【问题标题】:How to get a list of antonyms lemmas using Python, NLTK and WordNet?如何使用 Python、NLTK 和 WordNet 获取反义词引理列表?
【发布时间】:2017-11-22 18:22:14
【问题描述】:

我想使用 Python、NLTK 和 WordNet 生成给定引理的反义词引理列表。其实我只是想分享一个小实用功能。

【问题讨论】:

标签: python nlp nltk wordnet


【解决方案1】:

返回反义词列表的简单 Python 和 NLTK 函数

from nltk.corpus import wordnet as wn

def get_antonyms(input_lemma):
    antonyms = []
    for syn in wn.synsets(input_lemma):
        for lemma in syn.lemmas():
            if lemma.antonyms():
                antonyms.append(lemma.antonyms()[0].name())
    return antonyms

相关作品:How to generate a list of antonyms for adjectives in WordNet using Pythonhttp://www.geeksforgeeks.org/get-synonymsantonyms-nltk-wordnet-python/

【讨论】:

猜你喜欢
  • 2013-10-16
  • 1970-01-01
  • 1970-01-01
  • 2013-02-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多