0 / 0
Tone classification

Tone classification

The Tone model in the Watson Natural Language Processing classification workflow classifies the tone in the input text.

Workflow name

ensemble_classification-workflow_en_tone-stock

Supported languages

  • English and French

Capabilities

The Tone classification model is a pre-trained document classification model for the task of classifying the tone in the input document. The model identifies the tone of the input document and classifies it as:

  • Excited
  • Frustrated
  • Impolite
  • Polite
  • Sad
  • Satisfied
  • Sympathetic

Unlike the Sentiment model, which classifies each individual sentence, the Tone model classifies the entire input document. As such, the Tone model works optimally when the input text to classify is no longer than 1000 characters. If you would like to classify texts longer than 1000 characters, split the text into sentences or paragraphs for example and apply the Tone model on each sentence or paragraph.

A document may be classified into multiple categories or into no category.

Capabilities of tone classification
Capabilities Example
Identifies the tone of a document and classifies it "I'm really happy with how this was handled, thank you!" --> excited, satisfied

Dependencies on other blocks

None

Code sample

import watson_nlp

# Load the Tone workflow model for English
tone_model = watson_nlp.load('ensemble_classification-workflow_en_tone-stock')

# Run the Tone model 
tone_result = tone_model.run("I'm really happy with how this was handled, thank you!")
print(tone_result)

Output of the code sample:

{
  "classes": [
    {
      "class_name": "excited",
      "confidence": 0.6896854620082722
    },
    {
      "class_name": "satisfied",
      "confidence": 0.6570277557333078
    },
    {
      "class_name": "polite",
      "confidence": 0.33628806679460566
    },
    {
      "class_name": "sympathetic",
      "confidence": 0.17089694967744093
    },
    {
      "class_name": "sad",
      "confidence": 0.06880583874412932
    },
    {
      "class_name": "frustrated",
      "confidence": 0.010365418217209686
    },
    {
      "class_name": "impolite",
      "confidence": 0.002470793624966174
    }
  ],
  "producer_id": {
    "name": "Voting based Ensemble",
    "version": "0.0.1"
  }
}

Parent topic: Watson Natural Language Processing task catalog

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more