Analyse Sentiment
Note: The response format for this task has been modified to give a varied and more enhanced response. Refactor your scripts to suit the new response type before 7th June, 2024. An underscore(_) will be placed in your existing scripts to help you identify the places where this task has been currently used. For instance the underscore will be placed as below,
zoho.ai._analyseSentiment(<sentence>);
Table of Contents
Description
The zoho.ai.analyseSentiment task interprets the given piece of text to predict if it shows anger, disappointment, sarcasm, neutral, happy, or extremely happy emotion.
Note:
- This task only supports English.
- The prediction results may not be accurate, which is also the case with any AI prediction. However, we are working on improving this.
- The prediction results are dynamic. The same script may produce different outcomes at different times based on how much the machine has learned.
Syntax
<response> = zoho.ai.analyseSentiment(<sentence>);
where:
Params | Data type | Description |
---|---|---|
<response> | KEY-VALUE | Specifies the predicted sentiment in the given sentence |
<sentence> | TEXT | Specifies the piece of text whose sentiment needs to be interpreted |
Example
The following script interprets the sentiment of the given text - The session was intriguing.
response = zoho.ai.analyseSentiment("The session was intriguing.");
where:
response
"The session was intriguing."
Response Format
Success Response
The old success response for the above mentioned script will be returned in the following format.
{
"Prediction":"Neutral",
"Probability":{"Neutral":"80%","Negative":"10%","Positive":"10%"}}
},The new success response for the above mentioned script will be returned in the following format.
{
"data":[{"Text":"The session was intriguing.","Emotion":"Neutral"}]
},
Note: The other possible responses for this task will be
- Anger
- Disappointment
- Sarcasm
- Neutral
- Happy
- Extremely Happy
Failure Response
The failure response returned for an empty input text will remain the same and in the following format.
{
"Error Message ":"FAILED"
}
Limitations
- For sentiment analysis, you can enter only up to a maximum input of 30 words. If you have a longer text, we recommend finding sentiment for each sentence and averaging out the sentiment.