跳到主要內容 跳至補充內容

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.

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 method below to quickly analyze a large number of strings. See, Analyzing text.

Creating a data source connection

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.

To select and load data from a table, enter the required table parameters and click Preview data. Required parameters are marked with an asterisk (*) in the dialog. The table fields are displayed under the Data preview tab. You can select fields individually by selecting the box beside each field name. Select Insert script after you have made your selection.

Creating a connection and selecting data

資訊備註Sentiment140 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 a For/Next loop

For/next loops are often used to run a large number of API requests with Qlik 網頁連接器. These modes let you extract the maximum performance from Qlik 網頁連接器 and minimize load time of the Qlik Sense application.

For example, if you run a large number of text messages through Sentiment140, it can result in a long load time.

範例: For/next loop

for i=0 to $(noRows)-1   let id = peek('Search_id', $(i), 'Tweets'); let textEncoded = peek('text_urlEncoded', $(i), 'Tweets');   Sentiment: LOAD '$(id)' as Search_id, status as [Sentiment.status], text as [Sentiment.text], score as [Sentiment.score],   SELECT status, text, score FROM Sentiment WITH PROPERTIES ( text='$(textEncoded)', query='', Language='en' );   next

範例:  

Peek - script function

NoOfRows - chart function

Working with the Sentiment140 API quota limits

The Qlik 網頁連接器 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

可能的原因

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

建議的行動

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.

此頁面是否對您有幫助?

若您發現此頁面或其內容有任何問題——錯字、遺漏步驟或技術錯誤——請告知我們可以如何改善!