安装和使用NLTK分词和去停词

安装NLTK可能出现的问题:
1. pip install ntlk
2. 如果遇到缺少stopwords报错如下:(http://johnlaudun.org/20130126-nltk-stopwords/
LookupError:
**********************************************************************
  Resource u'corpora/stopwords' not found. Please use the
  NLTK Downloader to obtain the resource: >>> nltk.download()
  Searched in:
    - 'C:\\Users\\Tree/nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
    - 'F:\\Program Files (x86)\\python\\nltk_data'
    - 'F:\\Program Files (x86)\\python\\lib\\nltk_data'
    - 'C:\\Users\\Tree\\AppData\\Roaming\\nltk_data'
**********************************************************************
则有一下输入:
In[3]: import nltk
In[4]: nltk.download()
showing infohttp://www.nltk.org/nltk_data/
弹出窗口:

安装和使用NLTK分词和去停词

选择Corpora 然后找到stopword list确认,刷新
Out[4]: True

3.如果遇到缺少punkt报错如下:
LookupError:
**********************************************************************
Resource u'tokenizers/punkt/english.pickle' not found. Please
use the NLTK Downloader to obtain the resource:

    >>>nltk.download()

  Searched in:
    - 'C:\\Users\\Tree/nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
    - 'F:\\Program Files (x86)\\python\\nltk_data'
    - 'F:\\Program Files (x86)\\python\\lib\\nltk_data'
    - 'C:\\Users\\Tree\\AppData\\Roaming\\nltk_data'
**********************************************************************
解决方法
In[5]: nltk.download('punkt')
[nltk_data] Downloading package punkt to
[nltk_data] C:\Users\Tree\AppData\Roaming\nltk_data...
[nltk_data] Unzipping tokenizers\punkt.zip.

Out[5]: True

如果帮到你了,请赞赏支持:

安装和使用NLTK分词和去停词