API Client


Tasks related to translating data with the google translation API


Returns a Google translation client based on credentials stored in a Google credential json file


json_credential_path (str) – path to the google credential json file

Return type



A Google Translate Client

tamr_toolbox.enrichment.api_client.google.translate(phrases_to_translate, client, *, source_language='auto', target_language='en', translation_model='nmt', num_of_tries=4)[source]

Translate a list of text to a target language using google’s translation api

  • phrases_to_translate (List[str]) – list of phrases to translate from the source language to the target language

  • client (Client) – location of the credentials JSON read by the google_api client

  • source_language (str) – the language the text to translate is in, “auto” means the api_client google_api api_client will try to detect the source language automatically

  • target_language (str) – the language to translate into

  • translation_model (str) – google_api api_client api_client model to use, “nmt” or “pbmt”. Choose “pbmt” if an “nmt” model doesn’t exists for your source to target language pair

  • num_of_tries (int) – number of times to try to translate if the translation call fails

Return type

Optional[Dict[str, TranslationDictionary]]


A toolbox translation dictionary. None if the translation failed