Replace adverbs with their antonyms if antonym exists

Viewed 27

Is there a tool that can replace the adverbs of a set of sentences with their suitable antonym/synonym? I have used pos_tag universal to tag the pos. Could you please help me proceed further? Thankyou. I can use the code below to find the antonym of a word. How can I make it work for a particular pos. Can I use something like if pos_tag=='ADV'?

from nltk.corpus import wordnet
antonyms = []
for syn in wordnet.synsets("Happy"):
    for i in syn.lemmas():
         if i.antonyms():
              antonyms.append(i.antonyms()[0].name())

print(set(antonyms))
0 Answers
Related