1- # Copyright 2016 IBM All Rights Reserved.
1+ # Copyright 2017 IBM All Rights Reserved.
22#
33# Licensed under the Apache License, Version 2.0 (the "License");
44# you may not use this file except in compliance with the License.
1313# limitations under the License.
1414
1515"""
16- The v3 Tone Analyzer service
17- (https://www.ibm.com/watson/developercloud/tone-analyzer.html)
16+ The IBM Watson Tone Analyzer Service uses linguistic analysis to detect
17+ three types of tones from written text: emotions, social tendencies, and
18+ language style. Emotions identified include things like anger, cheerfulness
19+ and sadness. Identified social tendencies include things from the Big Five
20+ personality traits used by some psychologists. These include openness,
21+ conscientiousness, extraversion, agreeableness, and neuroticism. Identified
22+ language styles include things like confident, analytical, and tentative.
23+ Input email and other written media into the Tone Analyzer service, and use
24+ the results to determine if your writing comes across with the tone,
25+ personality traits, and writing style that you want for your intended
26+ audience.
1827"""
1928
20- from watson_developer_cloud .watson_developer_cloud_service import \
21- WatsonDeveloperCloudService
29+ from .watson_developer_cloud_service import WatsonDeveloperCloudService
2230
2331
2432class ToneAnalyzerV3 (WatsonDeveloperCloudService ):
33+ """Client for the ToneAnalyzer service."""
34+
2535 default_url = 'https://gateway.watsonplatform.net/tone-analyzer/api'
2636 latest_version = '2016-05-19'
2737
@@ -30,6 +40,10 @@ def __init__(self, version, url=default_url, **kwargs):
3040 ** kwargs )
3141 self .version = version
3242
43+ #########################
44+ # tone
45+ #########################
46+
3347 def tone (self , text , tones = None , sentences = None ):
3448 """
3549 The tone API is the main API call: it analyzes the "tone" of a piece
@@ -51,3 +65,21 @@ def tone(self, text, tones=None, sentences=None):
5165 data = {'text' : text }
5266 return self .request (method = 'POST' , url = '/v3/tone' , params = params ,
5367 json = data , accept_json = True )
68+
69+ def tone_chat (self , utterances ):
70+ """
71+ Analyze customer engagement tone.
72+
73+ Use the Tone Analyzer for Customer Engagement Endpoint to monitor
74+ customer service and customer support conversations.
75+
76+ :param utterances: The content to be analyzed.
77+ """
78+ params = {'version' : self .version }
79+ data = {'utterances' : utterances }
80+ return self .request (
81+ method = 'POST' ,
82+ url = '/v3/tone_chat' ,
83+ params = params ,
84+ json = data ,
85+ accept_json = True )
0 commit comments