How to get synonyms from nltk WordNet Python

后端 未结 6 1359
礼貌的吻别
礼貌的吻别 2020-11-30 04:10

WordNet is great, but I\'m having a hard time getting synonyms in nltk. If you search similar to for the word \'small\' like here, it shows all of the synonyms.

Ba

6条回答
  •  清歌不尽
    2020-11-30 04:38

    I've code Thesaurus Lookup for Synonym recently, I used this function :

    def find_synonyms(keyword) :
    
        synonyms = []
        for synset in wordnet.synsets(keyword):
            for lemma in synset.lemmas():
                synonyms.append(lemma.name())
    
        return str(synonyms)
    

    But if you prefer to host your own Dictionary, you might interested with my project on offline synonym dictionary lookup on my github page :

    https://github.com/syauqiex/offline_english_synonym_dictionary

提交回复
热议问题