I\'m trying to get synonyms of a given word using Wordnet. The problem is that despite I\'m doing the same as is written here: here, it returns error.
Here is my code:<
Which version of nltk are you using (try print nltk.__version
)? Are you using python 2 or python 3? It seems that in the version you are using, lemma_names
is a method and not an attribute (this is the case in nltk 3.0 for Python 3). If this is the case then you can probably fix your code by using this instead:
for i,j in enumerate(wn.synsets('small')):
print "Synonyms:", ", ".join(j.lemma_names())
In Python 2 & 3 versions lemmas and lemma_names don't work as they are methods. You have to use lemmas() and lemma_names() instead.
For eg -
dog = wn.synset('dog.n.01')
print dog.lemma_names()