'Merging Azure Cognitive Services sentiment results

I am using Azure Cognitive Services in order to calculate the sentiment of 58 documents. All of those have way more than 5000 characters, meaning that the character limit is always exceeded. I have thought that I could make more requests for each document, by dividing each document into more pieces and than merging the responses, but this is where I am stuck. The response contains overall document sentiment class (positive, neutral and negative), percentages of the three classes and the same information for each sentence. Do the sentences results generate the final one? In other words, could I get three percentage values for the three classes from two different api calls?

This is an example:

INPUT DOCUMENT: This API seems great. How the hell is overall score calculated? I wonder if anyone knows. I'll cry until someone answers.

RESPONSE:
    Document Sentiment: mixed
    Overall scores: positive=0.50; neutral=0.02; negative=0.47 

    Sentence: This API seems great. 
    Sentence 1 sentiment: positive
    Sentence score:
    Positive=1.00
    Neutral=0.00
    Negative=0.00

    Sentence: How the hell is overall score calculated? 
    Sentence 2 sentiment: negative
    Sentence score:
    Positive=0.01
    Neutral=0.05
    Negative=0.95

    Sentence: I wonder if anyone knows. 
    Sentence 3 sentiment: neutral
    Sentence score:
    Positive=0.04
    Neutral=0.92
    Negative=0.04

    Sentence: I'll cry until someone answers.
    Sentence 4 sentiment: neutral
    Sentence score:
    Positive=0.03
    Neutral=0.52
    Negative=0.46

Main question: Is there any way to calculate the overall sentiment from only the sentences ones? Also, is the way Azure calculates this score known? If you know the sentences results can not bring to the final one, could you suggest me any way to do what I want to achieve? Thank you very much in advance.



Solution 1:[1]

To be frank the procedure which is being requested is not that much acceptable. But there is a way to do that with programmatic approach.

1. Creating dictionary

Take individual responses in a dictionary variable.

{
         
document: 1,
         
positive: value,
         
negative: value,
         
neutral: value
    
}

2. Append the values into the list

Append the values u got into the list

3. Create a dataframe with those values

Dataframe can help to manage the column wise data pattern.

4. Mean each column

Get the mean of each column.

This will work

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 SairamTadepalli-MT