在IPython中控制檯我輸入from nltk.book import
,我得到了幾個LookupErrors。下面顯示了我得到的代碼。LookupError:從nltk.book進口*
*** 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.dowwnload()'這將打開一個面板。在那裏'Corpora'下載'gutenberrg'書/語料庫並再次嘗試你的命令 – Vaulstein
謝謝!有效!下載的錯誤消息中提到的語料庫。我是否需要其他語料庫,以後再不下載? –