当前位置:   article > 正文

python nltk nltk_data 离线安装,chatterbot

vader_lexicon.zip
离线数据包下载地址: https://codeload.github.com/nltk/nltk_data/zip/gh-pages
unzip nltk_data-gh-pages.zip
cd nltk_data-gh-pages/packages/
cp -r * ~/nltk_data
批量解压 数据包:  ls *.zip | xargs -n1 unzip -o -P infected

chatterbot  每次启动执行 nltk_download_corpus  
[nltk_data] Error loading stopwords: <urlopen error [Errno 60]
[nltk_data]     Operation timed out>
[nltk_data] Error loading averaged_perceptron_tagger: <urlopen error
[nltk_data]     [Errno 60] Operation timed out>

chatterbot里stopwords在nltk-data目录下、上述下载方式stopwords在nltk-data下的corpora目录

由于目录结构问题导致每次下载 stopwords、wordnet、averaged_perceptron_tagger、vader_lexicon

而网络问题导致各种timed out

修改文件 .pyenv/versions/3.7.4/lib/python3.7/site-packages/chatterbot/utils.py  
 

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')

 

转载于:https://www.cnblogs.com/dockers/p/11414881.html

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

闽ICP备14008679号