【问题标题】:How do I extract the offset of a WordNet synset give a synset in Python NLTK?如何在 Python NLTK 中提取 WordNet 同义词集的偏移量并给出同义词集?
【发布时间】:2015-09-22 06:08:46
【问题描述】:

WordNet 中的感觉偏移量是一个 8 位数字,后跟一个 POS 标记。例如,synset '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'?

【问题讨论】:

  • 您将从herehere 得到答案并进行一些实验

标签: python nlp nltk semantics wordnet


【解决方案1】:
>>> 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'

【讨论】:

猜你喜欢
  • 2017-04-18
  • 2014-08-31
  • 2011-12-26
  • 2013-10-16
  • 1970-01-01
  • 2013-03-11
  • 1970-01-01
  • 2013-08-30
  • 1970-01-01
相关资源
最近更新 更多