我NLTK數據~/nltk_data/corpora/words/(en,en-basic,README)
與蟒蛇
根據__init__.py
內~/lib/python2.7/site-packages/nltk/corpus
,閱讀在布朗語料庫中的詞的列表,使用 nltk.corpus.brown.words()
:
from nltk.corpus import brown
print brown.words()
['The', 'Fulton', 'County', 'Grand', 'Jury', 'said', ...]
這__init__.py
有
words = LazyCorpusLoader(
'words', WordListCorpusReader, r'(?!README|\.).*')
所以當我寫
from nltk.corpus import words
時,我是從__init__.py
導入位於目錄python2.7/site-packages/nltk/corpus
的'字詞'功能嗎?而且爲什麼會發生這種情況:
import nltk.corpus.words ImportError: No module named words from nltk.copus import words # WORKS FINE
的 「棕色」 語料庫駐留內
~/nltk_data/corpora
(而不是在NLTK /文集)。那麼爲什麼這個命令有效?from nltk.corpus import brown
不是這樣嗎?
from nltk_data.corpora import brown
作爲參考,來自解釋器的提示被解釋爲代碼塊的開始 - 我已將它們剝離出來,以使塊正常工作。 – thegrinner