nlp - How to iterate through the synset list generated from wordnet using python 3.4.2 -
i using wordnet find synonyms particular word shown below
synonyms = wn.synsets('good','a')
where wn wordnet. returns list of synsets
synset('good.a.01') synset('full.s.06') synset('good.a.03') synset('estimable.s.02') synset('beneficial.s.01')
etc...
how iterate through each synset , name , pos tag of each synset?
you can name , pos tag of each synset this:
from nltk.corpus import wordnet wn synonyms = wn.synsets('good','a') synset in synonyms: print(synset.name()) print(synset.pos())
the name combination of word, pos , sense, such 'full.s.06'. if want word, can split on dot '.' , take first element:
print(synset.name().split('.')[0]
Comments
Post a Comment