SentimentAnalyser - Scoped

  • 릴리스 버전: Australia
  • 업데이트 날짜 2026년 03월 12일
  • 소요 시간: 9분
  • The SentimentAnalyser script include provides methods to perform sentiment analysis on a string value.

    You should use this script include in a script that is treated as an admin-executing script. For example, use the Sentiment Analysis script includein a script action or scheduled job.

    To use this class in a scoped application, use the sn_nlp_sentiment namespace identifier. The Sentiment Analysis plugin (com.snc.sentiment_analysis) must be enabled to access the SentimentAnalyser API.

    SentimentAnalyser - SentimentAnalyser()

    Creates an instance of the SentimentAnalyser class with the default connector configuration that is used for sentiment analysis.

    var sa = new sn_nlp_sentiment.SentimentAnalyser();

    SentimentAnalyser - SentimentAnalyser(GlideRecord configGR)

    Creates an instance of the SentimentAnalyser class with the specified connector configuration that is used for sentiment analysis.

    표 1. Parameters
    Name Type Description
    configGR GlideRecord GlideRecord object of a connector configuration.
    var sa = new sn_nlp_sentiment.SentimentAnalyser(configGR);

    SentimentAnalyser - analyze(String inputText)

    Performs sentiment analysis on the specified text.

    표 2. Parameters
    Name Type Description
    inputText String Text on which sentiment analysis should be performed.
    표 3. Returns
    Type Description
    JSON object Result of the sentiment analysis specifying the status, score, normalised score, sys_id of the relevant connector configuration, and error message.
    
            var sa = new sn_nlp_sentiment.SentimentAnalyser();
            var result = sa.analyze ("Example string");

    Output:

    {"status": "Success", "score": "0.7", "normalizedScore": "0.7", "connectorConfig": "10932aa773101300734e234ffff6a777", "errorMessage":""}

    SentimentAnalyser - analyzeMultiple(Array inputTextArray)

    Performs sentiment analysis on an array of strings.

    표 4. Parameters
    Name Type Description
    inputTextArray Array Array of text (string) on which to perform sentiment analysis.
    표 5. Returns
    Type Description
    JSON Array An array that gives the result of the sentiment analysis performed on multiple texts specifying the status, score, normalized score, sys_id of the relevant connector configuration, and error message.
    var sa = new sn_nlp_sentiment.SentimentAnalyser();
    var result = sa.analyzeMultiple (["Example string1","Example string2"]);

    Output:

    [{"text": "I am happy","result": {Success", "score": "0.7", "normalizedScore": "0.7", "connectorConfig": "10932aa773101300734e234ffff6a777", "errorMessage":""}},{"text": "I am not happy","result": {Success", "score": "-0.7", "normalizedScore": "-0.7", "connectorConfig": "10932aa773101300734e234ffff6a777", "errorMessage":""}}]

    SentimentAnalyser - analyzeMultipleWithLanguage(Array inputTextArray, String language)

    Performs sentiment analysis on an array of strings in the specified language.

    표 6. Parameters
    Name Type Description
    inputTextArray Array Array of text (string) on which to perform sentiment analysis.
    language String Language for the input text. This can very for different sentiment services.
    표 7. Returns
    Type Description
    JSON Array An array with the result of the sentiment analysis performed on multiple texts of the mentioned language, specifying the status, score, normalized score, sys_id of the relevant connector configuration, and error message.
    var sa = new sn_nlp_sentiment.SentimentAnalyser();
    var result = sa.analyzeMultipleWithLanguage (["Example string1","Example string2"], "en");

    Output:

    [{"text": "I am happy","result": {Success", "score": "0.7", "normalizedScore": "0.7", "connectorConfig": "10932aa773101300734e234ffff6a777", "errorMessage":""}},{"text": "I am not happy","result": {Success", "score": "-0.7", "normalizedScore": "-0.7", "connectorConfig": "10932aa773101300734e234ffff6a777", "errorMessage":""}}]

    SentimentAnalyser - analyzeWithLanguage(String inputText, String language)

    Performs sentiment analysis on a specified text and language.

    표 8. Parameters
    Name Type Description
    inputText String Text on which to perform sentiment analysis.
    language String Language for the input text. This can vary for different sentiment services.
    표 9. Returns
    Type Description
    JSON object Result of the sentiment analysis specifying the status, score, normalized score, sys_id of the relevant connector configuration, and error message.
    var sa = new sn_nlp_sentiment.SentimentAnalyser();
    var result = sa.analyze ("Example string", "en");

    Output:

    {"status": "Success", "score": "0.7", "normalizedScore": "0.7", "connectorConfig": "10932aa773101300734e234ffff6a777", errorMessage":""}

    SentimentAnalyser - getConnectorByName(String connectorName)

    Returns the GlideRecord of the specified connector configuration.

    표 10. Parameters
    Name Type Description
    connectorName String Name of the connector configuration.
    표 11. Returns
    Type Description
    GlideRecord GlideRecord of the specified connector configuration.
    var sa = new sn_nlp_sentiment.SentimentAnalyser();
    var connector = sa.getConnectorByName("xxx");

    Output:

    GlideRecord object of the connector configuration with name "xxx", null if no connector is named as "xxx".
    

    SentimentAnalyser - getDefaultConnector()

    Returns the GlideRecord of the default connector configuration.

    표 12. Parameters
    Name Type Description
    None
    표 13. Returns
    Type Description
    GlideRecord GlideRecord of the default connector configuration.
    var sa = new sn_nlp_sentiment.SentimentAnalyser();
    var defaultConnector = sa.getDefaultConnector();