Sentiment analysis

What is sentiment analysis?

Sentiment analysis reads a piece of text and puts a label on the attitude behind it: positive, negative or neutral. It is a form of text classification, the general job of sorting text into buckets you defined yourself, and it lives under natural language processing. What gives it its own name is that the bucket is about how the writer feels, not about what the message is about. The raw material is unstructured data you already store and never query: the free-text field on a ticket, a review on the webshop, the note a salesperson typed after a visit.

Most services hand you those three labels with a confidence score. Microsoft's Azure AI Language scores every sentence and the document as a whole, and adds a fourth document label, mixed, when a text holds at least one positive and at least one negative sentence. Amazon Comprehend returns the same four values. Google's Natural Language API instead gives a score from -1 to 1 for the direction plus a separate magnitude for how much feeling is in the text at all, so a bland message and a message that is half praise and half complaint both land near zero and only the magnitude tells them apart.

That last detail is the whole problem in miniature. One number for one message throws away the part you wanted.

Overall sentiment versus aspect-based sentiment

Take one sentence: "The delivery was three days late but the bottle itself is great." Overall sentiment calls that mixed, or negative, or a score near zero. Whichever answer comes back, there is nothing to do with it.

Aspect-based sentiment scores the parts separately. Microsoft calls the feature opinion mining and returns a target, a noun or a verb, paired with an assessment, an adjective: delivery is late, bottle is great. Snowflake's AI_SENTIMENT takes up to ten categories of your own and gives back positive, negative, neutral, mixed or unknown for each.

The dimension that separates the two is what you can act on. Overall sentiment tells you which thing to look at. Aspect-based sentiment tells you what to change.

A review corpus, scored per aspect

A webshop has 4,000 reviews across 60 products. Ranked on average rating, the bottom of the list holds the products everyone in the company could already name.

Score each review instead on five aspects you picked: quality, delivery, packaging, price, and the instructions in the box. One product comes out with quality positive in nine reviews out of ten and packaging negative in four out of ten. Its average sits at 3.9, which is why nobody looked at it. It has a box problem, not a product problem, and that is one conversation with whoever packs it. Choosing the aspects is the real work, so choose them from what you could change next month.

Intent and urgency are usually the more useful score

Mood is rarely the thing a company acts on. In a shared inbox the question is which message gets answered first, and a customer writing "we still have not received the parts, the line stops on Thursday" is calm and expensive.

Nothing forces you to use positive and negative as your labels. The machinery is the same and the list is yours: urgency (can wait, this week, today), intent (question, complaint, cancellation, quote request), whether the writer has already asked once.

A support inbox, routed by urgency

Sixty messages a day land in one shared mailbox, and someone reads them all each morning and forwards them one by one, so two hours pass before any of them is answered.

Score each message on arrival for intent, urgency, and whether the thread already runs longer than three messages. Cancellations and quote requests go straight to sales, anything urgent goes to the top of the queue, and the rest is grouped by topic so one person answers eight similar questions in a row. The gain is not the label. It is that whoever spent the morning sorting now spends it answering, with the original message next to the label because the human still decides.

Plot the same per-message score across one thread in order and you also catch a contract negotiation that has turned, which nobody spots by reading six weeks of email back.

How it is done today

A lexicon is a word list with a value per word, added up per message. It runs on a laptop, costs nothing per row, and you can point at the words that made the score. It is also the weakest: a group at Leipzig University compared dictionary methods, fine-tuned models and language models on German text in 2025 and found the dictionary methods behind on every dataset.

A trained classifier means labelling a few thousand of your own messages and fine-tuning on them. It gives the best scores once the labels exist and it is cheap per row, but the labelling bill comes back every time your range or your customer base moves.

A language model with a prompt needs no training data, because you write the labels and the rules out in words. The same Leipzig comparison had an open-weight model with a plain zero-shot prompt reaching around 97 percent of the best score across their datasets. On the harder aspect-based task it is less flattering: a 2025 study of nine models on multilingual aspect-based sentiment found zero-shot prompting still behind models fine-tuned for that job, and found that simple prompts beat elaborate ones.

