Sentiment Analysis
Sentiment Analysis allows to predict the sentimental values of the given input, this
is great for determining the sentiment of user feedback, comments and or posts. This
method will allow you perform sentiment analysis by sentences and generalize the
results to get an overall prediction over a set of data to accurately predict the
overall prediction.
The input of your data is limited by your subscription and a larger input can take
longer to process
Example Success Response (Without sentence_split
)
{
"success": true,
"response_code": 200,
"results": {
"text": "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system. expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.",
"source_language": "en",
"sentiment": {
"sentiment": "POSITIVE",
"prediction": 49.942695470064,
"predictions": {
"VERY_NEGATIVE": 1.5705988835225,
"NEGATIVE": 6.420271901908,
"NEUTRAL": 12.353139466572499,
"POSITIVE": 49.942695470064,
"VERY_POSITIVE": 29.713294277933
}
},
"generalization": null
}
}
Example Success Response (With sentence_split
)
{
"success": true,
"response_code": 200,
"results": {
"text": "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system. expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.",
"source_language": "en",
"sentiment": {
"sentiment": "POSITIVE",
"prediction": 49.942695470064,
"predictions": {
"VERY_NEGATIVE": 1.5705988835225,
"NEGATIVE": 6.420271901908,
"NEUTRAL": 12.353139466572499,
"POSITIVE": 49.942695470064,
"VERY_POSITIVE": 29.713294277933
}
},
"sentences": [
{
"text": "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system.",
"offset_begin": 0,
"offset_end": 156,
"sentiment": {
"sentiment": "POSITIVE",
"prediction": 49.932369161977,
"predictions": {
"VERY_NEGATIVE": 1.784712197492,
"NEGATIVE": 7.190886877895,
"NEUTRAL": 12.420306833186,
"POSITIVE": 49.932369161977,
"VERY_POSITIVE": 28.671724929449997
}
}
},
{
"text": "expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.",
"offset_begin": 157,
"offset_end": 260,
"sentiment": {
"sentiment": "POSITIVE",
"prediction": 49.953021778151005,
"predictions": {
"VERY_NEGATIVE": 1.356485569553,
"NEGATIVE": 5.649656925921,
"NEUTRAL": 12.285972099959,
"POSITIVE": 49.953021778151005,
"VERY_POSITIVE": 30.754863626416
}
}
}
],
"generalization": null
}
}
Example Success Response (With generalization
)
{
"success": true,
"response_code": 200,
"results": {
"text": "But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system. expound the actual teachings of the great explorer of the truth, the master-builder of human happiness.",
"source_language": "en",
"sentiment": {
"sentiment": "POSITIVE",
"prediction": 49.942695470064,
"predictions": {
"VERY_NEGATIVE": 1.5705988835225,
"NEGATIVE": 6.420271901908,
"NEUTRAL": 12.353139466572499,
"POSITIVE": 49.942695470064,
"VERY_POSITIVE": 29.713294277933
}
},
"generalization": {
"id": "895af6da6227b73ae89a2728b6698324c3753ba6f9a4d033835608d3d1f3729b",
"size": 20,
"top_label": "POSITIVE",
"top_probability": 49.942695470064,
"probabilities": [
{
"label": "POSITIVE",
"calculated_probability": 49.942695470064,
"current_pointer": 0,
"probabilities": [
49.942695470064
]
},
{
"label": "VERY_POSITIVE",
"calculated_probability": 29.713294277933,
"current_pointer": 0,
"probabilities": [
29.713294277933
]
},
{
"label": "NEUTRAL",
"calculated_probability": 12.353139466572499,
"current_pointer": 0,
"probabilities": [
12.353139466572499
]
},
{
"label": "NEGATIVE",
"calculated_probability": 6.420271901908,
"current_pointer": 0,
"probabilities": [
6.420271901908
]
},
{
"label": "VERY_NEGATIVE",
"calculated_probability": 1.5705988835225,
"current_pointer": 0,
"probabilities": [
1.5705988835225
]
}
]
}
}
}
Response Structure
Name | Type | Description |
text | string | The text of the input, or the translation results if the input is from another language |
source_language | string | The original language source |
sentiment | SentimentPrediction | SentimentPrediction object that represents the sentimental prediction values |
sentences | SentimentPredictionSentence[] | Array of sentence splits containing SentimentPrediction values, this will be returned if you use sentence_split |
generalization | Generalization|null | The generalization results if generalization is used |
SentimentPrediction Object Structure
Name | Type | Description |
sentiment | string | The highest sentimental value, can be VERY_NEGATIVE, NEGATIVE, NEUTRAL, POSITIVE or VERY_POSITIVE |
prediction | float | The prediction value of the sentimental value |
predictions | array | String:Float combination of all the predictions, includes VERY_NEGATIVE, NEGATIVE, NEUTRAL, POSITIVE and VERY_POSITIVE as key values |
SentimentPredictionSentence Object Structure
Name | Type | Description |
text | string | The text of the sentence |
offset_begin | int | The character offset begin of the sentence |
offset_end | int | The character offset end of the sentence |
sentiment | SentimentPrediction | SentimentPrediction object that represents the sentimental prediction values for this sentence |
Generalization Labels
This method supports generalization and will use the following labels for generalization,
for more information on how generalization works see
Generalization - Introduction
Label |
VERY_NEGATIVE |
NEGATIVE |
NEUTRAL |
POSITIVE |
VERY_POSITIVE |
Invalid Language Code Response
This response is given when the parameter
language
contains
an invalid value.
{
"success": false,
"response_code": 400,
"error": {
"error_code": 7,
"type": "CLIENT",
"message": "The given language 'not a real language' cannot be identified"
}
}
Invalid Language Code Response
This response is given when the parameter
language
contains
an invalid value.
{
"success": false,
"response_code": 400,
"error": {
"error_code": 7,
"type": "CLIENT",
"message": "The given language 'not a real language' cannot be identified"
}
}
Unsupported Language Response
This response is given when the requested language is unsupported by the method
{
"success": false,
"response_code": 400,
"error": {
"error_code": 23,
"type": "CLIENT",
"message": "The given language 'nr' is not supported"
}
}