Book Image

Cognitive Computing with IBM Watson

By : Rob High, Tanmay Bakshi
Book Image

Cognitive Computing with IBM Watson

By: Rob High, Tanmay Bakshi

Overview of this book

Cognitive computing is rapidly becoming a part of every aspect of our lives through data science, machine learning (ML), and artificial intelligence (AI). It allows computing systems to learn and keep on improving as the amount of data in the system increases. This book introduces you to a whole new paradigm of computing – a paradigm that is totally different from the conventional computing of the Information Age. You will learn the concepts of ML, deep learning (DL), neural networks, and AI with the help of IBM Watson APIs. This book will help you build your own applications to understand, and solve problems, and analyze them as per your needs. You will explore various domains of cognitive computing, such as NLP, voice processing, computer vision, emotion analytics, and conversational systems. Equipped with the knowledge of machine learning concepts, how computers do their magic, and the applications of these concepts, you’ll be able to research and apply cognitive computing in your projects.
Table of Contents (16 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Translating between languages with Language Translator


To start, provision a new Language Translator service instance. Once that's done, head over to your favorite text editor, open up a new Python file, and let's get coding:

  1. Import the service:
from watson_developer_cloud import LanguageTranslatorV3
  1. Initialize the API:
language_translator = LanguageTranslatorV3(version=“2018-05-01”, iam_apikey=“rvE894AVGJQ_t_ZNuUoQrclWWQwvpFB0_78jr9pvtjIl”)

Of course, you should use your own API Key.

  1. We just need to translate and get our result! But let's make it a bit prettier, and create a command-line interface for it:
print “Enter a sentence in English:”
eng_sent = raw_input()
translation = language_translator.translate(text=eng_sent, model_id=“en-fr”).get_result()[“translations”][0][“translation”]
print “Your sentence in French is:\n” + translation
  1. Run your code, and let's see some output:
Enter a sentence in English:
My name is Frank Felix
Your sentence in French is:
Je m'appelle Frank Felix

Enter a sentence...