Sentiment Analysis¶
To analyze the sentiment of some text, do an HTTP POST to https://text-processing.com/api/sentiment/ with form encoded data containg the text you want to analyze. You’ll get back a JSON object response with 2 attributes:
- label:
will be either
posif the text is determined to be positive,negif the text is negative, orneutralif the text is neitherposnorneg.- probability:
an object that contains the probability for each label.
negandposwill add up to 1, whileneutralis standalone. Ifneutralis greater than0.5then thelabelwill beneutral. Otherwise, thelabelwill beposorneg, whichever has the greater probability.
Here’s some examples using curl:
$ curl -d "text=great" http://text-processing.com/api/sentiment/
{
"probability": {
"neg": 0.39680315784838732,
"neutral": 0.28207586364297021,
"pos": 0.60319684215161262
},
"label": "pos"
}
$ curl -d "text=terrible" http://text-processing.com/api/sentiment/
{
"probability": {
"neg": 0.68846305481785608,
"neutral": 0.38637609994709854,
"pos": 0.31153694518214375
},
"label": "neg"
}
$ curl -d "text=hi friend" http://text-processing.com/api/sentiment/
{
"probability": {
"neg": 0.59797768649386562,
"neutral": 0.74939503025120124,
"pos": 0.40202231350613421
},
"label": "neutral"
}
Try the sentiment analysis demo to get a feel for the results.
Parameters¶
- text:
Required - the text you want to analyze. It must not exceed 80,000 characters.
Return Value¶
On success, a 200 OK response will be returned containing a JSON object that looks like this:
{
"label": "pos",
"probability": {
"pos": 0.85,
"neg": 0.15,
"neutral": 0.4
}
}
Errors¶
A 400 Bad Request response will be returned under the following conditions:
no value for
textis providedtextexceeds 80,000 characters
A 503 Throttled response will be returned if you exceed the daily request limit. Signup for the Text-Processing RapidAPI to get a higher limit plan.