When I try to print the hypernym, I just want the word rather the all the information about the word.
pp = wn.synset('grow.v.01')
pp1= pp.hypernyms()
print pp1
My output is [Synset('change.v.02')]. I just want "change". What change do i need to do? Sorry I am new to wordnet.
You can use the
lemma_names
function of theSynset
object. Bear in mind it returns list of names, you can pick the one you are happy with (in this case its only 1 result 'change').Also calling
hypernyms()
also returns you a list, thus I usedpp1[0]
. For example querying for 'dog' returns[dog, frump, cad...]
etc.. If you want to get alllemma_names
for all hypernyms, you can use a list comprehension.