Reputation: 11
'See if you can print all the synset definitions of the lemma dog.'
So for this exercise, I'm told to run the code and download nltk, and then look up all the synset definitions of the lemma 'dog.'
The download runs, and it says 'true,' therefore, nltk was downloaded.
However, when I want to import wordnet from nltk_data.corpora (the nltk folder corpus), I can import it, but the attribute 'synset' from the wordnet dictionary outputs: 'AttributeError.'
In what way can I bring the output of synsets for the lemma 'dog'?
## help found on https://www.nltk.org/howto/wordnet.html
import nltk_data
from nltk_data.corpora import wordnet as wn
dog = wn.synset('dog.n.01')
Image of code error, view the full exercise description
Upvotes: 1
Views: 749
Reputation: 134
wn.synsets('dog')
[Synset('dog.n.01'), Synset('frump.n.01'), Synset('dog.n.03'), Synset('cad.n.01'), Synset('frank.n.02'), Synset('pawl.n.01'), Synset('andiron.n.01'), Synset('chase.v.01')]
[syn.definition() for syn in wn.synsets('dog')]
['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', 'a dull unattractive unpleasant girl or woman', 'informal term for a man', 'someone who is morally reprehensible', 'a smooth-textured sausage of minced beef or pork usually smoked; often served on a bread roll', 'a hinged catch that fits into a notch of a ratchet to move a wheel forward or prevent it from moving backward', 'metal supports for logs in a fireplace', 'go after with the intent to catch']
Upvotes: 0