Git Product home page Git Product logo

w205_final_project's Introduction

W205 - School Twitter Stream

Requirements:
Python 2.7+
Postgres (9.5 was used in our case)
Python Dependencies:
tweepy
psycopg2
textblob
json

00. Create database in postgres with:
DB Name: schoolstream
USER: postgres
PASS: pass
PORT: 5432

Sample commands for centos.
$ su - postgres
$ psql
# create database schoolstream;
# \q

In our case, we had to add the option 'template template0' to create the database.

There is a sample database if you do not wish to collect your own twitter data. If you wish to use the sample database, load into the database:
$ psql schoolstream < xx_sample_tweet_database.sql


If you wish to create your own database, follow the below steps:

01. Run 01_twitter_table_schema.sql to create table schema for twitter data recording table.

02. Run 02_schoolstreamtwitter.py to start twitter feed
Python Dependencies:
tweepy
psycopg2
textblob
json

If the recording is a success, you will see the message "Yay!"
If the recording is a failure, you will see the error and the message "Oh no it failed!"
If the recording is a failure, the script will restart.
CTRL + C to break and end the stream.

03. Run 03_generate_schoolpol_table_from_twitter.sql to generate the schoolpol table from the raw twitter data. Then you may start using the serving scripts.

04. Serving Scripts
Inside the serving scripts folder, there are 6 serving scripts. The descriptions of the serving scripts are contained within the project report.

Short description of the serving scripts:
S01. 01_candschoolcount.py
   Description: See how many times candidate comes up at each school
   Input: candidate
   Output: candidate, school, count

S02. 02_toptweetsentment.py
   Description: See the top tweet of X candidate and count by sentiment
   Input: positive or negative, candidate
   Output: candidate, tweet, sentiment, count

S03. 03_toptweetscandschool.py
   Description: See the top tweets for THAT school about X candidate
   Input: candidate, school
   Output: candidate, school, tweet, sentiment, count

S04. 04_schoolcandsentpct.py
   Decription: Show breakdown of candidates + sentiment + count
   Input:  school
   Output: school, candidate, sentiment, count, percentage of candidate's total count

S05. 05_schoolsentpct.py
   Description: Breakdown of a sentiment of a school
   Input: school
   Output: school, sentiment, count, percentage of school's total count

S06. 06_highestsentschoolcand.py
   Description: See which schools have the highest sentiment % for a candidate
   Input: positive or negative, candidate
   Output: candidate, sentiment, school, count, percentage of total sentiment count

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.