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

Detectron2 Object Detection and Segmentation Example Python
Object Detection using Detectron2 - Build a Dectectron2 model to detect the zones and inhibitions in antibiogram images.

Digit Recognition using CNN for MNIST Dataset in Python
In this deep learning project, you will build a convolutional neural network using MNIST dataset for handwritten digit recognition.

Recommender System Machine Learning Project for Beginners-4
Collaborative Filtering Recommender System Project - Comparison of different model based and memory based methods to build recommendation system using collaborative filtering.

Deploy Transformer BART Model for Text summarization on GCP
Learn to Deploy a Machine Learning Model for the Abstractive Text Summarization on Google Cloud Platform (GCP)

Tensorflow Transfer Learning Model for Image Classification
Image Classification Project - Build an Image Classification Model on a Dataset of T-Shirt Images for Binary Classification

Build a Multi Class Image Classification Model Python using CNN
This project explains How to build a Sequential Model that can perform Multi Class Image Classification in Python using CNN

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

Build a Autoregressive and Moving Average Time Series Model
In this time series project, you will learn to build Autoregressive and Moving Average Time Series Models to forecast future readings, optimize performance, and harness the power of predictive analytics for sensor data.

Build Deep Autoencoders Model for Anomaly Detection in Python
In this deep learning project , you will build and deploy a deep autoencoders model using Flask.

Loan Eligibility Prediction Project using Machine learning on GCP
Loan Eligibility Prediction Project - Use SQL and Python to build a predictive model on GCP to determine whether an application requesting loan is eligible or not.