2

so I'm relatively new to this and I'd like some help.

So I'm trying to get the Wordnet in nltk to use the Open Multilingual WordNet. This is the page I've come to which shows how to do this http://www.nltk.org/howto/wordnet.html

The problem is when I try sorted(wn.langs()) I get this error

Traceback (most recent call last): 
File "<stdin>", line 1, in <module>
AttributeError: 'WordNetCorpusReader' object has no attribute 'langs'

Since I'm using python 2.7 I know it would have to be sorted(wn.langs) instead of sorted(wn.langs()) but either way get this error.

Can anyone please help me with this?

Nolohice
  • 339
  • 4
  • 15

1 Answers1

2

I traced this down and I think it's a NLTK version issue. What NLTK version do you have?

If you start your interpreter and then run

from nltk.corpus import wordnet as wn
sorted(wn.langs())

When I ran this code under nltk==2.0.4 (also using Python 2.7), I saw the same error as you. So I checked the source code and the langs(self) method didn't exist. However, looking at the latest stable version on GitHub, you can see it is there.

Assuming you are using pip (if you aren't, and if you use Windows go here and follow the "Alternative Instructions"), do

pip install --upgrade nltk

And that should install nltk==3.0.0.

Run the code again and you should see

>>> sorted(wn.langs())
[u'als', u'arb', u'cat', u'cmn', u'dan', u'eng', u'eus', u'fas', u'fin', u'fra', u'fre', u'glg', u'heb', u'ind', u'ita', u'jpn', u'nno', u'nob', u'pol', u'por', u'spa', u'tha', u'zsm']
Community
  • 1
  • 1
Jeff
  • 227
  • 1
  • 10