Extract Word from Synset using Wordnet in NLTK 3.0

前端 未结 3 1480
梦如初夏
梦如初夏 2020-11-30 10:11

Some time ago, someone on SO asked how to retrieve a list of words for a given synset using NLTK\'s wordnet wrapper. Here is one of the suggested responses:

         


        
3条回答
  •  攒了一身酷
    2020-11-30 10:59

    Use:

    wn.synset('dog.n.1').name() 
    

    instead of:

    wn.synset('dog.n.1').name 
    

    because NLTK changed Synset properties to get functions instead. see https://github.com/nltk/nltk/commit/ba8ab7e23ea2b8d61029484098fd62d5986acd9c

    This is a good list of changes to NLTK's API to suit py3.x: https://github.com/nltk/nltk/wiki/Porting-your-code-to-NLTK-3.0

提交回复
热议问题