Get synonyms from synset returns error - Python

后端 未结 2 1731
执笔经年
执笔经年 2021-02-11 03:19

I\'m trying to get synonyms of a given word using Wordnet. The problem is that despite I\'m doing the same as is written here: here, it returns error.

Here is my code:<

2条回答
  •  忘了有多久
    2021-02-11 04:08

    Which version of nltk are you using (try print nltk.__version)? Are you using python 2 or python 3? It seems that in the version you are using, lemma_names is a method and not an attribute (this is the case in nltk 3.0 for Python 3). If this is the case then you can probably fix your code by using this instead:

    for i,j in enumerate(wn.synsets('small')):
        print "Synonyms:", ", ".join(j.lemma_names())
    

提交回复
热议问题