Sentiment Analysis (Basic Edition)

  • Example request
    //You are advised to construct and use the client in a singleton pattern to avoid frequent object creation.
    NluClient client = new NluClient (AuthMode.AKSK,authInfo);
    
    GeneralSentimentReq req = new GeneralSentimentReq();
    req.setContent("Text for analysis");
    
    try {
        GeneralSentimentResp resp = client.getSentiment(req);
    } catch (NlpException e) {
        //A failure is thrown as an exception. For details about exceptions, see section "Exceptions". The client automatically processes exceptions.
    }
    
  • Table 1 describes GeneralSentimentReq parameters.
    Table 1 GeneralSentimentReq parameters

    Parameter

    Mandatory

    Type

    Description

    content

    Yes

    String

    Text to be analyzed. The text must be encoded using UTF-8.

    The value contains a maximum of 400 characters. If the value exceeds 400 characters, only the first 400 characters are detected.

  • Table 2 describes GeneralSentimentResp parameters.
    Table 2 GeneralSentimentResp parameters

    Parameter

    Type

    Description

    result

    Result

    Encapsulated object of the returned result

  • Table 3 describes the data structure description of the Result field.
    Table 3 Data structure description of the Result field

    Parameter

    Type

    Description

    content

    String

    Text to be analyzed.

    label

    Integer

    Positive and negative labels are included.

    • 1: positive
    • 0: negative

    confidence

    Float

    Confidence level of a label