NLTK TweetTokenizer不工作(Python)

2024-06-02 20:51:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前已经安装了NLTK并运行了命令nltk.download()。但是并不是所有的库都安装好了(它在panlex_-lite上卡住了)。在

问题是,当我试图导入Tweet Tokenizer时,我得到了一个错误:

File "create_docs.py", line 7, in

from nltk.tokenize import TweetTokenizer ImportError: cannot import 

name TweetTokenizer

我该怎么处理?干杯!在


Tags: pyimport命令docsdownload错误createlite
1条回答
网友
1楼 · 发布于 2024-06-02 20:51:39

这是因为没有正确安装库,所以需要跳过“panlex_lite”库,应该可以工作。在

Currently is open issue for this, solution will be as follow:

I guess, we could add something like if id != 'panlex_lite' to the code...

But, as for me, the easiest way looks like this:

get https://raw.githubusercontent.com/nltk/nltk_data/gh-pages/index.xml
remove panlex from it
upload it to a public Gist
pass the gist's url to the downloader: python -m nltk.downloader -d /usr/local/share/nltk_data -u https://gist.githubusercontent.com/demidovakatya/61dab385d74065ae825c80496a197980/raw/c6ff7fbf44265c7f8c9e961e3e1158cd812d6af1/index.xml all

以下是问题的链接:look at last 2 conversations

相关问题 更多 >