Sentiment Analysis

Zia Sentiment Analysis is a part of Text Analytics that processes textual content to recognize the tone of the message, and the sentiments conveyed through it. It analyses each sentence in the text to determine if its tone is positive, negative, or neutral. It then determines the tone of the overall text as one of the these three sentiments, based on the sentiments recognized in each sentence.

The response also returns the confidence scores for the sentiments detected in each sentence, to showcase the accuracy of the analysis. The confidence score lies in the range of 0 to 1. A confidence score for the overall analysis is also returned.

You can pass a block of text as the input of upto 1500 characters in a single request. The input text is passed to getSentimentAnalysis().

You can also pass optional keywords for the text. This will enable Sentiment Analysis to process only those sentences that contain these keywords, and determine their sentiments. Other sentences will be ignored.

The zia reference used below is defined in the component instance page.

Copiedzia.getSentimentAnalysis(['Zoho Corporation, is an Indian multinational technology company that makes web-based business tools. It is best known for Zoho Office Suite. The company was founded by Sridhar Vembu and Tony Thomas and has a presence in seven locations with its global headquarters in Chennai, India, and corporate headquarters in Pleasanton, California.'], ['Zoho']) //Pass the text and the optional keyword to process
	.then((result) => console.log(result))
	.catch((error) => console.log(error.toString()));

A sample response that you will receive is shown below. The response is the same for both versions of Node.js.

Node.js

Copied"sentiment_prediction": [
            {
                "document_sentiment": "Neutral",
                "sentence_analytics": [
                    {
                        "sentence": "Zoho Corporation, is an Indian multinational technology company that makes web-based business tools.",
                        "sentiment": "Neutral",
                        "confidence_scores": {
                            "negative": 0,
                            "neutral": 1,
                            "positive": 0
                        }
                    },
                    {
                        "sentence": "It is best known for Zoho Office Suite.",
                        "sentiment": "Neutral",
                        "confidence_scores": {
                            "negative": 0,
                            "neutral": 0.6,
                            "positive": 0.4
                        }
                    },
                    {
                        "sentence": "The company was founded by Sridhar Vembu and Tony Thomas and has a presence in seven locations with its global headquarters in Chennai, India, and corporate headquarters in Pleasanton, California.",
                        "sentiment": "Neutral",
                        "confidence_scores": {
                            "negative": 0,
                            "neutral": 0.88,
                            "positive": 0.12
                        }
                    }
                ],
                "overall_score": 0.83
            }
        ]