sazr
sazr

Reputation: 25928

Find Synonyms for multi-word phrases

Is it possible for the python library NLTK to suggest/create synonyms for groups of words?

For example; for the word/group "main course" can I use NLTK to get the synonyms "main dish", "main meal", "dinner" etc.?

Heres my code that works for single word synonyms but not multiwords:

from nltk.corpus import wordnet as wn
print wn.synset("eat.v.01").lemma_names # prints synonyms of eat
print wn.synset("main course.n.01").lemma_names # throws WordNetError

Upvotes: 5

Views: 4352

Answers (1)

Usagi
Usagi

Reputation: 2946

Use an underscore:

print wn.synset("main_course.n.01").lemma_names

Upvotes: 4

Related Questions