Do not get the desired result using the Wordnet type detection method

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

Expected Result:

'a book of recipes and cooking directions'

Actual output:

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

I cannot pinpoint the error in my code that causes the difference between the actual output and the expected output.

+4
source share
1 answer
>>> 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'

This is because the properties of the object Synsethave been changed to functions Synset, see https://github.com/nltk/nltk/commit/ba8ab7e23ea2b8d61029484098fd62d5986acd9c

+5
source

Source: https://habr.com/ru/post/1570128/


All Articles