Using `ToneAnalyzerV3` from the ibm_watson python package, how can I exclude a specific tone from being included?

189 views Asked by At

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?

1

There are 1 answers

2
Mark H On BEST ANSWER

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.