Imagine a reader able to scan millions of customer reviews in a second and tell, for each one, whether it breathes satisfaction or anger. That is exactly the job of sentiment analysis (also called opinion mining): a branch of Natural Language Processing (NLP) that detects the emotional polarity of a text — positive, negative, or neutral.
How it works
Historically, the approach relied on lexicons: dictionaries assigning each word an affective score ("excellent" = +2, "disappointing" = -2). The sentence score was then a simple sum.
Today, models rely on machine learning, and especially on transformers (such as BERT) that grasp context. The text is turned into vectors, then a classifier estimates the probability of each class. For a binary problem, the sigmoid function gives the probability:
$$P(\text{positive} \mid x) = \frac{1}{1 + e^{-z}}$$
where $z$ is the score produced by the model.
The real challenges
| Difficulty | Example |
|---|---|
| Irony / sarcasm | "Great, another crash." |
| Negation | "It's not bad." |
| Multiple aspects | "Good screen, bad battery." |
This last case gave rise to Aspect-Based Sentiment Analysis (ABSA), which assigns a sentiment to each mentioned entity rather than to the whole text.
Applications
- Monitoring a brand's reputation on social media
- Prioritizing customer support tickets
- Analyzing financial markets from news flow
Understanding the what of a text is useful; understanding the feeling it carries means grasping the human intent behind the words.