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

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Zillow’s Home Value Prediction (Zestimate)
Data Science Project in R -Build a machine learning algorithm to predict the future sale prices of homes.

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.

Human Activity Recognition Using Smartphones Data Set
In this deep learning project, you will build a classification system where to precisely identify human fitness activities.

Ensemble Machine Learning Project - All State Insurance Claims Severity Prediction
In this ensemble machine learning project, we will predict what kind of claims an insurance company will get. This is implemented in python using ensemble machine learning algorithms.

Customer Market Basket Analysis using Apriori and Fpgrowth algorithms
In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

Mercari Price Suggestion Challenge Data Science Project
Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

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 - Instacart Market Basket Analysis
Data Science Project - Build a recommendation engine which will predict the products to be purchased by an Instacart consumer again.