Skip to content

Repository files navigation

CircleCI

Sentiment Analysis on Tweets

A Flask application where we can enter hashtags and keywords related to tweets we want to stream and in which an NLP model, FinBERT which is a pre-trained NLP model to analyze the sentiment of the financial text, does sentiment analysis on the tweets in real-time. We can see the results of the tweets collected containing the hashtags or keywords and their sentiment scores given by FinBERT via Pandas dataFrame.

How to use

  1. Clone this repository to your local.

    git clone https://github.com/boblef/twitter_sentiment.git
    
  2. Create a Twitter developer account
    In order to run the Flask application, we need to create a Twitter developer account.

  3. Set up the cinfig file
    Once you have created a developer account, the next thing you need to do is to set up the config file. Copy twitter.txt and put it into the config folder with the information you need to set up. What you need is as follows:

    • API KEY
    • SECRET API KEY

    APIKEYS

    • ACCESS TOKEN
    • SECRET ACCESS TOKEN

    TOKENS


    Copy all of them from your Twitter developer dashboard and paste them to config/twitter.txt

    Twitter_config

  4. Set up the environment, and run the application
    You can set up the environment in which we run the Flask application either by using Docker or by creating a conda or pip env by yourself.

  • Docker Build a container
    docker build -t twitter_sentiment:latest .
    
    Run the image
    docker run -d -p 5000:5000 twitter_sentiment:latest
    
    Open up your browser, and copy and paste the link below. The application is supposed to start.
    http://localhost:5000/
    
  • Conda Create a conda env whose name is going to be finbert
    conda env create -f environment.yml
    
    Activate the conda env you just created
    source activate finbert
    or
    conda activate finbert
    
    Run the application
    python app.py
    

Further Work

  • Some of the functionality used in this application can also be used in the Automated Forex Trading Strategy which I have been working on in order to create new features.
  • We change the Deep Learning model which gives sentiment scores to tweets to another NLP model which trained on different dataset, if we want to switch the domain we want to use for.

Reference

About

A Flask application of Twitter sentiment analysis by using FinBERT, which is a pre-trained NLP model trained on the financial corpus.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages