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



代码:

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

错误:

---------------------------------------------------------------------------
LookupError                               Traceback (most recent call last)
File ~anaconda3libsite-packagesnltkcorpusutil.py:84, in 
LazyCorpusLoader.__load(self)
83 try:
---> 84     root = nltk.data.find(f"{self.subdir}/{zip_name}")
85 except LookupError:
File ~anaconda3libsite-packagesnltkdata.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)

收到这个错误,我正在试用评论产品,用python中的表情符号和英文短格式替换评论。

您在导入nltk库中犯了错误。首先您可以下载stopword nltk,然后您可以在编程中使用stopword

代码

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

最新更新