在iPython控制台中,我输入了
from nltk.book import
,然后出现了几个LookupErrors错误。以下是我得到的代码。*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
---------------------------------------------------------------------------
LookupError Traceback (most recent call last)
<ipython-input-3-8446809acbd4> in <module>()
----> 1 from nltk.book import*
C:\Users\dell\Anaconda\lib\site-packages\nltk-3.0.3-py2.7.egg\nltk\book.py in <module>()
20 print("Type: 'texts()' or 'sents()' to list the materials.")
21
---> 22 text1 = Text(gutenberg.words('melville-moby_dick.txt'))
23 print("text1:", text1.name)
24
C:\Users\dell\Anaconda\lib\site-packages\nltk-3.0.3-py2.7.egg\nltk\corpus\util.pyc in __getattr__(self, attr)
97 raise AttributeError("LazyCorpusLoader object has no attribute '__bases__'")
98
---> 99 self.__load()
100 # This looks circular, but its not, since __load() changes our
101 # __class__ to something new:
C:\Users\dell\Anaconda\lib\site-packages\nltk-3.0.3-py2.7.egg\nltk\corpus\util.pyc in __load(self)
62 except LookupError as e:
63 try: root = nltk.data.find('corpora/%s' % zip_name)
---> 64 except LookupError: raise e
65
66 # Load the corpus.
LookupError:
**********************************************************************
Resource u'corpora/gutenberg' not found. Please use the NLTK
Downloader to obtain the resource: >>> nltk.download()
Searched in:
- 'C:\\Users\\dell/nltk_data'
- 'C:\\nltk_data'
- 'D:\\nltk_data'
- 'E:\\nltk_data'
- 'C:\\Users\\dell\\Anaconda\\nltk_data'
- 'C:\\Users\\dell\\Anaconda\\lib\\nltk_data'
- 'C:\\Users\\dell\\AppData\\Roaming\\nltk_data'
**********************************************************************
In [4]:
我可以知道为什么会出现这些错误吗?
nltk.download()
命令,它会打开一个面板。在那里,在Corpora
中下载gutenberg
书籍/语料库,然后再次尝试您的命令。 - Vaulstein