GithubHelp home page GithubHelp logo

kashi97 / twitter-search-sentiment-analysis Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 13 KB

Periodically get the amount of positive and negatives tweets mentioning a specified search term and write the results to a file

Python 100.00%

twitter-search-sentiment-analysis's Introduction

Twitter-Search-Sentiment-Analysis

Gets the amount of positive and negatives tweets mentioning a specified search term and write the results to a file.

Uses tweepy to get the tweets and textblob to perform the sentiment analysis

Can be run once, returning the amount of positive and negative tweets for the search term and amount of tweets

Or run forever in specified intervals and write the results to a file

Dependencies

Python 3 is recommended

Installation:

pip install requirements.txt 

Usage

The program can be from the command terminal.

For it to work, consumer_key, consumer_secret, access_token and access_token_secret must be added to "keys.txt"

python3 TwitterSent.py --search %SearchTerm% --interval %IntervalMinutes% --amount %ResultAmount% --filename %PathToResultFile%  

For example, the following command will get the 50 most recent tweets mentioning "Apples" and write the amount of positive and negative tweets to the file "output.txt". It will do this every 30 minutes until the program is stopped.

python3 TwitterSent.py —search Apples —interval 30 --amount 50 --filename output.txt  

Parameters:

Parameter Flag Description
Search term --search The keyword/string that is searched for on twitter
Run interval (minutes) --interval The amount of minutes the program waits before running again after the first time
Amount of tweets --amount How many tweets it gathers and performs sentiment analysis on
Output filename --filename The filename of the file which contains the time and results from each run. It will be created if it does not already exist

It can also be used a package. Example in example.py

>>> from TwitterSent import TwitterSentiments
>>> tw = TwitterSentiments(consumer_key=consumer_key, consumer_secret=consumer_secret,
                       access_token=access_token, access_token_secret=access_token_secret)
>>> positive_sentiments, negative_sentiments = tw.run(searchTerm="Test search", amount=100)

twitter-search-sentiment-analysis's People

Contributors

kashi97 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.