Three Word-Sense Disambiguation Algorithms
Word sense disambiguation (w.s.d.) is that part of natural language processing that deals with attributing to a word (token) its meaning in the context in which it appears.
In this article there are presented three probabilistic algorithms to solve this problem, together with their implementation in Python.
The algorithms are:
- Naive Bayes;
- Lesk algorithm;
- EM (Expectation-Maximization) algorithm;
Naive Bayes Algorithm
This algorithm belongs to the supervised learning algorithm class and it’s based on three factors:
To simplify, we define a feature fi of a word wi all the other words wj that appear in the same sentence; with i ≠ j.
So we have:
The result of the last expression represents the most suitable meaning for the word w.
Python implementation: naive_bayes.py
The Lesk algorithm uses a dictionary to disambiguate words: WordNET is the database we need.
The concept behind Lesk’s algorithm is the overlapping between the dictionary definition and the context in which the word to be disambigured appears. More precisely, the meaning given by the algorithm is the one in whose definition (which can be extended with some example sentences) appears the largest number of words (features) of the context.
Python implementation: lesk.py
The Expectation-Maximization algorithm is part of the unsupervised learning algorithm class.
The goal is to maximize the likelihood of the corpus:
where C is the corpus and ci are the individual contexts that make up the corpus, i.e. the sentences.
At the beginning the parameters P(sk) and P(fj|sk) are initialized randomly. As the name suggests, the iterative algorithm is composed of the phases:
- E-step: esitimate the posterior probability that the sense sk generates the context ci.
- M-step: recalculation of the parameters P(sk) and P(fj|sk).
The iterative cycle continues until l(C) is improved.
Python implementation: em.py
Although I have not found any errors in the source code except those reported with the comments in the files themselves, I do not guarantee their complete correctness.
- Alessandro Raganato, Jose Camacho-Collados and Roberto Navigli.Word Sense Disambiguation: A Unified Evaluation Framework and Empirical Comparison. Proceedings of EACL 2017, Valencia, Spain.
- Word Sense Disambiguation (WSD) – UAIC
Passionate about computers, technology and information technology since I was a child. I have a master degree in Computer Science at the University of Bologna. Often I like to put my knowledge into practice by creating something new. Here I tell a bit about me.