nltk udhr模块中的错误

时间:2014-08-10 08:25:10

标签: python python-2.7 ubuntu-14.04 nltk

从NLP运行代码片段时出现错误,其中包含python..as

>>> from nltk.corpus import udhr
>>> languages = ['Chickasaw','English','German_Deutsh',
...     'Greenlandic_Inuktikut','Hungarian_Magyar','Ibibio_Efik']
>>> cfd = nltk.ConditionalFreqDist(
...             (lang,len(word))
...             for lang in languages
...             for word in udhr.words(lang + '-Latin1'))
Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
  File "/usr/local/lib/python2.7/dist-packages/nltk/probability.py", line 1729, in __init__
    for (cond, sample) in cond_samples:
  File "<stdin>", line 4, in <genexpr>
  File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/reader/plaintext.py", line 91, in words
    in self.abspaths(fileids, True, True)])
  File "/usr/local/lib/python2.7/dist-packages/nltk/corpus/reader/api.py", line 167, in abspaths
    paths = [self._root.join(f) for f in fileids]
  File "/usr/local/lib/python2.7/dist-packages/nltk/data.py", line 176, in join
    return FileSystemPathPointer(path)
  File "/usr/local/lib/python2.7/dist-packages/nltk/data.py", line 154, in __init__
    raise IOError('No such file or directory: %r' % path)
IOError: No such file or directory: '/home/anupam/nltk_data/corpora/udhr/German_Deutsh-Latin1'

我已经导入了所需的模块 import nltk 我是python的新手,有人可以告诉我错误是什么......

1 个答案:

答案 0 :(得分:1)

你犯了一个错字:

它应该是German_Deutsch而不是German_Deutsh

请参见第1.7节:http://www.nltk.org/book/ch02.html

请注意,堆栈跟踪的最后一行表示无法加载的语料库,如果再次遇到此错误应该是一个提示