Not getting the required output using Wordnet Synset's definition method

一个人想着一个人 提交于 2019-12-19 03:35:19

问题


 from nltk.corpus import wordnet 
 syn=wordnet.synsets('cookbook')[0]
 print syn.definition

Expected Output:

'a book of recipes and cooking directions'

Actual Output:

bound method Synset.definition of Synset('cookbook.n.01')

I am unable to pinpoint the error in my code which is causing the difference between the actual output and the expected output.


回答1:


>>> from nltk.corpus import wordnet as wn
>>> wn.synsets('dog')[0]
Synset('dog.n.01')
>>> wn.synsets('dog')[0].definition
<bound method Synset.definition of Synset('dog.n.01')>
>>> wn.synsets('dog')[0].definition()
u'a member of the genus Canis (probably descended from the common wolf) that has been domesticated by man since prehistoric times; occurs in many breeds'

It's because Synset object properties has been changed to Synset functions, see https://github.com/nltk/nltk/commit/ba8ab7e23ea2b8d61029484098fd62d5986acd9c



来源:https://stackoverflow.com/questions/27795623/not-getting-the-required-output-using-wordnet-synsets-definition-method

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!