简体   繁体   English

在 python(jupyter) 中运行 nltk.corpus 数据但显示此错误所以我该怎么办?

[英]Run nltk.corpus data in python(jupyter) but shown this error So What should i do?

code:代码:

from nltk.corpus import stopwords
stop = stopwords.words('english')

Error:错误:

---------------------------------------------------------------------------
LookupError                               Traceback (most recent call last)
File ~\anaconda3\lib\site-packages\nltk\corpus\util.py:84, in 
 LazyCorpusLoader.__load(self)
       83 try:
  ---> 84     root = nltk.data.find(f"{self.subdir}/{zip_name}")
       85 except LookupError:

    File ~\anaconda3\lib\site-packages\nltk\data.py:583, in find(resource_name, paths)
       582 resource_not_found = f"\n{sep}\n{msg}\n{sep}\n"
   --> 583 raise LookupError(resource_not_found)

Getting this Error, I am trying the review product by replacing reviews with emoji and English short forms in python.收到此错误,我正在尝试通过在 python 中用表情符号和英文短 forms 替换评论来尝试评论产品。

You are doing the mistake in the import nltk library.First you can download stopword nltk library then you can used the stopword in you program您在导入 nltk 库中犯了错误。首先您可以下载停用词 nltk 库,然后您可以在程序中使用停用词

Code代码

import nltk
from nltk.corpus import stopwords
nltk.download("stopwords") 
stop = set(stopwords.words('english'))
stop

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM