Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeffhollan/twitter-streaming-app
https://github.com/jeffhollan/twitter-streaming-app
Last synced: 3 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jeffhollan/twitter-streaming-app
- Owner: jeffhollan
- Created: 2016-10-17T17:44:27.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-10-17T17:46:34.000Z (over 8 years ago)
- Last Synced: 2025-01-23T00:45:11.305Z (5 days ago)
- Language: C#
- Size: 13.7 KB
- Stars: 0
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This wiki will guide you through the Twitter Sentiment Analysis sample. Consider the scenario below:
##Scenario:
A news media website is interested in getting an edge over its competitors by featuring site content that is immediately relevant to its readers. They use social media analysis on topics relevant to their readers by doing real time sentiment analysis on Twitter data. Specifically, to identify what topics are trending in real time on Twitter, they need real-time analytics about the tweet volume and sentiment for key topics.
###Pre-Req:
* Visual Studio
* Azure Subscription
* Twitter AccountRunning the generator code and setting up the Stream Analytics job is very simple.
This sample contains an event generator which uses Twitter API to get tweet events. Application parses tweets for parameterized keywords (Azure,Microsoft,Seattle, etc.) and uses open source Sentiment140 to add sentiment score to tweet events. To run the sample you will need to first create an EventHub and configure the App.config with its connection string.
You can then create a Stream Analytics Job. Configure the input to point to the EventHub your have created. In the Query Window you can copy and paste the Query below:
``` SQL
SELECT Topic,count(*) AS Count, Avg(SentimentScore) AS AvgSentiment,
System.Timestamp AS Insert_Time
FROM TwitterInput TIMESTAMP BY CreatedAt
GROUP BY TumblingWindow(second,5), Topic
```
There are several ways to see the output. You can check our [samples guide](https://azure.microsoft.com/en-us/documentation/articles/stream-analytics-twitter-sentiment-analysis-trends/) for details. To see the output in a SQL table, you will need to create a SQL table with the command below and configure a SQL output for your ASA job to point to the database you have created.
In Azure DB, create a SQL Database:
``` SQL
CREATE DATABASE TwitterDemo
GO
```Then create a table with the schema below:
``` SQL
USE [TweetCount]
GOSET ANSI_NULLS ON
GOSET QUOTED_IDENTIFIER ON
GOCREATE TABLE [dbo].[TweetCount](
[Id] [bigint] IDENTITY(1,1) NOT NULL,
[Topic] [nvarchar](128) NULL,
[Count] [int] NULL,
[AvgSentiment] [float] NULL,
[Insert_Time] [datetime2](6) NULL,
CONSTRAINT [PK_TweetCount] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
)GO
```Please note: This sample code calls the Twitter API, which is provided by Twitter, Inc. and not by Microsoft, to obtain tweets. Your use of the Twitter API is governed by your agreement(s) with Twitter, Inc. This sample code also calls the API from Sentiment140 (www.sentiment140.com), which is not affiliated with Microsoft, to discover the sentiment of tweets. Your use of the Sentiment140 API is governed by any terms imposed on your use by the owners of the Sentiment140 API.