Change language

NLP | Synsets for a word in WordNet

| |

Synset — it is a special kind of simple interface that NLTK provides for searching words in WordNet. Instances of Synset — they are groups of synonymous words that express the same concept. Some words only have one Synset, and some — several.

Code # 1: Understanding Synset

from nltk.corpus import wordnet

syn = wordnet.synsets ( ’hello’ ) [ 0 ]

 

print ( "Synset name: " , syn.name ())

 
# Word definition

print ( "Synset meaning:" , syn.defin ition ())

 
# list of phrases using the word in context

print ( "Synset example:" , syn.examples ())

Exit :

 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 it can contain multiple items.

Hypernyms and Hyponyms —

Hypernyms : more abstract terms
Hyponyms: more specific terms.

Both are manifested in the fact that Synsets are organized in a structure similar to that of a tree inheritance. This tree can be traced back to the hyper root. Hyperonyms provide a way to categorize and group words based on their similarity to each other.

Code # 2: Understanding Hypernerms and Hyponyms

from nltk.corpus import wordnet

syn = wordnet.synsets ( ’hello’ ) [ 0 ]

 

print ( " Synset name: " , syn.name ())

 

print ( "Syns et abstract term: " , syn.hypernyms ())

  

print ( "Synset specific term: "

syn.hypernyms () [ 0 ]. hyponyms ())

  
syn.root_hypernyms ()

 

print ( "Synset root hypernerm: " , syn.root_hypernyms ())

Exit :

 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’), S ynset (’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.

syncode> = wordnet.synsets ( ’hello’ ) [ 0 ]

print ( "Syn tag:" , syn.pos ())

  

syncode> = wordnet.synsets ( ’ doing’ ) [ 0 ]

print ( "Syn tag:" , syn.pos ())

  

syn = wordnet.synsets ( ’beautiful’ ) [ 0 ]

print ( "Syn tag:" , syn.pos ())

 

syncode> = wordnet.s ynsets ( ’quickly’ ) [ 0 ]

print ( " Syn tag: " , syn.pos ())

Exit :

 Syn tag: n Syn tag: v Syn tag: a Syn tag: r 

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

Common xlabel/ylabel for matplotlib subplots

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

12 answers

NUMPYNUMPY

Flake8: Ignore specific warning for entire file

12 answers

NUMPYNUMPY

glob exclude pattern

12 answers

NUMPYNUMPY

How to avoid HTTP error 429 (Too Many Requests) python

12 answers

NUMPYNUMPY

Python CSV error: line contains NULL byte

12 answers

NUMPYNUMPY

csv.Error: iterator should return strings, not bytes

12 answers

News


Wiki

Python | How to copy data from one Excel sheet to another

Common xlabel/ylabel for matplotlib subplots

Check if one list is a subset of another in Python

sin

How to specify multiple return types using type-hints

exp

Printing words vertically in Python

exp

Python Extract words from a given string

Cyclic redundancy check in Python

Finding mean, median, mode in Python without libraries

cos

Python add suffix / add prefix to strings in a list

Why do I get "Pickle - EOFError: Ran out of input" reading an empty file?

Python - Move item to the end of the list

Python - Print list vertically