Skip to content

Commit 58ac117

Browse files
committed
chore(TA): regenerate tone analyzer
1 parent 79c7a07 commit 58ac117

File tree

1 file changed

+108
-21
lines changed

1 file changed

+108
-21
lines changed

ibm_watson/tone_analyzer_v3.py

Lines changed: 108 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,11 @@ def __init__(
5050
iam_apikey=None,
5151
iam_access_token=None,
5252
iam_url=None,
53+
iam_client_id=None,
54+
iam_client_secret=None,
55+
icp4d_access_token=None,
56+
icp4d_url=None,
57+
authentication_type=None,
5358
):
5459
"""
5560
Construct a new client for the Tone Analyzer service.
@@ -92,6 +97,21 @@ def __init__(
9297
9398
:param str iam_url: An optional URL for the IAM service API. Defaults to
9499
'https://iam.cloud.ibm.com/identity/token'.
100+
101+
:param str iam_client_id: An optional client_id value to use when interacting with the IAM service.
102+
103+
:param str iam_client_secret: An optional client_secret value to use when interacting with the IAM service.
104+
105+
:param str icp4d_access_token: A ICP4D(IBM Cloud Pak for Data) access token is
106+
fully managed by the application. Responsibility falls on the application to
107+
refresh the token, either before it expires or reactively upon receiving a 401
108+
from the service as any requests made with an expired token will fail.
109+
110+
:param str icp4d_url: In order to use an SDK-managed token with ICP4D authentication, this
111+
URL must be passed in.
112+
113+
:param str authentication_type: Specifies the authentication pattern to use. Values that it
114+
takes are basic, iam or icp4d.
95115
"""
96116

97117
BaseService.__init__(
@@ -103,8 +123,13 @@ def __init__(
103123
iam_apikey=iam_apikey,
104124
iam_access_token=iam_access_token,
105125
iam_url=iam_url,
126+
iam_client_id=iam_client_id,
127+
iam_client_secret=iam_client_secret,
106128
use_vcap_services=True,
107-
display_name='Tone Analyzer')
129+
display_name='Tone Analyzer',
130+
icp4d_access_token=icp4d_access_token,
131+
icp4d_url=icp4d_url,
132+
authentication_type=authentication_type)
108133
self.version = version
109134

