DIY Language Translator API using Node.js and IBM Watson

Shagun Khemka
HackerNoon.com
2 min readJul 29, 2017

--

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:-

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:-

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/

--

--