2

A sense offset in WordNet is an 8 digit number followed by a POS tag. For example, the offset for the synset 'dog.n.01' is '02084071-n'. I have tried the following code:

    from nltk.corpus import wordnet as wn

    ss = wn.synset('dog.n.01')
    offset = str(ss.offset)
    print (offset)

However, I get this output:

    <bound method Synset.offset of Synset('dog.n.01')>

How do I get the actual offset in this format: '02084071-n'?

alvas
  • 115,346
  • 109
  • 446
  • 738
modarwish
  • 495
  • 10
  • 22
  • You will get your answer from [here](http://stackoverflow.com/questions/27091571/get-synonyms-from-synset-returns-error-python) and [here](http://stackoverflow.com/questions/8077641/how-to-get-the-wordnet-synset-given-an-offset-id) and a little experimenting – Vaulstein Jul 04 '15 at 17:46

1 Answers1

6
>>> from nltk.corpus import wordnet as wn
>>> ss = wn.synset('dog.n.01')
>>> offset = str(ss.offset()).zfill(8) + '-' + ss.pos()
>>> offset
u'02084071-n'
alvas
  • 115,346
  • 109
  • 446
  • 738
  • thanks!, please check my other question: http://stackoverflow.com/questions/31234168/how-do-i-calculate-the-shortest-path-geodesic-distance-between-two-adjectives @alvas – modarwish Jul 05 '15 at 19:27