From 8f446aac1f766a9f87d86ce3d834d28201d8b5ea Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Mon, 14 Nov 2016 11:37:19 -0800 Subject: [PATCH] Adding BASE and NMT constants for translation. --- system_tests/translate.py | 2 +- translate/google/cloud/translate/__init__.py | 2 ++ translate/google/cloud/translate/client.py | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/system_tests/translate.py b/system_tests/translate.py index 6ef78b0f0b95..402be16399be 100644 --- a/system_tests/translate.py +++ b/system_tests/translate.py @@ -56,7 +56,7 @@ def test_translate(self): values = ['hvala ti', 'dankon', 'Me llamo Jeff', 'My name is Jeff'] translations = Config.CLIENT.translate( - values, target_language='de', model='nmt') + values, target_language='de', model=translate.NMT) self.assertEqual(len(values), len(translations)) self.assertEqual( diff --git a/translate/google/cloud/translate/__init__.py b/translate/google/cloud/translate/__init__.py index c58b22301ee5..83ff5f114435 100644 --- a/translate/google/cloud/translate/__init__.py +++ b/translate/google/cloud/translate/__init__.py @@ -14,5 +14,7 @@ """Google Cloud Translate API wrapper.""" +from google.cloud.translate.client import BASE from google.cloud.translate.client import Client +from google.cloud.translate.client import NMT from google.cloud.translate.connection import Connection diff --git a/translate/google/cloud/translate/client.py b/translate/google/cloud/translate/client.py index b7fe9142d017..47c692833abf 100644 --- a/translate/google/cloud/translate/client.py +++ b/translate/google/cloud/translate/client.py @@ -26,6 +26,12 @@ ENGLISH_ISO_639 = 'en' """ISO 639-1 language code for English.""" +BASE = 'base' +"""Base translation model.""" + +NMT = 'nmt' +"""Neural Machine Translation model.""" + class Client(BaseClient): """Client to bundle configuration needed for API requests. @@ -194,7 +200,7 @@ def translate(self, values, target_language=None, format_=None, :type model: str :param model: (Optional) The model used to translate the text. The - only accepted values are ``base`` and ``nmt``. + only accepted values are :attr:`BASE` and :attr:`NMT`. :rtype: str or list :returns: A list of dictionaries for each queried value. Each