5

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
sazr
  • 24,984
  • 66
  • 194
  • 362

1 Answers1

4

Use an underscore:

print wn.synset("main_course.n.01").lemma_names
Usagi
  • 2,896
  • 2
  • 28
  • 38