API Client¶
Google¶
- tamr_toolbox.enrichment.api_client.google_address_validate.get_maps_client(googlemaps_api_key)[source]¶
Get GoogleMaps client.
- Parameters
googlemaps_api_key (
str
) – API key for the Google Maps address validation API- Return type
Client
- Returns
API client linekd to specified key
- tamr_toolbox.enrichment.api_client.google_address_validate.validate(*, address_to_validate, client, locality=None, region_code=None, enable_usps_cass=False)[source]¶
Validate an address using google’s address validation API.
- Parameters
- Return type
- Returns
toolbox address validation mapping, or None if API call fails
- Raises
RuntimeError – if API key is invalid
Tasks related to translating data with the google translation API
- tamr_toolbox.enrichment.api_client.google_translate.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.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