600字范文,内容丰富有趣,生活中的好帮手!
600字范文 > 已解决Resource stopwords not found. Please use the NLTK Downloader to obtain the resource:

已解决Resource stopwords not found. Please use the NLTK Downloader to obtain the resource:

时间:2022-08-11 18:25:05

相关推荐

已解决Resource stopwords not found. Please use the NLTK Downloader to obtain the resource:

已解决(nltk加载停用词词库报错问题)Resource stopwords not found.

Please use the NLTK Downloader to obtain the resource:

文章目录

报错代码报错翻译报错原因解决方法帮忙解决

报错代码

粉丝群里面的一个小伙伴想用nltk加载停用词,在网上复制别人的代码运行的时候发生了报错(当时他心里瞬间凉了一大截,跑来找我求助,然后顺利帮助他解决了,顺便记录一下希望可以帮助到更多遇到这个bug不会解决的小伙伴),报错代码如下:

from nltk.corpus import stopwordsstop_words = set(stopwords.words('english'))print(stop_words)

我们可以看到他导包没有任何问题(已经安装了nltk模块):

报错信息内容如下

Traceback (most recent call last):File "D:\Python3.8\lib\site-packages\nltk\corpus\util.py", line 84, in __loadroot = nltk.data.find(f"{self.subdir}/{zip_name}")File "D:\Python3.8\lib\site-packages\nltk\data.py", line 583, in findraise LookupError(resource_not_found)LookupError: **********************************************************************Resource stopwords not found.Please use the NLTK Downloader to obtain the resource:>>> import nltk>>> nltk.download('stopwords')For more information see: /data.htmlAttempted to load corpora/stopwords.zip/stopwords/Searched in:- 'C:\\Users\\Administrator/nltk_data'- 'D:\\Python3.8\\nltk_data'- 'D:\\Python3.8\\share\\nltk_data'- 'D:\\Python3.8\\lib\\nltk_data'- 'C:\\Users\\Administrator\\AppData\\Roaming\\nltk_data'- 'C:\\nltk_data'- 'D:\\nltk_data'- 'E:\\nltk_data'**********************************************************************

报错翻译

报错信息翻译:

找不到资源stopwords。

请使用NLTK下载程序获取资源:

报错原因

报错原因:安装nltk库的时候不会自动安装停用词库,按照下面的方式手动安装即可,博主已经把词库下载好了,自行免费下载领取!!!

解决方法

当时我查阅资料得知,可以自己下载这个数据。根据报错信息提示放到以下任一目录即可(注意:每个人的目录不一定)

我是在Python3.8文件夹下,创建一个nltk_data文件夹,往下在创建一个corpora文件夹,最后把stopwords解压后的文件夹放在corpora文件夹下:D:\Python3.8\nltk_data\corpora:

再次运行程序就可以看到停用词库加载出来了:

博主已经下好了NLTK 常用的三个词库:停用词词库、词性词库。。。关注文末公众号回复:nltk_data,即可领取!!!下载后放到自己的报错信息的指定文件路径下即可!

关注文末公众号回复nltk_data

帮忙解决

本文已收录于:《告别Bug》专栏

本专栏用于记录学习和工作中遇到的各种疑难Bug问题,以及粉丝群里小伙伴提出的各种问题,文章形式:报错代码 + 报错翻译 + 报错原因 + 解决方法,包括程序安装、运行程序过程中等等问题,订阅专栏+关注博主后如遇到其他问题可私聊帮忙解决!!!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。