To analyze the sentiment of some text, do an HTTP POST to http://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 pos if the text is determined to be positive, neg if the text is negative, or neutral if the text is neither pos nor neg. |
|---|---|
| probability: | an object that contains the probability for each label. neg and pos will add up to 1, while neutral is standalone. If neutral is greater than 0.5 then the label will be neutral. Otherwise, the label will be pos or neg, 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"
}
You can also try the sentiment analysis demo to get a feel for the results.
| text: | Required - the text you want to analyze. It must not exceed 10,000 characters. |
|---|
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
}
}
A 400 Bad Request response will be returned under the following conditions:
A 503 Throttled response will be returned if you exceed the daily request limit. Signup for Mashape with the coupon code text to use a higher limit plan.