我的 nltk 数据是~/nltk_data/corpora/words/(en,en-basic,README)
根据__init__.pyinside ~/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中的'words'函数 吗?__init__.pypython2.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/corpus 中)。那么为什么这个命令有效呢?from nltk.corpus import brown不应该是这个吗?
from nltk_data.corpora import brown