Analyze emotions
    • PDF

    Analyze emotions

    • PDF

    Article Summary

    Emotion analysis API

    It is a REST API based on HTTP, which analyzes text data and returns the results as a service that analyzes the emotions within the content of the text, sentence, phrase.

    Requests

    POST https://naveropenapi.apigw.ntruss.com/sentiment-analysis/v1/analyze
    

    Request headers

    Header nameDescription
    X-NCP-APIGW-API-KEY-IDClient ID issued when registering the app
    X-NCP-APIGW-API-KEY-ID:{Client ID}
    X-NCP-APIGW-API-KEYClient secret issued when registering the app
    X-NCP-APIGW-API-KEY:{Client Secret}
    Content-TypeBinary transfer method
    Content-Type: application/json

    Request body

    Field nameRequirement statusTypeDescription
    contentYesStringEmotion analysis text
    config.negativeClassificationNoBooleanNegative statement analysis option

    Responses

    Response bodies

    Field nameData typeDescription
    documentObjectObject for all sentences
    document.sentimentStringEmotion for all sentences
    document.confidenceObjectEmotion confidence for all sentences
    document.confidence.neutralFloatNeutral confidence (%)
    document.confidence.positiveFloatPositive confidence (%)
    document.confidence.negativeFloatNegative confidence (%)
    sentencesList of ObjectList object related to categorized sentences
    sentences.contentStringCategorized sentences
    sentences.offsetIntSentence start point in document.content
    sentences.lengthIntCharacter count for categorized sentences
    sentences.sentimentStringEmotion for categorized sentences
    sentences.confidenceObjectEmotion confidence for the categorized sentence
    sentences.confidence.neutralFloatNeutral confidence (%)
    sentences.confidence.positiveFloatPositive confidence (%)
    sentences.confidence.negativeFloatNegative confidence (%)
    sentences.highlightsList of ObjectEmotion analysis section in sentences.content
    sentences.highlights.offsetIntStart point of major emotion section
    sentences.highlights.lengthIntCharacter count for major emotion section
    sentences.negativeSentiment.sentimentStringIf negative emotion, detailed emotions
    sentences.negativeSentiment.confidenceFloatIf negative emotion, confidence of detailed emotions

    Examples

    Request examples

    {
      "content": "It's chilling. A dagger flies into my heart and pierces it."
    }
    

    Response examples

    {
        "document": {
            "sentiment": "negative",
            "confidence": {
                "neutral": 0.14525136640572725,
                "positive": 0.00186876227013191,
                "negative": 0.8528798713241407
            }
        },
        "sentences": [
            {
                "content": "It's chilling.",
                "offset": 0,
                "length": 5,
                "sentiment": "negative",
                "confidence": {
                    "negative": 0.9961358904838562,
                    "positive": 0.0036366574931889772,
                    "neutral": 0.0002274021098855883
                },
                "highlights": [
                    {
                        "offset": 0,
                        "length": 4
                    }
                ]
            },
            {
                "content": "A dagger flies into my heart and pierces it.",
                "offset": 5,
                "length": 17,
                "sentiment": "negative",
                "confidence": {
                    "negative": 0.927976131439209,
                    "positive": 0.07131962478160858,
                    "neutral": 0.0007042606011964381
                },
                "highlights": [
                    {
                        "offset": 1,
                        "length": 15
                    }
                ]
            }
        ]
    }
    
    

    Error

    Error examples

    {
      "status": 400,
      "error": {
        "errorCode": "E001",
        "message": "Unsupported empty or blank text"
      }
    }
    

    Errors

    HttpStatusCodeErrorCodeErrorMessageDescription
    400E001Unsupported empty or blank textEmpty string or blank character
    400E002Utf-8 encoding errorUTF-8 encoding error
    400E003Text quota ExceededSentences over the standard value
    400E103Invalid request bodyInvalid request body’s json format or omitting required parameters
    400E415Unsupported media typeContent-type error
    400E900Unexpected errorCase without exception handling (Bad Request)
    500E501Endpoint connection failedEndpoint connection failed
    500E900Unexpected errorError without exception handling (Server Error)

    Was this article helpful?

    Changing your password will log you out immediately. Use the new password to log back in.
    First name must have atleast 2 characters. Numbers and special characters are not allowed.
    Last name must have atleast 1 characters. Numbers and special characters are not allowed.
    Enter a valid email
    Enter a valid password
    Your profile has been successfully updated.