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*** f_{i}** of a

*word*all the other

**w**_{i}*words*that appear in the same sentence; with

**w**_{j}*.*

**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

*are the individual contexts that make up the corpus, i.e. the sentences.*

**c**_{i}At the beginning the parameters * P(s_{k})* and

*are initialized randomly. As the name suggests, the iterative algorithm is composed of the phases:*

**P(f**_{j}|s_{k})**E-step**: esitimate the posterior probability that the sensegenerates the context**s**_{k}.*c*_{i}

**M-step**: recalculation of the parametersand**P(s**_{k}).**P(f**_{j}|s_{k})

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