How to get synonyms of a particular word from wordnet?

How to get synonyms of a particular word from wordnet?

How to get synonyms of a particular word from wordnet?

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


Recipe Objective

How to get synonyms of a particular word from wordnet.

Wordnet It is nothing but the lexical database or we can say dictionary for English language which is specifically desined for NLP (natuaral language processing). To look up words in wordnet a special kind of a simple interface is present in the NLTK library i.e Synset which is nothing but "sets of cognitive synonyms".

WordNet hastily looks like a thesaurus, in that it bunches words together dependent on their implications. It additionally interlinks the word structures series of letters as well as explicit feelings of words. WordNet marks the semantic relationship among words, though the groupings of words in a thesaurus don't follow any unequivocal example other than significance similitude.

Step 1 - Import the necessary libraries

from nltk.corpus import wordnet

Step 2 - Find the Sysnsets of words

My_sysn = wordnet.synsets("fight")

Here we are going to find synonyms for "Write" word.

Step 3 - Print the result

print("Print an Example of the word:",My_sysn[0].name(), "\n") print("Print just the word:", My_sysn[0].lemmas()[0].name(),"\n") print("Definition of word:", My_sysn[0].definition(),'\n') print("Examples of the word in use in sentences:",My_sysn[0].examples())
Print an Example of the word: battle.n.01 

Print just the word: battle 

Definition of word: a hostile meeting of opposing military forces in the course of a war 

Examples of the word in use in sentences: ['Grant won a decisive victory in the battle of Chickamauga', 'he lost his romantic ideas about war when he got into a real engagement']

Relevant Projects

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.

Forecast Inventory demand using historical sales data in R
In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

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 Census Income using Deep Learning Models
In this project, we are going to work on Deep Learning using H2O to predict Census income.

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.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

Data Science Project in Python on BigMart Sales Prediction
The goal of this data science project is to build a predictive model and find out the sales of each product at a given Big Mart store.

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 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.

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.