Aspect Based Sentiments Analysis

A Specrom News API endpoint for extracting entities from the input text and predicting the sentiments towards each entities.

Extract topics (also known as aspects or entities) from the input text and predict the sentiment towards each of the topics.

If you are instead looking for document level sentiment score and label, you should look at our API endpoint that does that instead.

Input

import requests

url = "https://specrom-news-api.p.rapidapi.com/"

payload = {
  "api_type": "aspect_based_sentiments_analysis",
  "input_text": "This is a very solid device. Wonderful job, Apple!  The only thing unexpected about it was the weight... the dimensions are smaller than the old macbook air my wife had, but heavier.  Screen size is the same"
}

headers = {
  "content-type": "application/json",
  "X-RapidAPI-Key": API_Key,
  "X-RapidAPI-Host": "specrom-news-api.p.rapidapi.com"
}

response = requests.request("POST", url, json=payload, headers=headers)

print(response.text)
	
	POST / HTTP/1.1
Content-Type: application/json
X-Rapidapi-Key: API_Key
X-Rapidapi-Host: specrom-news-api.p.rapidapi.com
Host: specrom-news-api.p.rapidapi.com
Content-Length: 151

{
    "api_type": "aspect_based_sentiments_analysis",
    "input_text": "This is a very solid device. Wonderful job, Apple!  The only thing unexpected about it was the weight... the dimensions are smaller than the old macbook air my wife had, but heavier.  Screen size is the same"
}
	
	
Parameter Description
api_type aspect_based_sentiments_analysis
input_text input text

Output


{
  "Response": [
    {
      "Aspect": "Device",
      "Sentiment": "Positive"
    },
    {
      "Aspect": "Weight",
      "Sentiment": "Negative"
    },
    {
      "Aspect": "Dimensions",
      "Sentiment": "Positive"
    },
    {
      "Aspect": "Screen Size",
      "Sentiment": "Positive"
    }
  ]
}
Parameter Description
Aspect The extracted entities or aspects from the input text. Generally speaking, this will be some attribute, person, company, product, service etc.
Sentiment A label of Positive, Negative or Neutral.