jazzz jazzz - 3 months ago 7x
Python Question

error in nltk udhr module

I have an an error while running a code snippet from NLP with python..as follows

>>> 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'

I have already imported the required modules like
import nltk
I am new to python ,can someone tell me what the error is exactly..


You've made a typo:

it should be German_Deutsch not German_Deutsh

See Section 1.7 here: http://www.nltk.org/book/ch02.html

Note that the last line of the Stack trace indicates the corpus that couldn't be loaded which should be a hint if you run into this again