Sentiment analysis

Sentiment analysis uses language processing and machine learning to judge whether a piece of text expresses a positive, negative or neutral opinion, and sometimes how strong that opinion is.

Sentiment analysis, also called opinion mining, turns text into a judgement about attitude. Google's machine learning glossary gives the example of analysing written feedback on a university course to see how far students liked or disliked it. The same idea is applied to product reviews, social media posts, customer support messages and news.

It can work at different levels. Document-level analysis gives one verdict for a whole review. Sentence-level analysis scores each sentence, often first sorting factual sentences from opinionated ones. Aspect-based analysis scores opinions about particular features, so a hotel review can be positive about location and negative about food. Some systems go beyond positive and negative to estimate star ratings or detect emotions such as anger or fear.

Methods have changed over time. Early approaches used word lists that scored terms as positive or negative and adjusted for words such as not and very. In 2002 Bo Pang, Lillian Lee and Shivakumar Vaithyanathan showed in Thumbs up? Sentiment Classification using Machine Learning Techniques that standard machine learning methods trained on movie reviews clearly beat human-produced baselines, though they did worse on sentiment than on sorting documents by topic. Later systems used deep learning, and today large language models can classify sentiment from a plain instruction with no task-specific training.

The hard cases are the ones people find hard too: sarcasm, jokes, negation, exaggeration and remarks whose meaning depends on context. Short posts give little to work with, and news writing often carries sentiment implicitly rather than stating it. Accuracy is usually measured against human judgements, and human raters do not always agree with each other, which limits how precise any score can be.

In practice, sentiment analysis is most useful in aggregate, for spotting a shift in how thousands of customers talk about a product. A dashboard showing that sentiment rose a few points says little unless you know how the tool handles sarcasm and mixed opinions, and checking a sample of its judgements by hand is the quickest test.

Common questions

What is sentiment analysis?

It is the automated process of identifying whether text expresses a positive, negative or neutral opinion. Businesses use it to track how customers feel about products, services and brands across reviews, surveys and social media.

How does sentiment analysis work?

Older systems use lists of words scored as positive or negative, adjusted for negations and intensifiers. Machine learning systems learn from examples of text labelled by sentiment. Modern language models can also judge sentiment directly when asked, without being trained specifically for the task.

Can sentiment analysis detect sarcasm?

Only partly. Sarcasm, irony and jokes say the opposite of what the words literally mean, which makes them among the hardest cases for any system. Larger language models handle context better than word-list methods, but errors on sarcasm remain common.

How accurate is sentiment analysis?

It varies with the text and the tool. Accuracy is measured by comparing a system's labels with human judgements, but people also disagree on many texts, so no system can be perfectly accurate. It tends to be more reliable on clear, longer texts such as reviews than on short or ambiguous posts.

Finding more

Search for "sentiment analysis", "aspect-based sentiment analysis" or "opinion mining" to explore methods and uses. Reliable sources include research papers in the ACL Anthology and on arXiv, machine learning guides from major providers and shared evaluations such as SemEval. Be cautious with vendor accuracy figures that do not say what kind of text they were measured on.

Working out what this means for your business?

Aileron Shift builds the systems behind this site: AI newsrooms that research, write and publish on their own, marketing automation and WordPress hosting for companies that need to move faster than their competitors.