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

2

5
 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.

Longe answered 6/1, 2015 at 9:24 Comment(0)
O
9
>>> 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

Officiary answered 6/1, 2015 at 10:27 Comment(1)
Thanks :). I was going crazy browsing for solutions.Longe
C
0

you forgot about the () after .definition bro.

try this line below, it will work.

print(wn.synsets('dog')[0].definition())

Chrysotile answered 19/9, 2020 at 4:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.