I am attempting to get synonyms for a word using the python library NLTK.
My Problem: Some words create an error when I use them. For example ‘eat’ throws a WordNetError of “WordNetError: no lemma ‘eat’ with part of speech ‘n'”. What does that mean? How can I retrieve synonyms for the word eat?
Here’s my code, note how words like ‘dog’ do work:
from nltk.corpus import wordnet as wn
print wn.synset("dog.n.01").lemma_names
print wn.synset("eat.n.01").lemma_names
Also is it possible to get synonyms for a group of words? For example; for ‘main course’, can I get the synonyms ‘main dish’, ‘main meal’, ‘dinner’?
The error says
no lemma 'eat' with part of speech 'n'. That means that “eat” isn’t in WordNet as a noun. Try it as a verb: