Git Product home page Git Product logo

trumpy-news's Introduction

Trumpy News

A simple flask app that combines Tump's tweets and related CNN articles.

The differential

I decided to do some sentiment analysis on the messages. I used the nltk library developed by Bird, Steven, Edward Loper and Ewan Klein (2009), Natural Language Processing with Python. O’Reilly Media Inc.

On the left of the card, it is shown the source of that information, whether its from Twitter or CNN. If the model finds it to be negative sentences on average, it's backgound turns red. If positive, green. Neutrals are blank.

Configuring:

This is assuming that you're using bash

  1. Make yourself a virtual environment:
python -m venv .venv

Enter it:

source .venv/bin/activate
  1. Install pip requirements:
pip install -r requirements.txt
  1. Add the environment variables:

    There are 4 variables required to access twitter and one for flask:

    • CKEY Consumer Key
    • CSECRET Consumer Secret
    • ATOKEN Authentication Token
    • TSECRET Token Secret
    • FLASK_APP Required by Flask

You have to get them from https://developer.twitter.com/

export -x FLASK_APP=main.py
export -x CKEY=XX
export -x CSECRET=XX
export -x ATOKEN=XX
export -x TSECRET=XX
  1. That's it.

    Running it:

    gunicorn wsgi
  2. Runtime Configurations

    Let's say you want to tune it a bit, there are a few things that come to mind:

    • cnn.py The constructor has the following signature:

          def __init__(self, article_class, feeds = [], search_terms = []):

      feeds is a optional list of RSS urls that are added to the pre-select 3 cnn sources.

      search_terms is another optional argument, takes in strings that, if found in the title or summary, considers the article as related to Trump.

    • twitter.py

          def __init__(self, article_class, twitter_account = 25073877):

      The optional argument twitter_account is the twitter id of the desired user whose tweets will be queried. Defaults to @realDonaldtrump.

trumpy-news's People

Contributors

hydrocat avatar

Watchers

James Cloos avatar  avatar

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.