How to get overall sentiment score using Text Analytics API?

Shimmur 1 Reputation point
2021-03-07T17:01:13.6+00:00

I'm making a post request to the Text Analytics API to run sentiment analysis on a sample text and am successfully getting back the following response. Going by this response, I don't see a means to grab a single overall score for the document - just the individual positive, negative, or neutral scores. How do I get the overall score as I've seen in sample docs online?
Do I need to use the client library instead? Appreciate any help.
{
"documents":
[
{"id":"1",
"sentiment":"negative",
"confidenceScores”: {“positive":0.0,"neutral":0.0,"negative":1.0},
"sentences”: [
{“sentiment":"negative",
"confidenceScores":
{"positive":0.0,"neutral":0.0,"negative":1.0},
"offset":0,
"length":27,
"text": "['it is noisy outside']"
}
],
"warnings":[]}],
"errors":[],
"modelVersion":"2020-04-01"}

Azure AI Language
Azure AI Language
An Azure service that provides natural language capabilities including sentiment analysis, entity extraction, and automated question answering.
359 questions
Azure AI services
Azure AI services
A group of Azure services, SDKs, and APIs designed to make apps more intelligent, engaging, and discoverable.
2,402 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. romungi-MSFT 42,286 Reputation points Microsoft Employee
    2021-03-08T14:32:30.317+00:00

    @Shimmur Could you post the request body and the API used in your request? I have tried the sentiment API and it provides the response with the expected results. For example:

    API: https://<myresource>.cognitiveservices.azure.com/text/analytics/v2.1/sentiment  
    

    Body:

    {  
      "documents": [  
        {  
          "id": "1",  
          "text": "If this demo doesn't work I will be super sad",  
          "language": "en"  
        },  
        {  
          "id": "2",  
          "text": "Español es muy difícil de aprender",  
          "language": "es"  
        },  
        {  
          "id": "3",  
          "text": "I really really love machine learning",  
          "language": "en"  
        },  
        {  
          "id": "4",  
          "text": "Le soleil se lève à l'Est",  
          "language": "fr"  
        }  
      ]  
    }  
    

    Response:

    {"documents":[{"id":"1","score":0.0073043704032897949},{"id":"3","score":0.94009941816329956},{"id":"2","score":0.44219660758972168},{"id":"4","score":0.53425812721252441}],"errors":[]}