How to get hypernyms and hyponyms for a particular word in nlp

This recipe helps you get hypernyms and hyponyms for a particular word in nlp

Recipe Objective

How to get hypernyms and hyponyms for a particular word?

As we have discussed earlier only about Wordnet, now lets understand about hypernyms and hyponyms.

hypernym is a term whose meaning includes the meaning of other words, its a broad superordinate label that applies to many other members of set. It describes the more broad terms or we can say that more abstract terms.

for e.g hypernym of labrador, german sheperd is dog.

hyponym is a term which is more specialised and specific word, it is a hierarchical relationship which may consist of a number of levels. These are the more specific term. for e.g. dog is a hyponym of animal.

NLP Techniques to Learn for your Next NLP Project

Step 1 - Import the necessary libraries

from nltk.corpus import wordnet

Step 2 - Take a sample word in sysnsets

My_sysn = wordnet.synsets("Plane")[0]

Step 3 - Print the sysnset name

print("Print just the name:", My_sysn.name())

Print just the name: airplane.n.01

Step 4 - Print hypernym and hyponym

print("The Hypernym for the word is:",My_sysn.hypernyms(),'\n') print("The Hyponyms for the word is:",My_sysn.hyponyms())

The Hypernym for the word is: [Synset('heavier-than-air_craft.n.01')] 

The Hyponyms for the word is: [Synset('airliner.n.01'), Synset('amphibian.n.02'), Synset('biplane.n.01'), Synset('bomber.n.01'), Synset('delta_wing.n.01'), Synset('fighter.n.02'), Synset('hangar_queen.n.01'), Synset('jet.n.01'), Synset('monoplane.n.01'), Synset('multiengine_airplane.n.01'), Synset('propeller_plane.n.01'), Synset('reconnaissance_plane.n.01'), Synset('seaplane.n.01'), Synset('ski-plane.n.01'), Synset('tanker_plane.n.01')]

What Users are saying..

profile image

Savvy Sahai

Data Science Intern, Capgemini
linkedin profile url

As a student looking to break into the field of data engineering and data science, one can get really confused as to which path to take. Very few ways to do it are Google, YouTube, etc. I was one of... Read More

Relevant Projects

Ola Bike Rides Request Demand Forecast
Given big data at taxi service (ride-hailing) i.e. OLA, you will learn multi-step time series forecasting and clustering with Mini-Batch K-means Algorithm on geospatial data to predict future ride requests for a particular region at a given time.

PyCaret Project to Build and Deploy an ML App using Streamlit
In this PyCaret Project, you will build a customer segmentation model with PyCaret and deploy the machine learning application using Streamlit.

Learn to Build Generative Models Using PyTorch Autoencoders
In this deep learning project, you will learn how to build a Generative Model using Autoencoders in PyTorch

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.

End-to-End Snowflake Healthcare Analytics Project on AWS-2
In this AWS Snowflake project, you will build an end to end retraining pipeline by checking Data and Model Drift and learn how to redeploy the model if needed

Learn to Build an End-to-End Machine Learning Pipeline - Part 1
In this Machine Learning Project, you will learn how to build an end-to-end machine learning pipeline for predicting truck delays, addressing a major challenge in the logistics industry.

OpenCV Project for Beginners to Learn Computer Vision Basics
In this OpenCV project, you will learn computer vision basics and the fundamentals of OpenCV library using Python.

Personalized Medicine: Redefining Cancer Treatment
In this Personalized Medicine Machine Learning Project you will learn to classify genetic mutations on the basis of medical literature into 9 classes.

Recommender System Machine Learning Project for Beginners-1
Recommender System Machine Learning Project for Beginners - Learn how to design, implement and train a rule-based recommender system in Python

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.