110135
#########################
@@ -122,7 +147,7 @@ def tone(self,
122147
"""
123148
Analyze general tone.
124149
125-
Use the general purpose endpoint to analyze the tone of your input content. The
150+
Use the general-purpose endpoint to analyze the tone of your input content. The
126151
service analyzes the content for emotional and language tones. The method always
127152
analyzes the tone of the full document; by default, it also analyzes the tone of
128153
each individual sentence of the content.
@@ -138,7 +163,7 @@ def tone(self,
138163
text/plain;charset=utf-8`. For `text/html`, the service removes HTML tags and
139164
analyzes only the textual content.
140165
**See also:** [Using the general-purpose
141-
endpoint](https://cloud.ibm.com/docs/services/tone-analyzer/using-tone.html#using-the-general-purpose-endpoint).
166+
endpoint](https://cloud.ibm.com/docs/services/tone-analyzer?topic=tone-analyzer-utgpe#utgpe).
142167
143168
:param ToneInput tone_input: JSON, plain text, or HTML input that contains the
144169
content to be analyzed. For JSON input, provide an object of type `ToneInput`.
@@ -213,9 +238,9 @@ def tone_chat(self,
213238
accept_language=None,
214239
**kwargs):
215240
"""
216-
Analyze customer engagement tone.
241+
Analyze customer-engagement tone.
217242
218-
Use the customer engagement endpoint to analyze the tone of customer service and
243+
Use the customer-engagement endpoint to analyze the tone of customer service and
219244
customer support conversations. For each utterance of a conversation, the method
220245
reports the most prevalent subset of the following seven tones: sad, frustrated,
221246
satisfied, excited, polite, impolite, and sympathetic.
@@ -226,7 +251,7 @@ def tone_chat(self,
226251
utterances have more than 500 characters. Per the JSON specification, the default
227252
character encoding for JSON content is effectively always UTF-8.
228253
**See also:** [Using the customer-engagement
229-
endpoint](https://cloud.ibm.com/docs/services/tone-analyzer/using-tone-chat.html#using-the-customer-engagement-endpoint).
254+
endpoint](https://cloud.ibm.com/docs/services/tone-analyzer?topic=tone-analyzer-utco#utco).
230255
231256
:param list[Utterance] utterances: An array of `Utterance` objects that provides
232257
the input content that the service is to analyze.
@@ -281,8 +306,7 @@ def tone_chat(self,
281306

282307
class DocumentAnalysis(object):
283308
"""
284-
An object of type `DocumentAnalysis` that provides the results of the analysis for the
285-
full input document.
309+
The results of the analysis for the full input content.
286310
287311
:attr list[ToneScore] tones: (optional) **`2017-09-21`:** An array of `ToneScore`
288312
objects that provides the results of the analysis for each qualifying tone of the
@@ -326,6 +350,12 @@ def __init__(self, tones=None, tone_categories=None, warning=None):
326350
def _from_dict(cls, _dict):
327351
"""Initialize a DocumentAnalysis object from a json dictionary."""
328352
args = {}
353+
validKeys = ['tones', 'tone_categories', 'warning']
354+
badKeys = set(_dict.keys()) - set(validKeys)
355+
if badKeys:
356+
raise ValueError(
357+
'Unrecognized keys detected in dictionary for class DocumentAnalysis: '
358+
+ ', '.join(badKeys))
329359
if 'tones' in _dict:
330360
args['tones'] = [
331361
ToneScore._from_dict(x) for x in (_dict.get('tones'))
@@ -370,7 +400,7 @@ def __ne__(self, other):
370400

371401
class SentenceAnalysis(object):
372402
"""
373-
SentenceAnalysis.
403+
The results of the analysis for the individual sentences of the input content.
374404
375405
:attr int sentence_id: The unique identifier of a sentence of the input content. The
376406
first sentence has ID 0, and the ID of each subsequent sentence is incremented by one.
@@ -430,6 +460,15 @@ def __init__(self,
430460
def _from_dict(cls, _dict):
431461
"""Initialize a SentenceAnalysis object from a json dictionary."""
432462
args = {}
463+
validKeys = [
464+
'sentence_id', 'text', 'tones', 'tone_categories', 'input_from',
465+
'input_to'
466+
]
467+
badKeys = set(_dict.keys()) - set(validKeys)
468+
if badKeys:
469+
raise ValueError(
470+
'Unrecognized keys detected in dictionary for class SentenceAnalysis: '
471+
+ ', '.join(badKeys))
433472
if 'sentence_id' in _dict:
434473
args['sentence_id'] = _dict.get('sentence_id')
435474
else:
@@ -494,10 +533,10 @@ def __ne__(self, other):
494533

495534
class ToneAnalysis(object):
496535
"""
497-
ToneAnalysis.
536+
The tone analysis results for the input from the general-purpose endpoint.
498537
499-
:attr DocumentAnalysis document_tone: An object of type `DocumentAnalysis` that
500-
provides the results of the analysis for the full input document.
538+
:attr DocumentAnalysis document_tone: The results of the analysis for the full input
539+
content.
501540
:attr list[SentenceAnalysis] sentences_tone: (optional) An array of `SentenceAnalysis`
502541
objects that provides the results of the analysis for the individual sentences of the
503542
input content. The service returns results only for the first 100 sentences of the
@@ -509,8 +548,8 @@ def __init__(self, document_tone, sentences_tone=None):
509548
"""
510549
Initialize a ToneAnalysis object.
511550
512-
:param DocumentAnalysis document_tone: An object of type `DocumentAnalysis` that
513-
provides the results of the analysis for the full input document.
551+
:param DocumentAnalysis document_tone: The results of the analysis for the full
552+
input content.
514553
:param list[SentenceAnalysis] sentences_tone: (optional) An array of
515554
`SentenceAnalysis` objects that provides the results of the analysis for the
516555
individual sentences of the input content. The service returns results only for
@@ -524,6 +563,12 @@ def __init__(self, document_tone, sentences_tone=None):
524563
def _from_dict(cls, _dict):
525564
"""Initialize a ToneAnalysis object from a json dictionary."""
526565
args = {}
566+
validKeys = ['document_tone', 'sentences_tone']
567+
badKeys = set(_dict.keys()) - set(validKeys)
568+
if badKeys:
569+
raise ValueError(
570+
'Unrecognized keys detected in dictionary for class ToneAnalysis: '
571+
+ ', '.join(badKeys))
527572
if 'document_tone' in _dict:
528573
args['document_tone'] = DocumentAnalysis._from_dict(
529574
_dict.get('document_tone'))
@@ -566,7 +611,7 @@ def __ne__(self, other):
566611

567612
class ToneCategory(object):
568613
"""
569-
ToneCategory.
614+
The category for a tone from the input content.
570615
571616
:attr list[ToneScore] tones: An array of `ToneScore` objects that provides the results
572617
for the tones of the category.
@@ -595,6 +640,12 @@ def __init__(self, tones, category_id, category_name):
595640
def _from_dict(cls, _dict):
596641
"""Initialize a ToneCategory object from a json dictionary."""
597642
args = {}
643+
validKeys = ['tones', 'category_id', 'category_name']
644+
badKeys = set(_dict.keys()) - set(validKeys)
645+
if badKeys:
646+
raise ValueError(
647+
'Unrecognized keys detected in dictionary for class ToneCategory: '
648+
+ ', '.join(badKeys))
598649
if 'tones' in _dict:
599650
args['tones'] = [
600651
ToneScore._from_dict(x) for x in (_dict.get('tones'))
@@ -644,7 +695,7 @@ def __ne__(self, other):
644695

645696
class ToneChatScore(object):
646697
"""
647-
ToneChatScore.
698+
The score for an utterance from the input content.
648699
649700
:attr float score: The score for the tone in the range of 0.5 to 1. A score greater
650701
than 0.75 indicates a high likelihood that the tone is perceived in the utterance.
@@ -674,6 +725,12 @@ def __init__(self, score, tone_id, tone_name):
674725
def _from_dict(cls, _dict):
675726
"""Initialize a ToneChatScore object from a json dictionary."""
676727
args = {}
728+
validKeys = ['score', 'tone_id', 'tone_name']
729+
badKeys = set(_dict.keys()) - set(validKeys)
730+
if badKeys:
731+
raise ValueError(
732+
'Unrecognized keys detected in dictionary for class ToneChatScore: '
733+
+ ', '.join(badKeys))
677734
if 'score' in _dict:
678735
args['score'] = _dict.get('score')
679736
else:
@@ -721,7 +778,7 @@ def __ne__(self, other):
721778

722779
class ToneInput(object):
723780
"""
724-
ToneInput.
781+
Input for the general-purpose endpoint.
725782
726783
:attr str text: The input content that the service is to analyze.
727784
"""
@@ -738,6 +795,12 @@ def __init__(self, text):
738795
def _from_dict(cls, _dict):
739796
"""Initialize a ToneInput object from a json dictionary."""
740797
args = {}
798+
validKeys = ['text']
799+
badKeys = set(_dict.keys()) - set(validKeys)
800+
if badKeys:
801+
raise ValueError(
802+
'Unrecognized keys detected in dictionary for class ToneInput: '
803+
+ ', '.join(badKeys))
741804
if 'text' in _dict:
742805
args['text'] = _dict.get('text')
743806
else:
@@ -769,7 +832,7 @@ def __ne__(self, other):
769832

770833
class ToneScore(object):
771834
"""
772-
ToneScore.
835+
The score for a tone from the input content.
773836
774837
:attr float score: The score for the tone.
775838
* **`2017-09-21`:** The score that is returned lies in the range of 0.5 to 1. A score
@@ -825,6 +888,12 @@ def __init__(self, score, tone_id, tone_name):
825888
def _from_dict(cls, _dict):
826889
"""Initialize a ToneScore object from a json dictionary."""
827890
args = {}
891+
validKeys = ['score', 'tone_id', 'tone_name']
892+
badKeys = set(_dict.keys()) - set(validKeys)
893+
if badKeys:
894+
raise ValueError(
895+
'Unrecognized keys detected in dictionary for class ToneScore: '
896+
+ ', '.join(badKeys))
828897
if 'score' in _dict:
829898
args['score'] = _dict.get('score')
830899
else:
@@ -870,7 +939,7 @@ def __ne__(self, other):
870939

871940
class Utterance(object):
872941
"""
873-
Utterance.
942+
An utterance for the input of the general-purpose endpoint.
874943
875944
:attr str text: An utterance contributed by a user in the conversation that is to be
876945
analyzed. The utterance can contain multiple sentences.
@@ -894,6 +963,12 @@ def __init__(self, text, user=None):
894963
def _from_dict(cls, _dict):
895964
"""Initialize a Utterance object from a json dictionary."""
896965
args = {}
966+
validKeys = ['text', 'user']
967+
badKeys = set(_dict.keys()) - set(validKeys)
968+
if badKeys:
969+
raise ValueError(
970+
'Unrecognized keys detected in dictionary for class Utterance: '
971+
+ ', '.join(badKeys))
897972
if 'text' in _dict:
898973
args['text'] = _dict.get('text')
899974
else:
@@ -929,7 +1004,7 @@ def __ne__(self, other):
9291004

9301005
class UtteranceAnalyses(object):
9311006
"""
932-
UtteranceAnalyses.
1007+
The results of the analysis for the utterances of the input content.
9331008
9341009
:attr list[UtteranceAnalysis] utterances_tone: An array of `UtteranceAnalysis` objects
9351010
that provides the results for each utterance of the input.
@@ -955,6 +1030,12 @@ def __init__(self, utterances_tone, warning=None):
9551030
def _from_dict(cls, _dict):
9561031
"""Initialize a UtteranceAnalyses object from a json dictionary."""
9571032
args = {}
1033+
validKeys = ['utterances_tone', 'warning']
1034+
badKeys = set(_dict.keys()) - set(validKeys)
1035+
if badKeys:
1036+
raise ValueError(
1037+
'Unrecognized keys detected in dictionary for class UtteranceAnalyses: '
1038+
+ ', '.join(badKeys))
9581039
if 'utterances_tone' in _dict:
9591040
args['utterances_tone'] = [
9601041
UtteranceAnalysis._from_dict(x)
@@ -997,7 +1078,7 @@ def __ne__(self, other):
9971078

9981079
class UtteranceAnalysis(object):
9991080
"""
1000-
UtteranceAnalysis.
1081+
The results of the analysis for an utterance of the input content.
10011082
10021083
:attr int utterance_id: The unique identifier of the utterance. The first utterance
10031084
has ID 0, and the ID of each subsequent utterance is incremented by one.
@@ -1035,6 +1116,12 @@ def __init__(self, utterance_id, utterance_text, tones, error=None):
10351116
def _from_dict(cls, _dict):
10361117
"""Initialize a UtteranceAnalysis object from a json dictionary."""
10371118
args = {}
1119+
validKeys = ['utterance_id', 'utterance_text', 'tones', 'error']
1120+
badKeys = set(_dict.keys()) - set(validKeys)
1121+
if badKeys:
1122+
raise ValueError(
1123+
'Unrecognized keys detected in dictionary for class UtteranceAnalysis: '
1124+
+ ', '.join(badKeys))
10381125
if 'utterance_id' in _dict:
10391126
args['utterance_id'] = _dict.get('utterance_id')
10401127
else:

0 commit comments

Comments
 (0)