Reputation: 2244
Is it possible to find synonyms of a word and rank the synonyms based on its closeness to the base word? Below is the code for finding the synonyms. I wish to give each synonym a rank. How can I do it?
import nltk
from nltk.corpus import wordnet
synonyms = []
for syn in wordnet.synsets("good"):
for l in syn.lemmas():
synonyms.append(l.name())
print(set(synonyms))
Upvotes: 2
Views: 374