How to get antonyms of a particular word from wordnet?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

How to get antonyms of a particular word from wordnet?

How to get antonyms of a particular word from wordnet?

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

0

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.

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'}

Relevant Projects

Machine Learning project for Retail Price Optimization
In this machine learning pricing project, we implement a retail price optimization algorithm using regression trees. This is one of the first steps to building a dynamic pricing model.

Learn to prepare data for your next machine learning project
Text data requires special preparation before you can start using it for any machine learning project.In this ML project, you will learn about applying Machine Learning models to create classifiers and learn how to make sense of textual data.

Predict Macro Economic Trends using Kaggle Financial Dataset
In this machine learning project, you will uncover the predictive value in an uncertain world by using various artificial intelligence, machine learning, advanced regression and feature transformation techniques.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

Data Science Project on Wine Quality Prediction in R
In this R data science project, we will explore wine dataset to assess red wine quality. The objective of this data science project is to explore which chemical properties will influence the quality of red wines.

Ecommerce product reviews - Pairwise ranking and sentiment analysis
This project analyzes a dataset containing ecommerce product reviews. The goal is to use machine learning models to perform sentiment analysis on product reviews and rank them based on relevance. Reviews play a key role in product recommendation systems.

Demand prediction of driver availability using multistep time series analysis
In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

Predict Credit Default | Give Me Some Credit Kaggle
In this data science project, you will predict borrowers chance of defaulting on credit loans by building a credit score prediction model.

Predict Churn for a Telecom company using Logistic Regression
Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.

Sequence Classification with LSTM RNN in Python with Keras
In this project, we are going to work on Sequence to Sequence Prediction using IMDB Movie Review Dataset​ using Keras in Python.