Skip to content

Commit b705442

Browse files
Merge pull request #387 from watson-developer-cloud/codegen/language-translator
Regenerate language translator
2 parents c3812e3 + e067605 commit b705442

1 file changed

Lines changed: 15 additions & 8 deletions

File tree

watson_developer_cloud/language_translator_v2.py

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(self, url=default_url, username=None, password=None):
6666
use_vcap_services=True)
6767

6868
#########################
69-
# translate
69+
# Translate
7070
#########################
7171

7272
def translate(self, text, model_id=None, source=None, target=None):
@@ -94,7 +94,7 @@ def translate(self, text, model_id=None, source=None, target=None):
9494
return response
9595

9696
#########################
97-
# identify
97+
# Identify
9898
#########################
9999

100100
def identify(self, text):
@@ -133,7 +133,7 @@ def list_identifiable_languages(self):
133133
return response
134134

135135
#########################
136-
# models
136+
# Models
137137
#########################
138138

139139
def create_model(self,
@@ -219,9 +219,10 @@ def delete_model(self, model_id):
219219

220220
def get_model(self, model_id):
221221
"""
222-
Get information about the given translation model, including training status.
222+
Gets information about a translation model, including training status for custom
223+
models.
223224
224-
:param str model_id: Model ID to use.
225+
:param str model_id: Model ID of the model to get.
225226
:return: A `dict` containing the `TranslationModel` response.
226227
:rtype: dict
227228
"""
@@ -233,15 +234,19 @@ def get_model(self, model_id):
233234

234235
def list_models(self, source=None, target=None, default_models=None):
235236
"""
236-
Lists available standard and custom models by source or target language.
237+
Lists available translation models.
237238
238239
:param str source: Specify a language code to filter results by source language.
239240
:param str target: Specify a language code to filter results by target language.
240-
:param bool default_models: If the default_models parameter isn't specified, the service will return all models (default_models and non-default_models) for each language pair. To return only default_models models, set this to `true`. To return only non-default_models models, set this to `false`.
241+
:param bool default_models: If the default parameter isn't specified, the service will return all models (default and non-default) for each language pair. To return only default models, set this to `true`. To return only non-default models, set this to `false`.
241242
:return: A `dict` containing the `TranslationModels` response.
242243
:rtype: dict
243244
"""
244-
params = {'source': source, 'target': target, 'default': default_models}
245+
params = {
246+
'source': source,
247+
'target': target,
248+
'default': default_models
249+
}
245250
url = '/v2/models'
246251
response = self.request(
247252
method='GET', url=url, params=params, accept_json=True)
@@ -543,6 +548,8 @@ def __init__(self, translation_output):
543548
def _from_dict(cls, _dict):
544549
"""Initialize a Translation object from a json dictionary."""
545550
args = {}
551+
if 'translation_output' in _dict:
552+
args['translation_output'] = _dict['translation_output']
546553
if 'translation' in _dict:
547554
args['translation_output'] = _dict['translation']
548555
else:

0 commit comments

Comments
 (0)