Skip to content

Commit a9f0149

Browse files
authored
Merge pull request #596 from watson-developer-cloud/fixes
patch release 1.4.2
2 parents f7be21f + ad6f2a0 commit a9f0149

File tree

3 files changed

+111
-40
lines changed

3 files changed

+111
-40
lines changed

watson_developer_cloud/discovery_v1.py

Lines changed: 92 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6760,6 +6760,53 @@ def __ne__(self, other):
67606760
return not self == other
67616761

67626762

6763+
class NluEnrichmentConcepts(object):
6764+
"""
6765+
An object specifiying the concepts enrichment and related parameters.
6766+
6767+
:attr int limit: (optional) The maximum number of concepts enrichments to extact from
6768+
each instance of the specified field.
6769+
"""
6770+
6771+
def __init__(self, limit=None):
6772+
"""
6773+
Initialize a NluEnrichmentConcepts object.
6774+
6775+
:param int limit: (optional) The maximum number of concepts enrichments to extact
6776+
from each instance of the specified field.
6777+
"""
6778+
self.limit = limit
6779+
6780+
@classmethod
6781+
def _from_dict(cls, _dict):
6782+
"""Initialize a NluEnrichmentConcepts object from a json dictionary."""
6783+
args = {}
6784+
if 'limit' in _dict:
6785+
args['limit'] = _dict.get('limit')
6786+
return cls(**args)
6787+
6788+
def _to_dict(self):
6789+
"""Return a json dictionary representing this model."""
6790+
_dict = {}
6791+
if hasattr(self, 'limit') and self.limit is not None:
6792+
_dict['limit'] = self.limit
6793+
return _dict
6794+
6795+
def __str__(self):
6796+
"""Return a `str` version of this NluEnrichmentConcepts object."""
6797+
return json.dumps(self._to_dict(), indent=2)
6798+
6799+
def __eq__(self, other):
6800+
"""Return `true` when self and other are equal, false otherwise."""
6801+
if not isinstance(other, self.__class__):
6802+
return False
6803+
return self.__dict__ == other.__dict__
6804+
6805+
def __ne__(self, other):
6806+
"""Return `true` when self and other are not equal, false otherwise."""
6807+
return not self == other
6808+
6809+
67636810
class NluEnrichmentEmotion(object):
67646811
"""
67656812
An object specifying the emotion detection enrichment and related parameters.
@@ -6830,8 +6877,8 @@ class NluEnrichmentEntities(object):
68306877
entity is recorded. The default is `false`.
68316878
:attr bool mention_types: (optional) When `true`, the types of mentions for each
68326879
idetifieid entity is recorded. The default is `false`.
6833-
:attr bool sentence_location: (optional) When `true`, a list of sentence locations for
6834-
each instance of each identified entity is recorded. The default is `false`.
6880+
:attr bool sentence_locations: (optional) When `true`, a list of sentence locations
6881+
for each instance of each identified entity is recorded. The default is `false`.
68356882
:attr str model: (optional) The enrichement model to use with entity extraction. May
68366883
be a custom model provided by Watson Knowledge Studio, the public model for use with
68376884
Knowledge Graph `en-news`, or the default public model `alchemy`.
@@ -6843,7 +6890,7 @@ def __init__(self,
68436890
limit=None,
68446891
mentions=None,
68456892
mention_types=None,
6846-
sentence_location=None,
6893+
sentence_locations=None,
68476894
model=None):
68486895
"""
68496896
Initialize a NluEnrichmentEntities object.
@@ -6858,7 +6905,7 @@ def __init__(self,
68586905
identified entity is recorded. The default is `false`.
68596906
:param bool mention_types: (optional) When `true`, the types of mentions for each
68606907
idetifieid entity is recorded. The default is `false`.
6861-
:param bool sentence_location: (optional) When `true`, a list of sentence
6908+
:param bool sentence_locations: (optional) When `true`, a list of sentence
68626909
locations for each instance of each identified entity is recorded. The default is
68636910
`false`.
68646911
:param str model: (optional) The enrichement model to use with entity extraction.
@@ -6870,7 +6917,7 @@ def __init__(self,
68706917
self.limit = limit
68716918
self.mentions = mentions
68726919
self.mention_types = mention_types
6873-
self.sentence_location = sentence_location
6920+
self.sentence_locations = sentence_locations
68746921
self.model = model
68756922

68766923
@classmethod
@@ -6887,8 +6934,8 @@ def _from_dict(cls, _dict):
68876934
args['mentions'] = _dict.get('mentions')
68886935
if 'mention_types' in _dict:
68896936
args['mention_types'] = _dict.get('mention_types')
6890-
if 'sentence_location' in _dict:
6891-
args['sentence_location'] = _dict.get('sentence_location')
6937+
if 'sentence_locations' in _dict:
6938+
args['sentence_locations'] = _dict.get('sentence_locations')
68926939
if 'model' in _dict:
68936940
args['model'] = _dict.get('model')
68946941
return cls(**args)
@@ -6906,9 +6953,10 @@ def _to_dict(self):
69066953
_dict['mentions'] = self.mentions
69076954
if hasattr(self, 'mention_types') and self.mention_types is not None:
69086955
_dict['mention_types'] = self.mention_types
6909-
if hasattr(self,
6910-
'sentence_location') and self.sentence_location is not None:
6911-
_dict['sentence_location'] = self.sentence_location
6956+
if hasattr(
6957+
self,
6958+
'sentence_locations') and self.sentence_locations is not None:
6959+
_dict['sentence_locations'] = self.sentence_locations
69126960
if hasattr(self, 'model') and self.model is not None:
69136961
_dict['model'] = self.model
69146962
return _dict
@@ -6946,6 +6994,8 @@ class NluEnrichmentFeatures(object):
69466994
semantic roles enrichment and related parameters.
69476995
:attr NluEnrichmentRelations relations: (optional) An object specifying the relations
69486996
enrichment and related parameters.
6997+
:attr NluEnrichmentConcepts concepts: (optional) An object specifiying the concepts
6998+
enrichment and related parameters.
69496999
"""
69507000

69517001
def __init__(self,
@@ -6955,7 +7005,8 @@ def __init__(self,
69557005
emotion=None,
69567006
categories=None,
69577007
semantic_roles=None,
6958-
relations=None):
7008+
relations=None,
7009+
concepts=None):
69597010
"""
69607011
Initialize a NluEnrichmentFeatures object.
69617012
@@ -6973,6 +7024,8 @@ def __init__(self,
69737024
the semantic roles enrichment and related parameters.
69747025
:param NluEnrichmentRelations relations: (optional) An object specifying the
69757026
relations enrichment and related parameters.
7027+
:param NluEnrichmentConcepts concepts: (optional) An object specifiying the
7028+
concepts enrichment and related parameters.
69767029
"""
69777030
self.keywords = keywords
69787031
self.entities = entities
@@ -6981,6 +7034,7 @@ def __init__(self,
69817034
self.categories = categories
69827035
self.semantic_roles = semantic_roles
69837036
self.relations = relations
7037+
self.concepts = concepts
69847038

69857039
@classmethod
69867040
def _from_dict(cls, _dict):
@@ -7007,6 +7061,9 @@ def _from_dict(cls, _dict):
70077061
if 'relations' in _dict:
70087062
args['relations'] = NluEnrichmentRelations._from_dict(
70097063
_dict.get('relations'))
7064+
if 'concepts' in _dict:
7065+
args['concepts'] = NluEnrichmentConcepts._from_dict(
7066+
_dict.get('concepts'))
70107067
return cls(**args)
70117068

70127069
def _to_dict(self):
@@ -7026,6 +7083,8 @@ def _to_dict(self):
70267083
_dict['semantic_roles'] = self.semantic_roles._to_dict()
70277084
if hasattr(self, 'relations') and self.relations is not None:
70287085
_dict['relations'] = self.relations._to_dict()
7086+
if hasattr(self, 'concepts') and self.concepts is not None:
7087+
_dict['concepts'] = self.concepts._to_dict()
70297088
return _dict
70307089

70317090
def __str__(self):
@@ -9773,30 +9832,26 @@ class TokenDictRule(object):
97739832
"""
97749833
An object defining a single tokenizaion rule.
97759834
9776-
:attr str text: (optional) The string to tokenize.
9777-
:attr list[str] tokens: (optional) Array of tokens that the `text` field is split into
9778-
when found.
9835+
:attr str text: The string to tokenize.
9836+
:attr list[str] tokens: Array of tokens that the `text` field is split into when
9837+
found.
97799838
:attr list[str] readings: (optional) Array of tokens that represent the content of the
97809839
`text` field in an alternate character set.
9781-
:attr str part_of_speech: (optional) The part of speech that the `text` string belongs
9782-
to. For example `noun`. Custom parts of speech can be specified.
9840+
:attr str part_of_speech: The part of speech that the `text` string belongs to. For
9841+
example `noun`. Custom parts of speech can be specified.
97839842
"""
97849843

9785-
def __init__(self,
9786-
text=None,
9787-
tokens=None,
9788-
readings=None,
9789-
part_of_speech=None):
9844+
def __init__(self, text, tokens, part_of_speech, readings=None):
97909845
"""
97919846
Initialize a TokenDictRule object.
97929847
9793-
:param str text: (optional) The string to tokenize.
9794-
:param list[str] tokens: (optional) Array of tokens that the `text` field is split
9795-
into when found.
9848+
:param str text: The string to tokenize.
9849+
:param list[str] tokens: Array of tokens that the `text` field is split into when
9850+
found.
9851+
:param str part_of_speech: The part of speech that the `text` string belongs to.
9852+
For example `noun`. Custom parts of speech can be specified.
97969853
:param list[str] readings: (optional) Array of tokens that represent the content
97979854
of the `text` field in an alternate character set.
9798-
:param str part_of_speech: (optional) The part of speech that the `text` string
9799-
belongs to. For example `noun`. Custom parts of speech can be specified.
98009855
"""
98019856
self.text = text
98029857
self.tokens = tokens
@@ -9809,12 +9864,23 @@ def _from_dict(cls, _dict):
98099864
args = {}
98109865
if 'text' in _dict:
98119866
args['text'] = _dict.get('text')
9867+
else:
9868+
raise ValueError(
9869+
'Required property \'text\' not present in TokenDictRule JSON')
98129870
if 'tokens' in _dict:
98139871
args['tokens'] = _dict.get('tokens')
9872+
else:
9873+
raise ValueError(
9874+
'Required property \'tokens\' not present in TokenDictRule JSON'
9875+
)
98149876
if 'readings' in _dict:
98159877
args['readings'] = _dict.get('readings')
98169878
if 'part_of_speech' in _dict:
98179879
args['part_of_speech'] = _dict.get('part_of_speech')
9880+
else:
9881+
raise ValueError(
9882+
'Required property \'part_of_speech\' not present in TokenDictRule JSON'
9883+
)
98189884
return cls(**args)
98199885

98209886
def _to_dict(self):

watson_developer_cloud/speech_to_text_v1.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def list_models(self, **kwargs):
162162

163163
def recognize(self,
164164
audio,
165-
content_type,
165+
content_type=None,
166166
model=None,
167167
language_customization_id=None,
168168
acoustic_customization_id=None,
@@ -351,8 +351,6 @@ def recognize(self,
351351

352352
if audio is None:
353353
raise ValueError('audio must be provided')
354-
if content_type is None:
355-
raise ValueError('content_type must be provided')
356354

357355
headers = {'Content-Type': content_type}
358356
if 'headers' in kwargs:
@@ -459,7 +457,7 @@ def check_jobs(self, **kwargs):
459457

460458
def create_job(self,
461459
audio,
462-
content_type,
460+
content_type=None,
463461
model=None,
464462
callback_url=None,
465463
events=None,
@@ -698,8 +696,6 @@ def create_job(self,
698696

699697
if audio is None:
700698
raise ValueError('audio must be provided')
701-
if content_type is None:
702-
raise ValueError('content_type must be provided')
703699

704700
headers = {'Content-Type': content_type}
705701
if 'headers' in kwargs:

watson_developer_cloud/speech_to_text_v1_adapter.py

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def recognize_using_websocket(self,
3131
content_type,
3232
recognize_callback,
3333
model=None,
34-
customization_id=None,
34+
language_customization_id=None,
3535
acoustic_customization_id=None,
3636
customization_weight=None,
3737
base_model_version=None,
@@ -48,6 +48,7 @@ def recognize_using_websocket(self,
4848
speaker_labels=None,
4949
http_proxy_host=None,
5050
http_proxy_port=None,
51+
customization_id=None,
5152
**kwargs):
5253
"""
5354
Sends audio for speech recognition using web sockets.
@@ -61,12 +62,15 @@ def recognize_using_websocket(self,
6162
:param RecognizeCallback recognize_callback: The callback method for the websocket.
6263
:param str model: The identifier of the model that is to be used for the
6364
recognition request or, for the **Create a session** method, with the new session.
64-
:param str customization_id: The customization ID (GUID) of a custom language
65-
model that is to be used with the recognition request or, for the **Create a
66-
session** method, with the new session. The base model of the specified custom
67-
language model must match the model specified with the `model` parameter. You must
68-
make the request with service credentials created for the instance of the service
69-
that owns the custom model. By default, no custom language model is used.
65+
:param str language_customization_id: The customization ID (GUID) of a custom
66+
language model that is to be used with the recognition request. The base model of
67+
the specified custom language model must match the model specified with the
68+
`model` parameter. You must make the request with service credentials created for
69+
the instance of the service that owns the custom model. By default, no custom
70+
language model is used. See [Custom
71+
models](https://console.bluemix.net/docs/services/speech-to-text/input.html#custom).
72+
**Note:** Use this parameter instead of the deprecated `customization_id`
73+
parameter.
7074
:param str acoustic_customization_id: The customization ID (GUID) of a custom
7175
acoustic model that is to be used with the recognition request or, for the
7276
**Create a session** method, with the new session. The base model of the specified
@@ -141,6 +145,10 @@ def recognize_using_websocket(self,
141145
labels](https://console.bluemix.net/docs/services/speech-to-text/output.html#speaker_labels).
142146
:param str http_proxy_host: http proxy host name.
143147
:param str http_proxy_port: http proxy port. If not set, set to 80.
148+
:param str customization_id: **Deprecated.** Use the `language_customization_id`
149+
parameter to specify the customization ID (GUID) of a custom language model that
150+
is to be used with the recognition request. Do not specify both parameters with a
151+
request.
144152
:param dict headers: A `dict` containing the request headers
145153
:return: A `dict` containing the `SpeechRecognitionResults` response.
146154
:rtype: dict
@@ -178,7 +186,8 @@ def recognize_using_websocket(self,
178186
'customization_id': customization_id,
179187
'acoustic_customization_id': acoustic_customization_id,
180188
'customization_weight': customization_weight,
181-
'base_model_version': base_model_version
189+
'base_model_version': base_model_version,
190+
'language_customization_id': language_customization_id,
182191
}
183192
params = _remove_null_values(params)
184193
url += '/v1/recognize?{0}'.format(urlencode(params))

0 commit comments

Comments
 (0)