nltk - Python: Retrieving WordNet hypernyms from offset input -


i know how hypernyms of words, :

word = 'girlfriend' word_synsets = wn.synsets(word)[0]  hypernyms = word_synsets.hypernym_paths()[0]  element in hypernyms:     print element   synset('entity.n.01') synset('physical_entity.n.01') synset('causal_agent.n.01') synset('person.n.01') synset('friend.n.01') synset('girlfriend.n.01') 

my question is, if wanted search hypernym of offset, how change current code?

for example, given offset 01234567-n hypernyms outputted. hypernyms can either outputted in synset form example, or (and preferably) offset form. thanks.

here's cute function pywsd that's http://moin.delph-in.net/semcor

def offset_to_synset(offset):     """      synset given offset-pos      (thanks @fbond, see http://moin.delph-in.net/semcor)     >>> synset = offset_to_synset('02614387-v')     >>> print '%08d-%s' % (synset.offset, synset.pos)     >>> print synset, synset.definition     02614387-v     synset('live.v.02') lead kind of life; live in style     """     return wn._synset_from_pos_and_offset(str(offset[-1:]), int(offset[:8])) 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -