1

This returns all tones from the analyzer

# returns all tones (anger, fear, sadness, tentative, analytical
tone_analysis = tone_analyzer.tone({'text': text}, content_type='application/json').get_result()

How can I exclude the 'analytical' tone from being returned from the analysis?

lovelikelando
  • 7,593
  • 6
  • 32
  • 50
  • I'm sure you've seen this, but it looks like the API no longer accepts the tones=[] list of tones to limit its analysis to. https://cloud.ibm.com/apidocs/tone-analyzer I also don't see a documented way to get confidence scores for all tones, instead of just the dominant ones. – Mark H Feb 22 '21 at 13:51
  • From the python-sdk docs here: http://watson-developer-cloud.github.io/python-sdk/v1.0.2/apis/watson_developer_cloud.tone_analyzer_v3.html Looks like as of late 2017, the scores have to pass a threshold (0.5) to be returned: Attr str tone_id: The unique, non-localized identifier of the tone. 2017-09-21: The service can return results for the following tone IDs: anger, fear, joy, and sadness (emotional tones); analytical, confident, and tentative (language tones). The service returns results only for tones whose scores meet a minimum threshold of 0.5. – Mark H Feb 22 '21 at 14:04

1 Answers1

2

Sorry, it looks like the answer (as of 2017-09-21) is, "You can't."

The documentation for the python-sdk indicates as much. http://watson-developer-cloud.github.io/python-sdk/v1.0.2/apis/watson_developer_cloud.tone_analyzer_v3.html

See specifically:

Under ToneAnalyzerV3.tone(), parameter tones - you can no longer specify the tone list to return:

tones (list[str]) – 2017-09-21: Deprecated. The service continues to accept the parameter for backward-compatibility, but the parameter no longer affects the response.

Under ToneAnalyzerV3.DocumentAnalysis(), the attribute tones - the service only returns tones with scores of value >= 0.5, which means you can't do your own softmax to exclude analytical:

Attr list[ToneScore] tones: (optional) 2017-09-21: An array of ToneScore objects that provides the results of the analysis for each qualifying tone of the document. The array includes results for any tone whose score is at least 0.5. The array is empty if no tone has a score that meets this threshold.

Under ToneAnalyzerV3.SentenceAnalysis(), the attribute tones - same story:

Attr list[ToneScore] tones: (optional) 2017-09-21: An array of ToneScore objects that provides the results of the analysis for each qualifying tone of the sentence. The array includes results for any tone whose score is at least 0.5. The array is empty if no tone has a score that meets this threshold.

Mark H
  • 4,246
  • 3
  • 12
  • Pity. It would be a useful feature. – lovelikelando Feb 26 '21 at 20:17
  • Yeah, I was thinking about why they removed it. I can think of two reasons: 1) people were "incorrectly" using values less than 0.5, or 2) people were using the Watson system to train their own systems! Hmmm I wonder if you could still do that with clipping the probability... I don't think it would work that well. – Mark H Feb 27 '21 at 04:22