栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

python chatterbot [nltk

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

python chatterbot [nltk

运行项目出现如下错误:

[nltk_data] Error loading stopwords: 
[nltk_data] Error loading averaged_perceptron_tagger: 

解决方法如下:

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

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

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

提取压缩文件

nltk_data-gh-pages.zipnltk_data-gh-pagespackages

所有文件到以下目录中

C:UsersAdministratorAppDataRoamingnltk_data

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

修改对应文件:

当前项目目录下venvLibsite-packageschatterbotutils.py

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

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

def download_nltk_stopwords():
    """
    Download required NLTK stopwords corpus if it has not already been downloaded.
    """
    nltk_download_corpus('corpora/stopwords')


def download_nltk_wordnet():
    """
    Download required NLTK corpora if they have not already been downloaded.
    """
    nltk_download_corpus('corpora/wordnet')


def download_nltk_averaged_perceptron_tagger():
    """
    Download the NLTK averaged perceptron tagger that is required for this algorithm
    to run only if the corpora has not already been downloaded.
    """
    nltk_download_corpus('taggers/averaged_perceptron_tagger')


def download_nltk_vader_lexicon():
    """
    Download the NLTK vader lexicon for sentiment analysis
    that is required for this algorithm to run.
    """
    nltk_download_corpus('sentiment/vader_lexicon')

愿你顺利解决问题

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/977495.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号