API Client¶
Google¶
Tasks related to translating data with the google translation API
-
tamr_toolbox.enrichment.api_client.google.
translation_client_from_json
(json_credential_path)[source]¶ Returns a Google translation client based on credentials stored in a Google credential json file
- Parameters
json_credential_path (
str
) – path to the google credential json file- Return type
Client
- Returns
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
- Parameters
phrases_to_translate (
List
[str
]) – list of phrases to translate from the source language to the target languageclient (
Client
) – location of the credentials JSON read by the google_api clientsource_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 automaticallytarget_language (
str
) – the language to translate intotranslation_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 pairnum_of_tries (
int
) – number of times to try to translate if the translation call fails
- Return type
- Returns
A toolbox translation dictionary. None if the translation failed