NLTK Most common synonym (Wordnet) for each word

后端 未结 3 2087
生来不讨喜
生来不讨喜 2021-02-10 01:42

Is there a way to find the most common synonym of a word with NLTK? I would like to simplify a sentence using the most common synonyms of each word on it.

If a word use

3条回答
  •  天涯浪人
    2021-02-10 02:06

    The other answer shows you how to use synonyms:

    wn.synsets('small')
    [Synset('small.n.01'),
     Synset('small.n.02'),
     Synset('small.a.01'),
     Synset('minor.s.10'),
     Synset('little.s.03'),
     Synset('small.s.04'),
     Synset('humble.s.01'),
     Synset('little.s.07'),
     Synset('little.s.05'),
     Synset('small.s.08'),
     Synset('modest.s.02'),
     Synset('belittled.s.01'),
     Synset('small.r.01')]
    

    You now know how to get all the synonyms for a word. That's not the hard part. The hard part is determining what's the most common synonym. This question is highly domain dependent. Most common synonym where? In literature? In common vernacular? In technical speak?

    Like you, I wanted to get an idea of how the English language was used. I downloaded 15,000 entire books from (Project Gutenberg) and processed the word and letter pair frequencies on all of them. After ingesting such a large corpus, I could see which words were used most commonly. Like I said above, though, it will depend on what you're trying to process. If it's something like Twitter posts, try ingesting a ton of tweets. Learn from what you have to eventually process.

提交回复
热议问题