WordNet is the lexical database i.e. dictionary for the English language, specifically designed for natural language processing.
Synset is a special kind of a simple interface that is present in NLTK to look up words in WordNet. Synset instances are the groupings of synonymous words that express the same concept. Some of the words have only one Synset and some have several.
Code #1 : Understanding Synset
Synset name : hello.n.01 Synset meaning : an expression of greeting Synset example : ['every morning they exchanged polite hellos']
wordnet.synsets(word) can be used to get a list of Synsets. This list can be empty (if no such word is found) or can have few elements.
Hypernyms and Hyponyms –
Hypernyms: More abstract terms
Hyponyms: More specific terms.
Both come to picture as Synsets are organized in a structure similar to that of an inheritance tree. This tree can be traced all the way up to a root hypernym. Hypernyms provide a way to categorize and group words based on their similarity to each other.
Code #2 : Understanding Hypernerms and Hyponyms
Synset name : hello.n.01 Synset abstract term : [Synset('greeting.n.01')] Synset specific term : [Synset('calling_card.n.02'), Synset('good_afternoon.n.01'), Synset('good_morning.n.01'), Synset('hail.n.03'), Synset('hello.n.01'), Synset('pax.n.01'), Synset('reception.n.01'), Synset('regard.n.03'), Synset('salute.n.02'), Synset('salute.n.03'), Synset('welcome.n.02'), Synset('well-wishing.n.01')] Synset root hypernerm : [Synset('entity.n.01')]
Code #3 : Part of Speech (POS) in Synset.
Syn tag : n Syn tag : v Syn tag : a Syn tag : r
- NLP | WordNet for tagging
- NLP | WuPalmer - WordNet Similarity
- How to get synonyms/antonyms from NLTK WordNet in Python?
- Python program to read file word by word
- NLP | Likely Word Tags
- NLP | Word Collocations
- ML | Word Encryption using Keras
- Python | Word Stretch
- Python - Get Nth word in given String
- Word Prediction using concepts of N - grams and CDF
- Generating Word Cloud in Python | Set 2
- Generating Word Cloud in Python
- Python | Word Embedding using Word2Vec
- Python | Word Similarity using spaCy
- Python - Kth word replace in String
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.