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

Churn Prediction in Telecom using Machine Learning in R
Estimating churners before they discontinue using a product or service is extremely important. In this ML project, you will develop a churn prediction model in telecom to predict customers who are most likely subject to churn.

Convolutional RCCn's for extracting the text out of images
CRNNs combine both convolutional and recurrent architectures and is widely used in text detection and optical character recognition (OCR). In this project, we are going to use a CRNN architecture to detect text in sample images. The data we are going to use is TRSynth100k from Kaggle. Given an image containing some text, the goal here is to correctly identify the text using the CRNN architecture. We are going to train the model end-to-end from scratch.

Customer Churn Prediction Analysis using Ensemble Techniques
In this machine learning churn project, we implement a churn prediction model in python using ensemble techniques.

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.

Time Series LSTM forecasting
In this project, we will use time-series forecasting to predict the values of a sensor using multiple dependent variables. A variety of machine learning models are applied in this task of time series forecasting. We will see a comparison between the LSTM, ARIMA and Regression models. Classical forecasting methods like ARIMA are still popular and powerful but they lack the overall generalizability that memory-based models like LSTM offer. Every model has its own advantages and disadvantages and that will be discussed. The main objective of this article is to lead you through building a working LSTM model and it's different variants such as Vanilla, Stacked, Bidirectional, etc. There will be special focus on customized data preparation for LSTM.

Expedia Hotel Recommendations Data Science Project
In this data science project, you will contextualize customer data and predict the likelihood a customer will stay at 100 different hotel groups.

Census Income Data Set Project - Predict Adult Census Income
Use the Adult Income dataset to predict whether income exceeds 50K yr based on census data.

Loan Eligibility Prediction in Python using
In this loan prediction project you will build predictive models in Python using to predict if an applicant is able to repay the loan or not.

Word2Vec and FastText Word Embedding with Gensim in Python
In this NLP Project, you will learn how to use the popular topic modelling library Gensim for implementing two state-of-the-art word embedding methods Word2Vec and FastText models.

Resume parsing with Machine learning - NLP with Python OCR and Spacy
In this machine learning resume parser example we use the popular Spacy NLP python library for OCR and text classification.