I would like to generate a list of antonyms lemmas of a given lemma using Python, NLTK, and WordNet. In fact I just want to share a small utility function.
Asked
Active
Viewed 1,089 times
3
-
See also https://stackoverflow.com/questions/24192979/how-to-generate-a-list-of-antonyms-for-adjectives-in-wordnet-using-python – alvas Nov 23 '17 at 00:53
1 Answers
4
A simple Python and NLTK function that returns a list of antonyms
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
Related works: How to generate a list of antonyms for adjectives in WordNet using Python and http://www.geeksforgeeks.org/get-synonymsantonyms-nltk-wordnet-python/

Claude COULOMBE
- 3,434
- 2
- 36
- 39
-
This is very similar to the code sample in http://www.geeksforgeeks.org/get-synonymsantonyms-nltk-wordnet-python/ – cs95 Nov 22 '17 at 18:26
-
Yes, you're right... I can cite this source, no problem. How can I do it? – Claude COULOMBE Nov 22 '17 at 18:49