Skip to main content

Babel Street Analytics API

Sentiment Analyzer

https://analytics.babelstreet.com/rest/v1/sentiment

https://raw.githubusercontent.com/rosette-api/curl-examples/develop/examples/sentiment.curl

Sentiment analyzer returns a sentiment label (subjective attitude) of the input text as positive (pos), negative (neg), or neutral (neu), with a confidence score between 0 and 1. The sum of the confidence scores for the three sentiment labels for a given document is always equal to one, though only the highest one is returned.

When Sentiment detects entities within your input, it also returns the sentiment for each unique entity in the document. It groups all the relevant sentiment about that entity into one mention, identified by its entityID.

Before analyzing, Sentiment filters out some stop words and punctuation, such as “the” “?” “a” “it”, to increase the accuracy of the assessment.

When working with English text, there is also an option to use an alternative, deep neural network sentiment model. To use this model, set the modelType option to DNN. The DNN model may return different scores than the standard model.

Query Parameters

Name

Value

Description

output

rosette

Returns the response in ADM format.

Note

All input parameters, including the text being analyzed and any relevant options, are defined in the request body.

Request

Option

Type

Description

Required

Value

modelType

string

Use the deep neural sentiment model. This is valid for English only.

no

DNN

{
  "content": "string",
  "language": "string",
  "options": {  
    "modelType": "string"
  }
}

Response

For the document, and each identified entity, only the highest scoring sentiment is returned, along with a confidence value between 0 and 1. For each entity, detail about the entity is also returned.

{
  "document": {
    "label": "string", 
    "confidence": number
  },
  "entities": [
  {
   "type": "string",
   "mention": "string",
   "normalized": "string",
   "count": 0,
   "mentionOffsets": [
    {
      "startOffset": number,
      "endOffset": number
    }
   ],
   "entityId": "string",
   "confidence": 0,
   "linkingConfidence": 0,   
   "sentiment": {
     "label": "string",
     "confidence": number
   }
 ]
}

Supported languages

GET /sentiment/supported-languages

Returns the list of supported languages and scripts for the endpoint, along with whether you have a license for the language.

Response

Field

Type

Description

language

string

ISO 639 language code

script

string

Four-letter ISO-15924 script code

licensed

boolean

Indicates if you are licensed for this language

{
  "supportedLanguages": [
    {
      "language": "string",
      "script": "string",
      "licensed": boolean
    }
  ]
}

When processing English text in which case should be ignored, use the language code uen.