2

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)) 
alyssaeliyah
  • 2,214
  • 6
  • 33
  • 80

1 Answers1

4

WordNet itself does not rank the synonyms. One synset is one class of equivalence. You can try measuring the cosine distance of word embeddings like GloVe or FastText, this can give you some approximation of semantic similarity.

Jindřich
  • 10,270
  • 2
  • 23
  • 44
  • Or you could measure "closeness" by minimum edit distance, if that is more suitable for you. – LetiP Nov 22 '19 at 09:57