In this blog series we’ll be experimenting with the most interesting blends of data and tools. Whether it’s mixing traditional sources with modern data lakes, open-source devops on the cloud with protected internal legacy tools, SQL with noSQL, web-wisdom-of-the-crowd with in-house handwritten notes, or IoT sensor data with idle chatting, we’re curious to find out: will they blend? Want to find out what happens when IBM Watson meets Google News, Hadoop Hive meets Excel, R meets Python, or MS Word meets MongoDB?
Follow us here and send us your ideas for the next data blending challenge you’d like to see at firstname.lastname@example.org.
Today: Finnish meets Italian and Portuguese through the Google Translate API. Preventing weather from getting lost in translation
Authors: Heather Fyson & Phil Winters
Talking about the weather isn’t just a British pastime. Everyone does it. Especially when they’re about to go on holiday.
Winter & Sun Travel organizes a diverse range of holidays for people, sending them to different destinations all over the world.
To make sure the weather doesn’t get lost in translation, they use KNIME Analytics Platform and Google Translate! Winter & Sun, a UK-based company, has put together a list of weather terms in English which they use as a base to translate into both the customer’s native language and the language spoken at their holiday destination. The weather terms - translated specifically to suit each customer’s language pair - are then put together in a small report the customer can take on holiday and refer to whenever they need to.
Three sets of customers have just booked holidays with Winter & Sun Travel:
The Hämäläinen Family from Finland are desperate to find sun and light and are off to Procida, Italy for a beach holiday.
Amanda and Mário from the Amazonas (one of the world’s least windy regions) in Brazil want to go to Sylt, Germany for some kitesurfing.
The Browns from Yuma in Arizona, US are escaping the hot desert for some skiing in France.
- Get a Google API key enabled for the Google Translate service from the Google API Console. Here is some help on how to obtain a Google API key. To understand how to use the Google Translate URL, which options are available, and how to append the API key, check the Google Translate API instructions.
- Winter & Sun put together a table of terms in English that would suit these three different types of holiday.
In the same table, they also entered language codes for the required translations, each time going from English into an “Original” and a “Final” language. A complete list of Google API Translation codes is available here: https://cloud.google.com/translate/docs/languages
In the KNIME workflow, a Table Creator node is introduced to host this translation map.
Figure 1. Translation Map including term in English (spoken by the agency), original language (in the touristic location), and final language (spoken by the travelers)
- Since Google API doesn’t know what to do with an “English to English” translation, if English is required as final language, those rows are split out and not translated via a Row Splitter node.
- In the following String Manipulation node, Google Translate Requests are built that combine their Google API Key along with the required options.
- The GET Request node calls Google Translate service, translates the terms – into Finnish and Italian for Hämäläinens, into Brazilian and German for Amanda and Mario and into French for the Browns from Arizona. The request is actually submitted once for each row in the input table.
- The result from each request to the Google Translate API comes back as JSON statement appended to each row. The JSON structure is then broken down into its parts with the JSON to Table node and only those columns that are of interest are kept.
- The English terms, that skipped translation, are added to the end of the table so that we have a complete set of translated terms.
- Finally, some cleanup is performed to be able to transfer everything to BIRT, creating the final report for each family.
Figure 2. The Winter & Sun translation workflow accessing the Google Translate API service. This workflow is available on the KNIME EXAMPLES server at 01_Data_Access/05_REST_Web_Services/07_Translate_Using_Google_API01_Data_Access/05_REST_Web_Services/07_Translate_Using_Google_API*.
Using the translated results, Winter & Sun Travel are able to produce weather cards for their customers, quickly and automatically, personalized into the respective languages. All they need is KNIME Analytics Platform and an account for Google Translate.
If you want to try this out, you can access this workflow through the KNIME EXAMPLES server at 01_Data_Access/05_REST_Web_Services/07_Translate_Using_Google_API01_Data_Access/05_REST_Web_Services/07_Translate_Using_Google_API*. Just enter your own Google API key enabled for the Google Translate service.
And Bob’s your uncle / fertig ist der Lack / Le tour est joué / se on siinä / aí está!
Figure 3. Weather Card by Winter & Sun Travel agency for the Brown family, created with the workflow hosted on the KNIME EXAMPLES server at 01_Data_Access/05_REST_Web_Services/07_Translate_Using_Google_API01_Data_Access/05_REST_Web_Services/07_Translate_Using_Google_API*.
If you would like to know more about KNIME Analytics Platform – we have courses coming up in Austin, US and Berlin, DE in November. Find out more here. https://www.knime.org/course
Coming Next …
If you enjoyed this, please share this generously and let us know your ideas for future blends.
We’re looking forward to the next challenge. What about SparkSQl and HiveQL? Will they blend?
* The link will open the workflow directly in KNIME Analytics Platform (requirements: Windows; KNIME Analytics Platform must be installed with the Installer version 3.2.0 or higher)