pycharm 如何解决停用词错误在耙沿着与许多更多?

b5buobof  于 12个月前  发布在  PyCharm
关注(0)|答案(1)|浏览(283)

"D:\Python files\venv\Scripts\python.exe""D:/Python files/www.example.com" Traceback(most recent call last):File "D:\Python files\venv\lib\site-packages\nltk\corpus\util.py",line 84,in__load root = nltk. data. find(f "{self. subdir}/{zip_name}")File "D:\Python files\venv\lib\site-packages\nltk\data.py",line 583,in find raise LookupError(resource_not_found)LookupError:
找不到资源停止字。请使用NLTK下载器获取资源:
import nltk www.example.com('stopwords')
有关更多信息,请参阅:https://www.nltk.org/data.html
尝试加载语料库/www.example.com
搜索:- "C:\Users\Harsh/nltk_data"-"D:\Python files\venv\nltk_data"-"D:\Python files\venv\share\nltk_data"-"D:\Python files\venv\lib\nltk_data"-"C:\Users\Harsh\AppData\Roaming\nltk_data"-"C:\nltk_data"-"D:\nltk_data"-"E:\nltk_data"
在处理上述异常的过程中,又出现了一个异常:
回溯(most recent call last):File "D:\Python files\main.py",line 16,in r = Rake()File "D:\Python files\venv\lib\site-packages\rake_nltk\rake.py",第84行,在initself中. stopwords = set(nltk. corpus. stopwords. words(language))文件"D:\Python files\venv\lib\site-packages\nltk\corpus\util.py",第121行,在getattrself.__load()文件"D:\Python files\venv\lib\site-packages\nltk\corpus\util.py",line 86,in__load raise e File" D:\python files\venv\lib\site-packages\nltk\corpus\util.py",第81行,in__load root = nltk. data. find(f"{self. subdir}/{self.__name}")文件" D:\Python files\venv\lib\site-packages\nltk\data.py",第583行,在find raise中LookupError(resource_not_found)LookupError:
找不到资源停止字。请使用NLTK下载器获取资源:
import nltk www.example.com('stopwords')
有关更多信息,请参阅:https://www.nltk.org/data.html
尝试加载语料库/停用词
搜索:- "C:\Users\Harsh/nltk_data"-"D:\Python files\venv\nltk_data"-"D:\Python files\venv\share\nltk_data"-"D:\Python files\venv\lib\nltk_data"-"C:\Users\Harsh\AppData\Roaming\nltk_data"-"C:\nltk_data"-"D:\nltk_data"-"E:\nltk_data"
进程已完成,退出代码为% 1
已尝试插入代码,正在解决语法错误,需要解决方案

fkvaft9z

fkvaft9z1#

你可以通过在python IDE中运行这段代码来解决这个问题

import nltk
import ssl

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    pass
else:
    ssl._create_default_https_context = _create_unverified_https_context

nltk.download()

字符串
之后,它会打开一个窗口,允许您选择要使用的nltk资源。它应该是这样的:x1c 0d1x
然后你点击“下载”,你应该准备好去!

相关问题