How Wu & Palmer Similarity works ?
It calculates relatedness by considering the depths of the two synsets in the WordNet taxonomies, along with the depth of the LCS (Least Common Subsumer).
The score can be 0 < score <= 1. The score can never be zero because the depth of the LCS is never zero (the depth of the root of taxonomy is one).
It calculates the similarity based on how similar the word senses are and where the Synsets occur relative to each other in the hypernym tree.
Code #1 : Introducing Synsets
hello name : hello.n.01 selling name : selling.n.01
Code #2 : Wu Similarity
hello and selling are apparently 27% similar! This is because they share common hypernyms further up the two.
Code #3 : Let’s check the hypernyms in between.
One of the core metrics used to calculate similarity is the shortest path the distance between the two Synsets and their common hypernym.
Code #4 : Let’s understand the use of hypernerm.
Self comprison : 1 Distance of hello from greeting : 11 Distance of greeting from hello : 11
Note : The similarity score is very high i.e. they are many steps away from each other becuase they are not so similar. The codes mentioned here uses ‘noun’ but one can use any Part of Speech (POS).
- Python | Measure similarity between two sentences using cosine similarity
- NLP | WordNet for tagging
- NLP | Synsets for a word in WordNet
- How to get synonyms/antonyms from NLTK WordNet in Python?
- Python | Similarity metrics of strings
- Python | Word Similarity using spaCy
- Python | Percentage similarity of lists
- Python | Test list element similarity
- NLP | Leacock Chordorow (LCH) and Path similarity for Synset
- Find if a degree sequence can form a simple graph | Havel-Hakimi Algorithm
- PyQt5 QRadioButton
- PyQt5 QToolButton
- Python | numpy.assert_allclose() method
- Python | Numpy.dsplit() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.