Methods & evaluation

Sentiment Analysis: How Machines Read Opinion, and Where They Get It Wrong

Methods & evaluation · · Published 2026-11-23

Two seventeenth-century painted half-length figures side by side: on the left a long-haired man grinning and pointing at a globe, on the right an old bearded man bowed over his clasped hands, weeping
Democritus, the laughing philosopher, and Heraclitus, the weeping philosopher: two paintings by an unknown Spanish artist, c. 1630 (details). The Art Institute of Chicago, CC0.

A company wants to know whether its customers are angry; a researcher wants to track the mood of a million posts; a newsroom wants to see how a policy is received. Sentiment analysis promises the same thing to all of them: give it text, and it returns positive, negative or neutral, sometimes with a score. It is one of the most widely deployed tasks in natural language processing, and one of the easiest to misuse, because the output looks so much simpler than the problem.

What the task actually is

In its basic form, sentiment analysis is a text classification problem: one label per document or sentence, chosen from a short list. The Hugging Face documentation of the text classification task uses it as its first example, with a review going in and probabilities for POSITIVE, NEUTRAL and NEGATIVE coming out. Variants change the question rather than the method:

The unit of analysis matters. A long review can praise the acting and hate the ending; a single score for the whole document averages away exactly what a reader wanted to know.

Lexicons and rules: VADER and its relatives

The oldest approach needs no training data. A lexicon lists words with a polarity or a score (excellent +, awful −), and the system adds them up. Good lexicon systems add rules for the obvious traps: negation flips or dampens the score, intensifiers such as "very" boost it, and a "but" shifts weight to the second half of the sentence.

The best-known example is VADER, presented by C. J. Hutto and Eric Gilbert at the ICWSM conference in 2014. Its paper combines a human-validated lexicon tuned to social media with five general rules for punctuation, capitalisation, degree modifiers, "but" and negation. On their tweet test set, the authors report that VADER outperformed individual human raters, with a classification F1 of 0.96 against 0.84. The NLTK sentiment documentation shows how it reacts to an exclamation mark or to "very" in a sentence. Lexicon methods are fast, transparent and easy to audit; their weakness is everything a word list cannot see, from irony to domain-specific meanings.

Trained classifiers: learning from labelled reviews

The machine learning turn came with Bo Pang, Lillian Lee and Shivakumar Vaithyanathan's 2002 paper "Thumbs up?". Using movie reviews whose star ratings provided free labels, they found that standard classifiers (naive Bayes, maximum entropy, support vector machines) "definitively outperform human-produced baselines", meaning word lists chosen by people. They also found that sentiment was harder than sorting documents by topic, a finding that still holds.

Movie reviews became the field's laboratory. In 2011, Andrew Maas and colleagues released a dataset of 50,000 IMDB reviews, balanced between positive and negative, which remains a standard benchmark. Two years later, the Stanford Sentiment Treebank changed the granularity: Richard Socher and colleagues labelled 215,154 phrases in the parse trees of 11,855 sentences, so that a model could learn how sentiment composes from words to phrases. Their recursive neural model raised accuracy on single-sentence positive/negative classification from 80% to 85.4%, and handled negation and its scope better than bag-of-words baselines.

Today most systems start from a pretrained language model and are fine-tuned on labelled examples, or simply prompted with instructions. These models are much better at context, but they remain classifiers trained or evaluated on someone's labels, with everything that implies. Before the text even reaches the model, the way it is split into units also shapes what it can see: see our article on tokenization.

Aspect-based sentiment: opinions about what, exactly?

"The food was great but the service was slow" is neither positive nor negative. Aspect-based sentiment analysis (ABSA) asks which aspects are mentioned and what the writer thinks of each. The SemEval-2014 shared task on ABSA, run on annotated restaurant and laptop reviews, attracted 163 submissions from 32 teams and set the template: find the aspect terms, group them into categories such as FOOD, PRICE or SERVICE, and assign each a polarity. Finding the aspect is close to the entity-spotting problem described in our article on named entity recognition; the sentiment step then has to link each opinion word to the right target.

Social media and shared tasks

Tweets brought new problems: short texts, slang, hashtags, emoji, sarcasm. The SemEval "Sentiment Analysis in Twitter" task ran for five years; its 2017 edition covered overall sentiment, sentiment towards a topic on two- and five-point scales, and the harder problem of quantification, estimating the distribution of sentiment across many tweets, which is often what an analyst really needs. It added Arabic and drew 48 participating teams. Quantification deserves more attention than it gets: a classifier that is 80% accurate on individual posts can still produce a badly skewed estimate of the share of negative posts if its errors are not symmetric.

Where sentiment analysis fails

Before you trust a sentiment score

  1. Label a sample of your own text. A few hundred examples, labelled by two people, tell you more than any published benchmark, and the disagreement between your two annotators sets a realistic ceiling.
  2. Report per-class results. Accuracy on an imbalanced dataset flatters a model that predicts the majority class. Use macro-averaged F1 and look at the confusion matrix, as our guide to evaluating NLP models recommends.
  3. Check the neutral class. Many errors are positive or negative texts called neutral, or the reverse; decide whether that matters for your use.
  4. Test the hard cases on purpose. Write negations, contrasts, sarcasm and domain terms, and swap names and pronouns to probe for bias.
  5. Estimate shares, not just labels. If the question is "what proportion of comments are negative?", check the aggregate against your labelled sample, not only the per-item accuracy.
  6. Keep a human in the loop for decisions. A sentiment score is a summary statistic, not evidence about any one person or message.

Sources