paint-brush
DIY Language Translator API using Node.js and IBM Watsonby@shagun.khemka60
1,609 reads
1,609 reads

DIY Language Translator API using Node.js and IBM Watson

by Shagun KhemkaJuly 28th, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Language translator is indeed a good project for <a href="https://hackernoon.com/tagged/learning" target="_blank">learning</a> Natural-Language-Processing. However it takes time and knowledge about understanding those concepts. So how about leveraging Artificial-Intelligence-as-a-Service for language-translations? Sounds good to me as they provide better accuracy and takes less time to set up. In this short DIY tour let’s know about IBM Watson and how to integrate its functionality with <a href="https://hackernoon.com/tagged/node-js" target="_blank">Node.js</a> to create a simple but useful REST API.

Company Mentioned

Mention Thumbnail
featured image - DIY Language Translator API using Node.js and IBM Watson
Shagun Khemka HackerNoon profile picture

Just an overview

Language translator is indeed a good project for learning Natural-Language-Processing. However it takes time and knowledge about understanding those concepts. So how about leveraging Artificial-Intelligence-as-a-Service for language-translations? Sounds good to me as they provide better accuracy and takes less time to set up. In this short DIY tour let’s know about IBM Watson and how to integrate its functionality with Node.js to create a simple but useful REST API.

But what is IBM Watson? Well it’s an IBM supercomputer that combines artificial intelligence (AI) and sophisticated analytical software for optimal performance as a “question answering” machine. Watson API offers large number of functionality most of which are free. In this tour we would use “language-translator/v2” API for language-translation. This API offers free language translation for 6 languages including Arabic, French, Spanish, Portugese and offers conversions to other languages on paid version.

As the theory part is now complete, lets get our hands dirty. Assuming that you are registered in IBM Bluemix, please receive your credentials for language-translation (found under watson services in Bluemix). The credentials would look like this:-

{  "url": "https://gateway.watsonplatform.net/language-translator/api",  "username": "USERNAME",  "password": "PASSWORD"}

Note:- There is also a Github repository named IBM-Bluemix-Docs provided by IBM themselves for more knowledge not just regarding this but also other functions . You can view for Language-Translation https://github.com/IBM-Bluemix-Docs/language-translator/blob/master/getting-started.md

Moving ahead, now its time for some Javascript :)

First it’s a good practice not to store sensitive credentials in our javascript file but instead store it in a “.env” file. Here i have stored my username and password in a .env file and accessing it using dotenv module.

Then using express as our middleware, we create an API Endpoint /api through which we pass our word to be translate.

Note:-es stands for spanish. This can be changed as per your prefered language.

Also do not forget Hosting in order to access this API.

yay!!

Thats it folks!! You just created a Language-Translator by your own without having much knowledge on NLP!!

I hope this article was useful. Please like, recommend, leave a response regarding anything about this project.

Link to the project:-


S2606/Language-Translator_IBMWatson_Language-Translator_IBMWatson - A simple language translator using IBM Watson and nodejs_github.com

P.S:- Hope i haven’t disappointed you.I am a self-learned,passionate programmer who wants to create stuff which have never been heard,seen or thought of. You can see my other projects at https://github.com/S2606, LinkedIn:- https://www.linkedin.com/in/shagun-khemka/