Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ToneAnalyzerV3

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. interfaces

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

Hierarchy

  • BaseService
    • ToneAnalyzerV3

Index

Constructors

constructor

  • Construct a ToneAnalyzerV3 object.

    Parameters

    Name Type Attribute Description
    options UserOptions

    Options for the service.

    Returns ToneAnalyzerV3

Properties

version

version: string

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.

Static DEFAULT_SERVICE_NAME

DEFAULT_SERVICE_NAME: string = "tone_analyzer"

Static DEFAULT_SERVICE_URL

DEFAULT_SERVICE_URL: string = "https://api.us-south.tone-analyzer.watson.cloud.ibm.com"

Methods

disableRetries

  • disableRetries(): void
  • Disables retries.

    Returns void

enableRetries

  • enableRetries(retryOptions?: RetryOptions): void
  • Enable retries for unfulfilled requests.

    Parameters

    Name Type Attribute Description
    retryOptions RetryOptions Optional

    configuration for retries

    Returns void

getAuthenticator

  • getAuthenticator(): any
  • Get the instance of the authenticator set on the service.

    Returns any

getHttpClient

  • getHttpClient(): AxiosInstance
  • Get the Axios instance set on the service. All requests will be made using this instance.

    Returns AxiosInstance

setEnableGzipCompression

  • setEnableGzipCompression(setting: boolean): void
  • Turn request body compression on or off.

    Parameters

    Name Type Attribute Description
    setting boolean

    Will turn it on if 'true', off if 'false'.

    Returns void

setServiceUrl

  • setServiceUrl(url: string): void
  • Set the service URL to send requests to.

    Parameters

    Name Type Attribute Description
    url string

    The base URL for the service.

    Returns void

tone

  • 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.

    Parameters

    Name Type Attribute Description
    params ToneParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    toneInput ToneInput | string JSON, plain text, or HTML input that contains the content to be analyzed. For JSON input, provide an object of type `ToneInput`.
    acceptLanguage AcceptLanguage | string Optional The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and **Accept-Language**.
    contentLanguage ContentLanguage | string Optional The language of the input text for the request: English or French. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not submit content that contains both languages. You can use different languages for **Content-Language** and **Accept-Language**. * **`2017-09-21`:** Accepts `en` or `fr`. * **`2016-05-19`:** Accepts only `en`.
    contentType ContentType | string Optional The type of the input. A character encoding can be specified by including a `charset` parameter. For example, 'text/plain;charset=utf-8'.
    headers OutgoingHttpHeaders Optional
    sentences boolean Optional Indicates whether the service is to return an analysis of each individual sentence in addition to its analysis of the full document. If `true` (the default), the service returns results for each sentence.
    tones Tones[] | string[] Optional *`2017-09-21`:** Deprecated. The service continues to accept the parameter for backward-compatibility, but the parameter no longer affects the response.

    Returns Promise<Response<ToneAnalysis>>

toneChat

  • 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.

    Parameters

    Name Type Attribute Description
    params ToneChatParams

    The parameters to send to the service.

    Properties

    Name Type Attributes Description
    utterances Utterance[] An array of `Utterance` objects that provides the input content that the service is to analyze.
    acceptLanguage AcceptLanguage | string Optional The desired language of the response. For two-character arguments, regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. You can use different languages for **Content-Language** and **Accept-Language**.
    contentLanguage ContentLanguage | string Optional The language of the input text for the request: English or French. Regional variants are treated as their parent language; for example, `en-US` is interpreted as `en`. The input content must match the specified language. Do not submit content that contains both languages. You can use different languages for **Content-Language** and **Accept-Language**. * **`2017-09-21`:** Accepts `en` or `fr`. * **`2016-05-19`:** Accepts only `en`.
    headers OutgoingHttpHeaders Optional

    Returns Promise<Response<UtteranceAnalyses>>

Generated using TypeDoc