From e067605a81de3f9960c0ca4183715ecf423799af Mon Sep 17 00:00:00 2001 From: Erika Dsouza Date: Wed, 7 Mar 2018 14:04:54 -0500 Subject: [PATCH] style(python language translator): regenerated service --- .../language_translator_v2.py | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/watson_developer_cloud/language_translator_v2.py b/watson_developer_cloud/language_translator_v2.py index 678f55a55..1613518db 100644 --- a/watson_developer_cloud/language_translator_v2.py +++ b/watson_developer_cloud/language_translator_v2.py @@ -66,7 +66,7 @@ def __init__(self, url=default_url, username=None, password=None): use_vcap_services=True) ######################### - # translate + # Translate ######################### 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): return response ######################### - # identify + # Identify ######################### def identify(self, text): @@ -133,7 +133,7 @@ def list_identifiable_languages(self): return response ######################### - # models + # Models ######################### def create_model(self, @@ -219,9 +219,10 @@ def delete_model(self, model_id): def get_model(self, model_id): """ - Get information about the given translation model, including training status. + Gets information about a translation model, including training status for custom + models. - :param str model_id: Model ID to use. + :param str model_id: Model ID of the model to get. :return: A `dict` containing the `TranslationModel` response. :rtype: dict """ @@ -233,15 +234,19 @@ def get_model(self, model_id): def list_models(self, source=None, target=None, default_models=None): """ - Lists available standard and custom models by source or target language. + Lists available translation models. :param str source: Specify a language code to filter results by source language. :param str target: Specify a language code to filter results by target language. - :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`. + :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`. :return: A `dict` containing the `TranslationModels` response. :rtype: dict """ - params = {'source': source, 'target': target, 'default': default_models} + params = { + 'source': source, + 'target': target, + 'default': default_models + } url = '/v2/models' response = self.request( method='GET', url=url, params=params, accept_json=True) @@ -543,6 +548,8 @@ def __init__(self, translation_output): def _from_dict(cls, _dict): """Initialize a Translation object from a json dictionary.""" args = {} + if 'translation_output' in _dict: + args['translation_output'] = _dict['translation_output'] if 'translation' in _dict: args['translation_output'] = _dict['translation'] else: