This script was created to build a database that can be used with tweet-dataset-creator-api and tweet-dataset-creator-client.
The purpose of the three projects is to create a colaborative dataset of tweets categorized by emotions. The responsabilities of each project's part are:
-
fetch-tweets-to-mongodb: Fetch tweets to create the initial database containing tweets that will be classified by real people.
-
tweet-dataset-creator-api: This acts as a end-point to the database previously created. Provide an interface to retrieve a tweet from the database and a way to evaluate a tweet as negative, neutral or positive.
-
tweet-dataset-creator-client: Is a client that consumes the previous api providing a friendly web page where users can evaluate tweets.
- A mongodb database running. I used a free account at https://cloud.mongodb.com/user to this.
- A developer twitter app registered at https://developer.twitter.com/en/apps.
- Create a
credentials.py
file following the estructure of credentials.example.py in src folder replacing'your*'
strings with your own credentials:
# mongo url
mongo_url = 'your_mongo_connection_url_with_user_and_pass'
# twitter autentication stuffs
t_consumer_key = 'your_twitter_consumer_key'
t_consumer_secret = 'your_twitter_consumer_secret'
t_access_token = 'your_twitter_acces_token'
t_access_token_secret = 'your_twitter_acces_token_secret'
- Install requirements with:
pip3 install --upgrade pip -r requirements.txt
-
In search-terms file you need to put the search terms you want to retrieve tweets about.
-
Run the commands:
python src/fetch-tweets-by-searchterm.py
- Run the commands:
python src/generate-csv.py