liveBook · Manning

Sentiment score

As explained in Spring AI in Action

A sentiment score is a numerical measure representing the polarity and degree of sentiment expressed by text.

A sentiment score represents text polarity and intensity on a continuous scale from -1.0 (very negative) to +1.0 (very positive), with neutral sentiment between them. An explanation accompanies the score so applications can respond differently to positive and negative user messages. section 11.3

Build a sentiment endpoint by:

  • Defining a text input record and a response record containing the original text, score, and explanation. section 11.3

Interpreting context

“It’s the end of the world” receives -1.0, while adding “And I feel fine” changes the result to 0.5, showing how surrounding language affects polarity.

How Spring AI in Action covers it

How deep it goes
Builds a working endpoint with prompt, records, controller, and sample requests, but does not detail sentiment-model internals.
Examples
Tests bleak, contextually qualified, and exuberant statements that receive scores of -1.0, 0.5, and 0.8.
What it assumes
Starts with simple text input and record types while assuming familiarity with Spring controllers, dependency injection, and HTTP requests.
What you can do after
Builds a Spring endpoint that accepts text and returns its score, explanation, and echoed input.
How it connects
Connects sentiment scoring with LLMs, prompt templates, ChatClient, structured output, and HTTP POST endpoints.

Also explained in

Compare how 3 books explain sentiment score →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring AI in Action. The section links point to the parts of the book it draws on.