当前位置:   article > 正文

python chatterbot [nltk_data] Error loading stopwords: <urlopen error [Errno 11004]_[nltk_data] error loading averaged_perceptron_tagg

[nltk_data] error loading averaged_perceptron_tagger:

运行项目出现如下错误:

  1. [nltk_data] Error loading stopwords: <urlopen error [Errno 11004]
  2. [nltk_data] getaddrinfo failed>
  3. [nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
  4. [nltk_data] [Errno 11004] getaddrinfo failed>

解决方法如下:

前往地址:https://github.com/nltk/nltk_data

进入目录/packages/corpora/找到对应的文件stopwords.zip放到对应的文件之下

推荐整个nltk_data项目都下载695M大小,避免了其他问题无法下载的情况!

提取压缩文件

nltk_data-gh-pages.zip\nltk_data-gh-pages\packages

所有文件到以下目录中

C:\Users\Administrator\AppData\Roaming\nltk_data

这里每个人安装的目录可能会不一样,我这里是上面的目录,

修改对应文件:

当前项目目录下\venv\Lib\site-packages\chatterbot\utils.py

(有些童鞋的目录可能不在当前项目之下,可根据自己的配置找到对应的site-packages目录然后找到对应的文件进行修改)

需修改对应代码nltk_download_corpus('xxx')如下:

  1. def download_nltk_stopwords():
  2. """
  3. Download required NLTK stopwords corpus if it has not already been downloaded.
  4. """
  5. nltk_download_corpus('corpora/stopwords')
  6. def download_nltk_wordnet():
  7. """
  8. Download required NLTK corpora if they have not already been downloaded.
  9. """
  10. nltk_download_corpus('corpora/wordnet')
  11. def download_nltk_averaged_perceptron_tagger():
  12. """
  13. Download the NLTK averaged perceptron tagger that is required for this algorithm
  14. to run only if the corpora has not already been downloaded.
  15. """
  16. nltk_download_corpus('taggers/averaged_perceptron_tagger')
  17. def download_nltk_vader_lexicon():
  18. """
  19. Download the NLTK vader lexicon for sentiment analysis
  20. that is required for this algorithm to run.
  21. """
  22. nltk_download_corpus('sentiment/vader_lexicon')

愿你顺利解决问题

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/盐析白兔/article/detail/344362
推荐阅读
相关标签