如何提取WordNet语法集的偏移量以在Python NLTK中提供语法集?

如何提取WordNet语法集的偏移量以在Python NLTK中提供语法集?,python,nlp,nltk,semantics,wordnet,Python,Nlp,Nltk,Semantics,Wordnet,WordNet中的感知偏移量是一个8位数字,后跟一个POS标记。例如,同步集“dog.n.01”的偏移量为“02084071-n”。我尝试了以下代码: from nltk.corpus import wordnet as wn ss = wn.synset('dog.n.01') offset = str(ss.offset) print (offset) 但是,我得到了以下输出: <bound method Synset.offset of S

WordNet中的感知偏移量是一个8位数字,后跟一个POS标记。例如,同步集“dog.n.01”的偏移量为“02084071-n”。我尝试了以下代码:

    from nltk.corpus import wordnet as wn

    ss = wn.synset('dog.n.01')
    offset = str(ss.offset)
    print (offset)
但是,我得到了以下输出:

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


我如何获得这种格式的实际偏移量:“02084071-n”?

您将从和中获得答案,并进行一些实验!,请检查我的另一个问题:@alvas
>>> 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'