File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22import json
33from os .path import join , dirname
44from watson_developer_cloud import ToneAnalyzerV3
5+ from watson_developer_cloud .tone_analyzer_v3 import ToneInput
56
67tone_analyzer = ToneAnalyzerV3 (
78 username = 'YOUR SERVICE USERNAME' ,
5556print (tone )
5657print (tone .get_headers ())
5758print (tone .get_result ())
59+ tone_analyzer .set_detailed_response (False )
60+
61+ print ("\n tone() example 7:\n " )
62+ tone_input = ToneInput ('I am very happy. It is a good day.' )
63+ tone = tone_analyzer .tone (
64+ tone_input = tone_input ,
65+ content_type = "application/json" )
66+ print (json .dumps (tone , indent = 2 ))
Original file line number Diff line number Diff line change @@ -170,6 +170,8 @@ def tone(self,
170170 raise ValueError ('tone_input must be provided' )
171171 if content_type is None :
172172 raise ValueError ('content_type must be provided' )
173+ if isinstance (tone_input , ToneInput ):
174+ tone_input = self ._convert_model (tone_input , ToneInput )
173175 headers = {
174176 'Content-Type' : content_type ,
175177 'Content-Language' : content_language ,
You can’t perform that action at this time.
0 commit comments