• python nltk nltk_data 离线安装,chatterbot


    离线数据包下载地址: 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')
  • 相关阅读:
    p4 view mapping及其特殊字符
    Build Release Blogs
    Linux技术blogs
    为什么使用tmux
    linux下安装wine
    PythonDjango的windows环境
    tmux安装
    基于云端的开发平台Team Foundation Service
    linux网络配置之setup命令
    Centos6.2设置静态ip和dns
  • 原文地址:https://www.cnblogs.com/dockers/p/11414881.html
Copyright © 2020-2023  润新知