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

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

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

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

Build ARCH and GARCH Models in Time Series using Python
In this Project we will build an ARCH and a GARCH model using Python

Deep Learning Project- Real-Time Fruit Detection using YOLOv4
In this deep learning project, you will learn to build an accurate, fast, and reliable real-time fruit detection system using the YOLOv4 object detection model for robotic harvesting platforms.

Build a CNN Model with PyTorch for Image Classification
In this deep learning project, you will learn how to build an Image Classification Model using PyTorch CNN

Learn Object Tracking (SOT, MOT) using OpenCV and Python
Get Started with Object Tracking using OpenCV and Python - Learn to implement Multiple Instance Learning Tracker (MIL) algorithm, Generic Object Tracking Using Regression Networks Tracker (GOTURN) algorithm, Kernelized Correlation Filters Tracker (KCF) algorithm, Tracking, Learning, Detection Tracker (TLD) algorithm for single and multiple object tracking from various video clips.

Build Multi Class Text Classification Models with RNN and LSTM
In this Deep Learning Project, you will use the customer complaints data about consumer financial products to build multi-class text classification models using RNN and LSTM.

Abstractive Text Summarization using Transformers-BART Model
Deep Learning Project to implement an Abstractive Text Summarizer using Google's Transformers-BART Model to generate news article headlines.

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.

Build CNN for Image Colorization using Deep Transfer Learning
Image Processing Project -Train a model for colorization to make grayscale images colorful using convolutional autoencoders.

Azure Text Analytics for Medical Search Engine Deployment
Microsoft Azure Project - Use Azure text analytics cognitive service to deploy a machine learning model into Azure Databricks

Deep Learning Project for Time Series Forecasting in Python
Deep Learning for Time Series Forecasting in Python -A Hands-On Approach to Build Deep Learning Models (MLP, CNN, LSTM, and a Hybrid Model CNN-LSTM) on Time Series Data.