Feedback
External APIs

IBM Watson: Sentiment and Context Analysis

Analyze text to understand and act on sentiment, context, emotion, entity, and language
Back to BLOCKS

About IBM Watson: Sentiment and Context Analysis

AlchemyLanguage from IBM Watson provides a number of APIs for text analysis through natural language processing. The APIs are able to analyze text, and understand a wide variety of characteristics, including sentiment, entity, emotion, keyword, concept tagging, language, and taxonomy.

The IBM Watson Sentiment Analysis block lets you analyze and run functions on your data streams, with all computation taking place in the network. For example, analyze chat messages coming through a customer support app, gauge emotion or detect language, and filter those messages to a specific representative. Your data streams just got way smarter.

Try it Now
Categories:
External APIs External APIs
Chat & Social
Chat & Social
Charting & Graphing
Charting & Graphing
Gaming
Gaming
Last Updated:
20160801 at 17:05:52
Event Handler Author:
PubNub

Walkthrough

The sentiment and context analysis block uses the IBM Watson AlchemyLanguage API to analyze text and execute functions based on the sentiment or emotion of that message. This is done in an after-publish event handler. The sentiment analysis for each message is saved in the PubNub distributed data store. The session sentiment is calculated as an average and is published on an output sentiment channel.

Input

Publish this data on the input channel.
{
    "text"       : "Feeling happy",
    "session_id" : "episode1"
}

Output

The sentiment average is added to the message.
{ 
    "session_id": "episode1",
    "session_sentiment":  {
        "overall": 3.1678750000000004,
        "positive": { 
            "count": 13, 
            "avg": 0.6078368461538461 
        },
        "negative": { 
            "count": 8, 
            "avg": -0.5917505 
        },
        "neutral": { 
            "count": 2, 
            "avg": null 
        }
    }
}

Try PubNub Today

Connect up to 100 devices for Free