AnalyzeSentiment Processor
Part of the GCP Natural Language processor family
This processor takes in an input string and returns information about the sentiment of the text. Sentiment can be thought of as the connotation of the message. This processor will analyze the sentiment of individual sentences as well as the text overall.
The resulting Sentiments are reported with two values: score and magnitude. Per the official documentation:
scoreranges from -1.0 (negative sentiment) to 1.0 (positive sentiment)magnitudeindicates the overall strength of the emotion (both positive and negative)
This means that, for example, a sentence with a sentiment that has a score of 0.8 and a magnitude of 1.7 means it's a very strongly positive message. Similarly, a sentiment with a score of -0.2 with a magnitude of 0.2 is likely a "lightly" negative message.
The example output is a great example of the strength / sentiment. The message is overall a very positive message, and the output reflects as such.
Properties
This processor does not have any unique properties outside of the common ones.
Data Output
Field Name
Data Type
Description
sentences
array of Sentence
The list of all sentences in the message
language
string
The language code of the language the message is in.
overallSentiment
Sentiment
The sentiment of the message as a whole
Sentence
SentenceField Name
Data Type
Description
text
string
The raw string of the sentence
sentiment
Sentiment
The sentiment of this sentence
beginOffset
int
The number of characters from the beginning of the input string to the start of this sentence
Sentiment
SentimentField Name
Data Type
Description
score
float
A number ranging from -1.0 (negative sentiment) to 1.0 (positive sentiment)
magnitude
float
A number ranging from 0 to +inf representing the absolute magnitude of the sentiment (regardless of score). This number can be thought of as the strength of the emotion (e.g., something being very positive, or slightly negative)
{
"output":{
"overallSentiment":{
"score":0.5,
"magnitude":1.7
},
"sentences":[
{
"sentiment":{
"score":0.6,
"magnitude":0.6
},
"text":"James Adams is a fantastic developer who has been on the scene for over ten years."
},
{
"sentiment":{
"score":0.9,
"magnitude":0.9
},
"text":"His excellent attitude and steady work ethic contribute to his character."
},
{
"sentiment":{
"score":0.2,
"magnitude":0.2
},
"text":"May he stay with our company for many years to come."
}
],
"language":"en"
},
"raw-input":"James Adams is a fantastic developer who has been on the scene for over ten years. His excellent attitude and steady work ethic contribute to his character. May he stay with our company for many years to come."
}Last updated
Was this helpful?