Skip to main content Skip to complementary content

Sentiment140

The Qlik Sentiment140 connector uses the Sentiment140 API to classify short strings, such as Tweets, into positive, neutral, or negative sentiment categories. The classification score is represented by a number: 1 (positive), 0 (neutral), or -1 (negative). The score is determined by keywords that appear in the text.

Information note

In previous versions of the Qlik Web Connectors, the Sentiment140 API was accessible through the Sentiment and Text Analytics Connector.

Supported offerings

  • Qlik Sense Desktop
  • Qlik Sense Enterprise on Windows
  • QlikView

This connector must be installed separately.

Ways to access your data

To access the Sentiment140 API to retrieve a sentiment score for your data, you can manually enter your text into the connector but this is not an effective way to analyze a large number of short strings. We recommend that you use one of the methods below to quickly analyze a large number of strings. See, Analyzing text.

Loading data from tables

Use the following table to fetch sentiment scores from your text strings.

Tables that can be loaded
Table Description
Sentiment Use this table to fetch sentiment scores for text strings.
Information noteSentiment140 API supports English and Spanish. English is the default language.

Analyzing text

The most effective way to use the Sentiment140 connector is to have a script pass rows of data to the Sentimen140 API to generate a new table with sentiment scores.

Using method

Use this method to make multiple Qlik Web Connectors requests without requiring a For/Next loop. This method does not require any URL encoding. More information about the processParams method can be found here, Making data request with synchronous, asynchronous, batch, and auto mode.

Using a For/Next loop with URL encoded text

Example:  

Information noteIn the above script the table name Sentiment contains the sentiment API being used.

Peek - script function

NoOfRows - chart function

Using a For/Next loop with text that is not URL encoded

If you are using text data from a source which is not already URL encoded, you can write a script that encodes the text before sending it to the sentiment analyzer like the following example.

Sub urlEncode(str)   let str=replace(str, '%', '%25'); // should be first let str=replace(str, '#', '%23'); let str=replace(str, ' ', '%20'); let str=replace(str, '$', '%24'); let str=replace(str, '&', '%26'); let str=replace(str, '+', '%2B'); let str=replace(str, ',', '%2C'); let str=replace(str, '/', '%2F'); let str=replace(str, '\', '%5C'); let str=replace(str, ':', '%3A'); let str=replace(str, ';', '%3B'); let str=replace(str, '=', '%3D'); let str=replace(str, '?', '%3F'); let str=replace(str, '@', '%40'); let str=replace(str, '[', '%5B'); let str=replace(str, ']', '%5D'); let str=replace(str, '>', '%3E'); let str=replace(str, '<', '%3C'); let str=replace(str, chr(10), '%0A'); // Line feed. let str=replace(str, chr(39), '%27'); // 39 Apostrophe   call=str;   End sub   LET noRows = NoOfRows('Timeline');   for i=0 to $(noRows)-1   let text = peek('text', $(i), 'Timeline'); let textEncoded = text; call urlEncode(textEncoded);   Sentiment140Connector_Sentiment: LOAD '$(text)' as text, // Use this if you want to link your table on the text status as sentiment_status, score as sentiment_score FROM [http://localhost:5555/data?connectorID=TextAnalyser_Sentiment140Connector&table=Sentiment&text=$(textNotEncoded)&Language=en&appID=&loadAccessToken=1h7jh3i6h3o7k] (qvx); next
Information note URL encoding should be done using UTF-8.

Caching

The sentiment analyzer caches the sentiment scores. If you want to clear the cache, follow the instructions on this web page:

Clearing the Qlik Web Connectors cache

Backing Up The Cache

The cache will grow to a considerable size and retrieving items from the cache will be significantly faster than accessing the sentiment API. For this reason it is recommended that you take regular backups of this cache so that it can be restored if necessary.

By default the cache can be found at the following location:

[INSTALLATION_DIR]\[Web_connector_folder]\App_Data\[USER_GUID]\TextAnalyser_Sentiment140Connector_Cache

Working with the Sentiment140 API quota limits

The Qlik Web Connectors use the Sentiment140 API to fetch sentiment data from Sentiment140 and load it into your Qlik Sense app. While reloading you Sentiment140-based app, you might receive an error message that the connector has reached the Sentiment140 API rate limit and that all subsequent API calls will fail until the connector falls back under the throttling limit. If you receive this error message, then you have exceeded one of the API rate limits.

You receive an error message that you have reached the API rate limit

Reference - Sentiment140 developer documentation

You can refer to the Sentiment140 API documentation to learn more about the different ways to use the Sentiment140 API.

Troubleshooting

You receive an error message that you have reached the API rate limit

Possible cause  

You have exceeded the API limits that are imposed on the Qlik Web Connectors by the Sentiment140 API.

Proposed action  

To reduce the impact of reaching the API rate limits, develop your app with the following in mind:

  • Extract only the data you need.
  • Reload one Sentiment140-based application at a time.
  • Ensure that loops in your script that make API calls will not result in infinite loops.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!