Analyzing Text with the AlchemyLanguage Service in IBM Watson

by Stas TurloJuly 29, 2016
This tutorial explains step by step how to use the semantic analysis service on IBM Bluemix.

text-analysis-ibm-bluemix-watson

AlchemyLanguage is a collection of APIs available in IBM Watson for analyzing text through natural language processing. In this post, we show how to create a browser extension that can extract insights—such as concepts, keywords, and emotions—from text on a page.

 

Prerequisites

To get started, you need:

  • an IBM Bluemix account
  • the Cloud Foundry CLI
  • Kango, a cross-browser extension framework

 

How it works

When using AlchemyLanguage, which is a collection of functions for text analysis, you can input text, HTML, or a public URL to get semantic information from content.

Our example is a browser extension and a simple service proxying communication between this extension and the AlchemyLanguage service. The extension adds a button to the browser for analyzing text on the current page and extracting the following information:

  • Concepts. The service will look for concepts with which the input text is associated. It understands how concepts relate and can also identify concepts that are not directly referenced in the text.
  • Emotions. The service is able to identify the overall emotional tone of a page, recognizing anger, disgust, fear, joy, and sadness.
  • Keywords. This information includes important topics that are commonly used when indexing data, generating tag clouds, or searching.

For more details, refer to the IBM Watson documentation.

 

Al training courses

Trying it yourself

The source code for the article is available in our GitHub repository. You can use this link to deploy a demo application to your Bluemix account or follow the steps bellow to deploy it manually:

  1. Clone the repository:
    git clone https://github.com/Altoros/watson-alchemy-demo
  2. Go to the repository directory:
    cd watson-alchemy-demo
  3. Create an application:
    cf push APP_NAME
  4. Create a Personality Insight service instance:
    cf create-service alchemy_api free alchemy_api_svc
  5. Bind the service instance to your application:
    cf bind-service YOUR_APP_NAME alchemy_api_svc
  6. Restage your application:
    cf restage APP_NAME
  7. Update the service URL in the extension sources (extension/src/common/main.js) by replacing watson-alchemy-demo.mybluemix.net with your application URL.
  8. Build the extension:
    python ~/dev/kango/kango.py build extension/

The results of the build process will be located in extension/output/. Refer to your browser documentation on installing extensions.

ibm-bluemix-services

Alternatively, you can create and bind the service instance using the Bluemix dashboard UI.

ibm-bluemix-watson-alchemyapi

Here’s how the demo application works:

text-analysis-ibm-bluemix-watson

Go to the GitHub account to deploy the application to IBM Bluemix.

 

Further reading

Download our AI Basics Cheat Sheet

To stay tuned with the latest updates, subscribe to our blog or follow @altoros.

  •  
  •  
  •