gpt4 book ai didi

python - 使用 Wordnet Synset 的定义方法未获得所需的输出

转载 作者:太空狗 更新时间:2023-10-30 02:19:44 24 4
gpt4 key购买 nike

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

预期输出:

'a book of recipes and cooking directions'

实际输出:

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

我无法查明我的代码中导致实际输出与预期输出之间存在差异的错误。

最佳答案

>>> 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'

这是因为Synset 对象属性已更改为Synset 函数,参见https://github.com/nltk/nltk/commit/ba8ab7e23ea2b8d61029484098fd62d5986acd9c

关于python - 使用 Wordnet Synset 的定义方法未获得所需的输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27795623/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com