The following code uses a seed positive word and adds all of its synonym members (lemmas) to a list.
from nltk.corpus import wordnet as wn
def pos_expansion():
pos_list = ['good'] #positive seed list
lemmas = [] #list of lemmas
unique_lemmas = []
for pos_word in pos_list:
for synset in wn.synsets(pos_word):
if synset.pos() in ['a', 's']: #restrict synsets to adjectives only
lemmas = lemmas + synset.lemma_names() #add all synonyms (lemmas) within each synset of pos_word
print(lemmas)
pos_expansion()
I want to do the same, but with synsets. I want to return a list of actual synsets based on the also-see, similar-to and attribute relations in NLTK's WordNet (assuming the seed synset is 'good.a.01'). Is this possible? Thanks in advance.
Synsets have different relations that individual terms in WN. Synset relations required are as follows:
for i in wn.all_synsets():
print(i._related('n'))
print(i.also_sees())
print(i.similar_tos())