The prompt route wins on a different argument than accuracy. The rules that decide whether a score is right are yours, and each one is a sentence: treat the word claim as neutral, because that is what our customers call a file. You cannot tell a lexicon that, and you cannot tell a trained classifier that without relabelling.

Cost stopped being the tiebreaker. Fifty thousand messages a year at roughly 700 characters each runs to about 35 dollars on Amazon Comprehend, which bills in units of 100 characters at 0.0001 dollar per unit, and to about 17 dollars on a small language model such as Claude Haiku 4.5 at 1 dollar per million input tokens, once you count the 120 or so tokens of labels that travel with every row. Both are smaller than one afternoon of somebody's time, so pick on what you are allowed to ask, not on the price per row.

Measuring whether it works on your own text

Take 300 of your own messages, spread across a full year rather than picked from last week. Have two of your own people label them independently from the same written instruction, and compare those two people to each other before you compare anything to a model.

That agreement is your ceiling, because a model cannot be more right than the judgement you are asking it to copy. The group at the Jožef Stefan Institute in Ljubljana that hand-labelled 1.6 million tweets across 13 European languages made exactly this the point of their work, and their measured agreement ran from decent in some languages down to very poor in others.

The disagreement clusters on short messages with no context, where a flatly stated fact could be a complaint or could be information. When your two readers split on one, the written instruction does not cover that case yet. Add the rule and have both redo that subset.

Only then run the model over the same 300 and count the matches. Decide beforehand how good is good enough, per use: 85 percent is fine for a share-of-negative line on a chart and nowhere near enough for a label that decides whether a customer gets called back today. Keep the 300 and rerun them whenever you change the prompt, the labels or the model.

Sentiment analysis is not emotion recognition

Article 5 of the EU AI Act bans AI systems that infer emotions of a person in the workplace and in education institutions, with a narrow exception for medical or safety reasons. Article 3 ties that ban to biometric data: an emotion recognition system is one that infers emotions or intentions from a person's biometric data, which the same article defines as data from technical processing of physical, physiological or behavioural characteristics, facial images among them.

Scoring the wording of written text is therefore not emotion recognition, because no biometric data goes in. A tool that reads a customer email and labels it angry sits outside that ban.

A tool that reads a face on a webcam or a voice on a call and infers a mood sits inside it the moment the person is your employee or your student. Pointing a tone-scoring product at your own agents to check how they come across is the case the ban was written for, and no consent form or supplier certificate changes that. The same product aimed at the caller is a different question, which our entry on prohibited AI practices works through along with the rest of Article 5.

Call-quality tools usually process both sides of a recording, so ask in writing whose voice is analysed and whether the employee side can be switched off. A sentiment score kept against a named employee is also personal data under the GDPR, and you have to be able to explain it.

What to watch out for with sentiment analysis

  • Irony gets scored backwards. "Great, another delivery on a Saturday" reads as positive to almost every method. If your channel is full of it, do not put a number built on it in front of management.

  • Flemish understatement reads as neutral. "Het is niet ideaal" is a serious complaint and "niet slecht" is a compliment. A model that learned mostly from English internet text flattens both, so put ten real messages from your own inbox in the prompt with the label you would give them.

  • Some words only look negative in your industry. In an insurance inbox, claim, damage and accident are the subject of nearly every message. In a maintenance inbox, broken is neutral. Name those words in the prompt and measure whether it moved the score.

  • Belgian inboxes are multilingual. Dutch, French and English land in the same queue and sometimes in one message, so check your sample per language. A score that works in Dutch can quietly fall apart in French.

Report the share of negative messages per week rather than the average score. An average over thousands of messages barely moves, so a real shift after you changed something in the process stays invisible in it.

Last Updated: September 4, 2026 Back to Dictionary
Keywords
sentiment analysis aspect-based sentiment natural language processing nlp unstructured data text classification large language model emotion recognition prohibited ai practices ai act bias customer feedback