Modeling Guide

Tweet Sentiment With Histogram

This graph analyses the sentiment of tweets and then makes a histogram of their polarity, which range between -1 and 1.

First, the Tweet Stream operator is used to send a message to the Sentiment Analyser operator. The message's body field contains the text of the tweet and the attributes contain metadata about the tweet. The Sentiment Analyser will then add two sentiment measures to the attributes field of the message: polarity and subjectivity. The resulting message is then copied to two different branches of the pipeline.

In the upper branch, the polarity value is extracted from the attributes field and then sent to the Histogram operator. The Histogram operator then sends the histogram of all the values received so far to its output port as an array of uint64. This array is then fed into the Histogram Plotter operator which has a UI to represent the received array graphically.

The lower branch just prints the message outputted by the Sentiment Analyser into the Terminal operator, but with all attributes fields removed from the message, except for polarity, id_str, and created_at.


The following configuration fields are required to run the graph:
  • accessToken, accessTokenSecret, consumerKey, and consumerSecret.

Those can be obtained by creating an app in Application ManagementInformation published on non-SAP site and accessing the "Keys and Access Tokens" section in the app management page.