Three Word-Sense Disambiguation Algorithms
Questo articolo รจ disponibile in italiano
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;
and they are tested on this corpus appropriately pre-processed the code available in corpus_preprocessing.py.
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
Lesk Algorithm
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
EM Algorithm
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
Notes
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.
References
- 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
Hi ๐, I'm Lorenzo ๐จ๐ปโ๐ป
๐ผ Software developer
๐ Master's degree in computer science
๐ค Artificial intelligence
๐ง Machine learning
๐ Data Analysis
๐ Web development
๐ฑ Android development
๐ช Astronomy
๐ฏ๐ต Japanese culture
๐ฅ Martial arts
๐ฎ Videogames
๐ธ Photography