【发布时间】:2017-11-22 18:22:14
【问题描述】:
我想使用 Python、NLTK 和 WordNet 生成给定引理的反义词引理列表。其实我只是想分享一个小实用功能。
【问题讨论】:
我想使用 Python、NLTK 和 WordNet 生成给定引理的反义词引理列表。其实我只是想分享一个小实用功能。
【问题讨论】:
返回反义词列表的简单 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 Python和http://www.geeksforgeeks.org/get-synonymsantonyms-nltk-wordnet-python/
【讨论】: