How to get antonyms of a particular word from wordnet in nlp

This recipe helps you get antonyms of a particular word from wordnet in nlp

Recipe Objective

How to get antonyms of a particular word from wordnet?

As we have discussed earlier only about wordnet, lets understand about antonyms. Antonyms these are the terms which are opposite of a word, word that means the opposite of another word.

for e.g Fast antonym is slow.

FastText and Word2Vec Word Embeddings Python Implementation

Step 1 - Import the necessary libraries

import nltk from nltk.corpus import wordnet

Step 2 - Store the antonym in a empty list

My_antonym = [] My_synonym = []

Step 3 - Take a word

for mysyn in wordnet.synsets("fast"): for l in mysyn.lemmas(): My_synonym.append(l.name()) if l.antonyms(): My_antonym.append(l.antonyms()[0].name())

Here we are taking a for loop which will generate the antonym of the word that we have taken

Step 4 - Print the result

print(set(My_antonym))

{'ill', 'badness', 'evilness', 'slow', 'bad', 'evil'}

What Users are saying..

profile image

Jingwei Li

Graduate Research assistance at Stony Brook University
linkedin profile url

ProjectPro is an awesome platform that helps me learn much hands-on industrial experience with a step-by-step walkthrough of projects. There are two primary paths to learn: Data Science and Big Data.... Read More

Relevant Projects

Tensorflow Transfer Learning Model for Image Classification
Image Classification Project - Build an Image Classification Model on a Dataset of T-Shirt Images for Binary Classification

AWS MLOps Project for Gaussian Process Time Series Modeling
MLOps Project to Build and Deploy a Gaussian Process Time Series Model in Python on AWS

Build a Face Recognition System in Python using FaceNet
In this deep learning project, you will build your own face recognition system in Python using OpenCV and FaceNet by extracting features from an image of a person's face.

Llama2 Project for MetaData Generation using FAISS and RAGs
In this LLM Llama2 Project, you will automate metadata generation using Llama2, RAGs, and AWS to reduce manual efforts.

Build a Review Classification Model using Gated Recurrent Unit
In this Machine Learning project, you will build a classification model in python to classify the reviews of an app on a scale of 1 to 5 using Gated Recurrent Unit.

Build a Speech-Text Transcriptor with Nvidia Quartznet Model
In this Deep Learning Project, you will leverage transfer learning from Nvidia QuartzNet pre-trained models to develop a speech-to-text transcriptor.

Build a Music Recommendation Algorithm using KKBox's Dataset
Music Recommendation Project using Machine Learning - Use the KKBox dataset to predict the chances of a user listening to a song again after their very first noticeable listening event.

Forecasting Business KPI's with Tensorflow and Python
In this machine learning project, you will use the video clip of an IPL match played between CSK and RCB to forecast key performance indicators like the number of appearances of a brand logo, the frames, and the shortest and longest area percentage in the video.

Learn How to Build PyTorch Neural Networks from Scratch
In this deep learning project, you will learn how to build PyTorch neural networks from scratch.

End-to-End Speech Emotion Recognition Project using ANN
Speech Emotion Recognition using RAVDESS Audio Dataset - Build an Artificial Neural Network Model to Classify Audio Data into various Emotions like Sad, Happy, Angry, and Neutral