如何解决jupyterhub - NLTK - 无法使用停用词 - 找不到资源停用词
我正在使用以下代码通过 jupyter notebook 使用停用词。我在 Linux 服务器上托管了 jupyter 并使用了笔记本。
python3 -m nltk.downloader stopwords
python3 -m nltk.downloader words
python3 -m nltk.downloader punkt
python3
>>>from nltk.corpus import stopwords
>>>stop_words = set(stopwords.words("english"))
>>>print(stop_words)
这在 python 终端中运行时工作正常,但是当我在 Jupyternotebook 中尝试以下时它失败并出现错误。
from nltk.corpus import stopwords
stop_words = set(stopwords.words("english"))
print(stop_words)
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
/usr/local/lib/python3.7/site-packages/nltk/corpus/util.py in __load(self)
82 try:
---> 83 root = nltk.data.find("{}/{}".format(self.subdir,zip_name))
84 except LookupError:
/usr/local/lib/python3.7/site-packages/nltk/data.py in find(resource_name,paths)
582 resource_not_found = "\n%s\n%s\n%s\n" % (sep,msg,sep)
--> 583 raise LookupError(resource_not_found)
584
LookupError:
**********************************************************************
Resource stopwords not found.
Please use the NLTK Downloader to obtain the resource:
解决方法
尝试在 jupyter notebook 中运行
import nltk
nltk.download('stopwords')
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。