Word Sense Disambiguation

September 8, 2025 · View on GitHub

Anish Sachdeva (DTU/2K16/MC/13) Natural Language Processing (Dr. Seba Susan)

📘 Path Length Similarity | 📘 Resnik Similarity | 📗 Naïve Disambiguation | 📗 Simple LESK Algorithm | ✒ Report

booster


Overview


Introduction

We explore 4 different metrics to compare similarity and disambiguate words. For details, see the notebooks below:

Notebooks

  1. Naive Disambiguation
  2. Simple LESK Algorithm Disambiguation
  3. Path Length Similarity Metric
  4. Resnik Similarity Metric

To see the disambiguation of any word using the naive method, clone the repository and install dependencies:

git clone https://github.com/anishLearnsToCode/word-sense-disambiguation.git
pip install -r requirements.txt

Run the naive method directly from the root directory:

python -m src.naive_method
>> Enter word for disambiguation:    bank
>> Definition: a large natural stream of water (larger than a creek)
>> Examples:
>> ['they pulled the canoe up on the bank',
>> 'he sat on the bank of the river and watched the currents']

See a running example with explanation in this notebook.


Simple LESK Algorithm Disambiguation

The Simple LESK Algorithm uses tokens in the gloss surrounding the main word to disambiguate its meaning. Inverse Document Frequency (IDF) values are assigned as weights to all possible senses of the word.

Run directly from the root directory:

python -m src.simple_lesk_algorithm
>> Enter the Gloss (document):    i like a hot cup of java in the morning 
>> Enter word for disambiguation:    java
>> The disambiguated meaning is: a beverage consisting of an infusion of ground coffee beans
>> The weight vector is: [0, 0.28768207245178085, 0]

Path Length Similarity Disambiguation

The Path Length Similarity computes the minimum hop path between any two words in WordNet using Hypernym Paths. The similarity score is computed as:

similarity = -log(path_length(w1, w2))

Run similarity between two words:

python -m src.path_length_similarity
>> Enter first word:    dog
>> Enter second word:    wolf
>> Dog Definition: a member of the genus Canis (probably descended from the common wolf) that has been domesticated by man since prehistoric times; occurs in many breeds
>> Wolf Definition: any of various predatory carnivorous canine mammals of North America and Eurasia that usually hunt in packs
>> similarity: -0.6931471805599453

Compute similarity between the 6th document and other documents:

python -m src.path_similarity_resume

See results here and explanation in the notebook.


Resnik Similarity Disambiguation

The Resnik similarity computes the negative log probability of the lowest common subsumer of two words using the Brown IC Corpus.

Run similarity between two words:

python -m src.resnik_similarity
>> Enter the first word:    java
>> Enter the second word:    language
>> Java Definition: a platform-independent object-oriented programming language
>> Language Definition: a systematic means of communicating by the use of sounds or conventional symbols
>> similarity: 5.792086967391197

Run similarity between the 6th document and other documents:

python -m src.resnik_similarity_resume

See the Resnik similarity matrix here and explanation in the notebook.


Bibliography

  1. Speech & Language Processing ~ Jurafsky
  2. NLTK
  3. pickle
  4. pandas
  5. pandas.DataFrame
  6. Indexing and Slicing on Pandas DataFrames
  7. NumPy
  8. WordNet interface (NLTK)