Class ToneAnalyzer

java.lang.Object
com.ibm.cloud.sdk.core.service.BaseService
com.ibm.watson.tone_analyzer.v3.ToneAnalyzer

public class ToneAnalyzer
extends com.ibm.cloud.sdk.core.service.BaseService
The IBM Watson™ Tone Analyzer service uses linguistic analysis to detect emotional and language tones in written text. The service can analyze tone at both the document and sentence levels. You can use the service to understand how your written communications are perceived and then to improve the tone of your communications. Businesses can use the service to learn the tone of their customers' communications and to respond to each customer appropriately, or to understand and improve their customer conversations.

**Note:** Request logging is disabled for the Tone Analyzer service. Regardless of whether you set the `X-Watson-Learning-Opt-Out` request header, the service does not log or retain data from requests and responses.

API Version: 3.5.3 See: https://cloud.ibm.com/docs/tone-analyzer

  • Field Summary

    Fields
    Modifier and Type Field Description
    static String DEFAULT_SERVICE_NAME  
    static String DEFAULT_SERVICE_URL  

    Fields inherited from class com.ibm.cloud.sdk.core.service.BaseService

    PROPNAME_DISABLE_SSL, PROPNAME_ENABLE_GZIP, PROPNAME_URL
  • Constructor Summary

    Constructors
    Constructor Description
    ToneAnalyzer​(String version)
    Constructs an instance of the `ToneAnalyzer` client.
    ToneAnalyzer​(String version, com.ibm.cloud.sdk.core.security.Authenticator authenticator)
    Constructs an instance of the `ToneAnalyzer` client.
    ToneAnalyzer​(String version, String serviceName)
    Constructs an instance of the `ToneAnalyzer` client.
    ToneAnalyzer​(String version, String serviceName, com.ibm.cloud.sdk.core.security.Authenticator authenticator)
    Constructs an instance of the `ToneAnalyzer` client.
  • Method Summary

    Modifier and Type Method Description
    String getVersion()
    Gets the version.
    void setVersion​(String version)
    Sets the version.
    com.ibm.cloud.sdk.core.http.ServiceCall<ToneAnalysis> tone​(ToneOptions toneOptions)
    Analyze general tone.
    com.ibm.cloud.sdk.core.http.ServiceCall<UtteranceAnalyses> toneChat​(ToneChatOptions toneChatOptions)
    Analyze customer-engagement tone.

    Methods inherited from class com.ibm.cloud.sdk.core.service.BaseService

    configureClient, configureService, constructServiceUrl, constructServiceURL, enableGzipCompression, getAuthenticator, getClient, getEndPoint, getName, getServiceUrl, isJsonMimeType, isJsonPatchMimeType, setClient, setDefaultHeaders, setEndPoint, setServiceUrl, toString

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

  • Constructor Details

    • ToneAnalyzer

      public ToneAnalyzer​(String version)
      Constructs an instance of the `ToneAnalyzer` client. The default service name is used to configure the client instance.
      Parameters:
      version - Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is `2017-09-21`.
    • ToneAnalyzer

      public ToneAnalyzer​(String version, com.ibm.cloud.sdk.core.security.Authenticator authenticator)
      Constructs an instance of the `ToneAnalyzer` client. The default service name and specified authenticator are used to configure the client instance.
      Parameters:
      version - Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is `2017-09-21`.
      authenticator - the Authenticator instance to be configured for this client
    • ToneAnalyzer

      public ToneAnalyzer​(String version, String serviceName)
      Constructs an instance of the `ToneAnalyzer` client. The specified service name is used to configure the client instance.
      Parameters:
      version - Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is `2017-09-21`.
      serviceName - the service name to be used when configuring the client instance
    • ToneAnalyzer

      public ToneAnalyzer​(String version, String serviceName, com.ibm.cloud.sdk.core.security.Authenticator authenticator)
      Constructs an instance of the `ToneAnalyzer` client. The specified service name and authenticator are used to configure the client instance.
      Parameters:
      version - Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is `2017-09-21`.
      serviceName - the service name to be used when configuring the client instance
      authenticator - the Authenticator instance to be configured for this client
  • Method Details

    • getVersion

      public String getVersion()
      Gets the version.

      Release date of the version of the API you want to use. Specify dates in YYYY-MM-DD format. The current version is `2017-09-21`.

      Returns:
      the version
    • setVersion

      public void setVersion​(String version)
      Sets the version.
      Parameters:
      version - the new version
    • tone

      public com.ibm.cloud.sdk.core.http.ServiceCall<ToneAnalysis> tone​(ToneOptions toneOptions)
      Analyze general tone.

      Use the general-purpose endpoint to analyze the tone of your input content. The service analyzes the content for emotional and language tones. The method always analyzes the tone of the full document; by default, it also analyzes the tone of each individual sentence of the content.

      You can submit no more than 128 KB of total input content and no more than 1000 individual sentences in JSON, plain text, or HTML format. The service analyzes the first 1000 sentences for document-level analysis and only the first 100 sentences for sentence-level analysis.

      Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8; per the HTTP specification, the default encoding for plain text and HTML is ISO-8859-1 (effectively, the ASCII character set). When specifying a content type of plain text or HTML, include the `charset` parameter to indicate the character encoding of the input text; for example: `Content-Type: text/plain;charset=utf-8`. For `text/html`, the service removes HTML tags and analyzes only the textual content.

      **See also:** [Using the general-purpose endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utgpe#utgpe).

      Parameters:
      toneOptions - the ToneOptions containing the options for the call
      Returns:
      a ServiceCall with a result of type ToneAnalysis
    • toneChat

      public com.ibm.cloud.sdk.core.http.ServiceCall<UtteranceAnalyses> toneChat​(ToneChatOptions toneChatOptions)
      Analyze customer-engagement tone.

      Use the customer-engagement endpoint to analyze the tone of customer service and customer support conversations. For each utterance of a conversation, the method reports the most prevalent subset of the following seven tones: sad, frustrated, satisfied, excited, polite, impolite, and sympathetic.

      If you submit more than 50 utterances, the service returns a warning for the overall content and analyzes only the first 50 utterances. If you submit a single utterance that contains more than 500 characters, the service returns an error for that utterance and does not analyze the utterance. The request fails if all utterances have more than 500 characters. Per the JSON specification, the default character encoding for JSON content is effectively always UTF-8.

      **See also:** [Using the customer-engagement endpoint](https://cloud.ibm.com/docs/tone-analyzer?topic=tone-analyzer-utco#utco).

      Parameters:
      toneChatOptions - the ToneChatOptions containing the options for the call
      Returns:
      a ServiceCall with a result of type UtteranceAnalyses