Giter VIP home page Giter VIP logo

it-pulse's Introduction

dependencies

Twitter Sentiments

Introduction

This Node.js project is an exploration of data stream processing. The goal is to exploit a third-party web service and perform analytics on the data stream. The Twitter streaming API is used to perform a basic sentiment analysis on a stream of tweets.

Dependencies

The project uses various other projects including Express.js, socket.io, Jade, and jQuery. In addition, the Node.js package Node-Twitter node-twitter has also been incorporated for easily connecting to the Twitter stream. Bootstrap and jQuery JavaScript and CSS dependencies should be put in pulic/javascripts and public/stylesheets respectively. You can put these files into their respective folders, or you can use symbolic links. However, the application expects jquery.min.js and bootstrap.min.js to be in the javascripts folder, as well as bootstrap.min.css and bootstrap-theme.min.css to be in the stylesheets folder.

Sentiment Analysis

The application will connect to the Twitter streaming API and filter tweets with the words 'love' or 'hate'. It will count and determine the percentage of tweets seen which contain these keywords, and it will also display the total number of tweets analyzed. If a tweet contains both words, then that tweet is added to the total count twice, so that the love and hate percentages will add up to 100%.

Source File Structure

The project file structure was created using Express.js web framework. The server code is found in app.js, while the client-side JavaScript code is in client.socket.io.js. Jade view templates are located in the views folder. The routes folder defines HTTP routing, but it is not really used in this project.

Running the Application

The main application is located in app.js, and it requires four environment variables to be set before running:

  • TWITTER_CONSUMER_KEY
  • TWITTER_CONSUMER_SECRET
  • TWITTER_ACCESS_TOKEN
  • TWITTER_ACCESS_SECRET

These are provided when you register an application for use with the Twitter API.

In addition to the Twitter key requirements, a Node.js environment is also required to install packages and run the app.js server source, but creating this environment is beyond the scope of this project.

Once the environment is set up, assuming you are using a terminal in the folder where app.js is located, you can install Node.js dependencies using:

$ npm install

Then, you can run the application using:

$ node app.js

This will launch the server, and tweets will begin streaming in and printing to the console. The server will listen for connections on port 3000, and on the client side, you may navigate to http://localhost:3000 in a web browser. This will display the sentiment analysis percentages and the total number of tweets seen since server start-up.

To close the server in a terminal, use CTRL-C.

it-pulse's People

Contributors

losmescaleros avatar ulisesgascon avatar

Watchers

James Cloos avatar  avatar

Forkers

davher890

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.