0

I am trying to install the NLTK with IronPython in VS2012. But when I tried to import the NLTK.book, i got the following error. The NLTK.book is the accompanying data for the book.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "D:\NLP\IronPython 2.7\lib\site-packages\nltk\book.py", line 21, in <module>
    text1 = Text(gutenberg.words('melville-moby_dick.txt'))
  File "D:\NLP\IronPython 2.7\lib\site-packages\nltk\corpus\util.py", line 68, in __getattr__
    self.__load()
  File "D:\NLP\IronPython 2.7\lib\site-packages\nltk\corpus\util.py", line 55, in _LazyCorpusLoader__load
    try: root = nltk.data.find('corpora/%s' % zip_name)
LookupError: 
**********************************************************************
  Resource 'corpora/gutenberg' not found.  Please use the NLTK
  Downloader to obtain the resource:  >>> nltk.download()
  Searched in:
    - 'C:\\Users\\John/nltk_data'
    - '/usr/share/nltk_data'
    - '/usr/local/share/nltk_data'
    - '/usr/lib/nltk_data'
    - '/usr/local/lib/nltk_data'
**********************************************************************

I am wondering how to change the IronPath's search path.

4

1 回答 1

2

您需要下载 NLTK 附带的 corpora/gutenberg 资源。下载过程在这里解释:http: //nltk.org/data

基本上你需要做:

import nltk
nltk.download()

如果您已经在某处安装了 NLTK 资源,则需要将 NLTK_DATA 环境变量更改为该位置。

于 2013-12-30T16:26:12.277 回答