https://github.com/definazu/tweetmoodvisualizer
This program is the solution of the first laboratory work on OOP in the 4th term of the Yanka Kupala State Uneversity of Grodno
https://github.com/definazu/tweetmoodvisualizer
docker docker-compose docker-container dockerfile flask python react typescript
Last synced: 2 months ago
JSON representation
This program is the solution of the first laboratory work on OOP in the 4th term of the Yanka Kupala State Uneversity of Grodno
- Host: GitHub
- URL: https://github.com/definazu/tweetmoodvisualizer
- Owner: Definazu
- License: mit
- Created: 2025-02-23T14:05:52.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-23T16:14:07.000Z (over 1 year ago)
- Last Synced: 2025-02-23T16:19:19.917Z (over 1 year ago)
- Topics: docker, docker-compose, docker-container, dockerfile, flask, python, react, typescript
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TweetMoodVisualizer
## Description
This program is the solution of the first laboratory work on OOP in the 4th term of the Yanka Kupala State Uneversity of Grodno.
## Table of content
1. [Problem Requiments](https://github.com/Definazu/TweetMoodVisualizer#problem-requiments)
a. [Input data](https://github.com/Definazu/TweetMoodVisualizer#input-data)
b. [Phase 1. The feelings in tweets](https://github.com/Definazu/TweetMoodVisualizer#phase-1-the-feelings-in-tweets)
c. [Phase 2. The mood of the nation](https://github.com/Definazu/TweetMoodVisualizer#phase-2-the-mood-of-the-nation)
2. [Project Stack](https://github.com/Definazu/TweetMoodVisualizer#project-stack)
3. [Description of microservices](https://github.com/Definazu/TweetMoodVisualizer#description-of-microservices)
a. [TweetCollectionService](https://github.com/Definazu/TweetMoodVisualizer#tweetcollectionservice)
b. [SentimentalAnalysisService](https://github.com/Definazu/TweetMoodVisualizer#sentimentalanalysisservice)
c. [Client](https://github.com/Definazu/TweetMoodVisualizer#client)
4. [Installation](https://github.com/Definazu/TweetMoodVisualizer#installation)
## Problem Requiments
In this project, you will develop a visualization of twitter data across the USA. The map displayed below depicts how the people in different states feel about California.
This image is generated by:
1. Collecting public Twitter posts (Tweets) that have been tagged with geographic locations and
filtering for those that contain the «cali» query term.
2. Assigning a sentiment (positive or negative) to each Tweet, based on all of the words it
contains.
3. Aggregating Tweets by the state with the closest geographic center, and finally
4. Coloring each state according to the aggregate sentiment of its Tweets. Yellow means
positive sentiment; blue means negative.
The details of how to conduct each of these steps is contained within the project description.
By the end of this project, you will be able to map the sentiment of any word or phrase.
### Input data
The **Data** directory contains all the data files needed for the project, and it's necessary to run the project. Each file in this folder (cali_tweets2014.txt, family_tweets2014.txt, football_tweets2014.txt, movie_tweets2014.txt, ...) contains collection of tweets on a related topic: California, family, football, movies, ...
The **Images** directory contains the correct maps that your program should produce by the end of the project for the given terms.
Every tweet is represented as following: the latitude of the tweet's location, the longitude of the tweet's location, date and time when the tweet was posted, the text of the tweet.
Some words of the tweet are associated with positive or negative sentiment, but most are not. The sentiment of some individual words can be found in the __Data/sentiments.csv__ text file.
Json file __Data/states.json__ contains data on geographical location of each U.S. state. Each state is keyed by its two-letter postal code (WA, FL, HI) and the shape. The shape of a state is represented as a list of polygons. Some states (e.g. Hawaii) consist of multiple polygons, but most states (e.g. Colorado) consist of only one polygon (represented as a length-one list of polygons).
### Phase 1: The Feelings in Tweets
In this phase, you have to split the text of a tweet into words, and calculate the amount of positive or negative feeling in a tweet.
#### Problem 1.
Before we can analyze the feelings in tweets, we need to access its words. You have to extract words from tweet. Assume that a word is any consecutive substring of text that consists only of letters.
#### Problem 2.
Analyze tweet sentiment: take a tweet and return a single number averaging the weights of sentiment-carrying words in the tweet, or None if none of the words in the tweet carry a sentiment weight.
### Phase 2: The Mood of the Nation
In this phase, you will determine the state that a tweet is coming from, group tweets by state, and calculate the average positive or negative feeling in all the tweets associated with a state.
#### Problem 3.
Implement function which returns the two-letter postal code of the state that is closest to the location of a tweet.
#### Problem 4.
Group tweets by state. Take a list of all tweets and return a dictionary. The keys of the returned dictionary are state postal codes, and the values are lists of tweets that appear closer to that state's center than any other.
#### Problem 5.
Implement calculate_average_sentiments. This function takes the dictionary returned by group_tweets_by_state and also returns a dictionary. The keys of the returned dictionary are the state names (two-letter postal codes), and the values are average sentiment values for all the tweets in that state.
If a state has no tweets with sentiment values, leave it out of the dictionary entirely. Do not include states with no tweets, or with tweets that have no sentiment, with a zero sentiment value. Zero represents neutral sentiment, not unknown sentiment. States with unknown sentiment will appear gray, while states with neutral sentiment will appear white.
#### Problem 6.
You should now be able to draw maps that are colored by sentiment corresponding to tweets that contain a given term. The correct map for «cali» appears at the top of this document.
## Project Stack
* Flask (API)
* React + Vite
* SQLite3
* Docker
## Description of microservices
### TweetCollectionService
#### Functions:
- Collecting/reading tweets
- Writing to database
#### Technologes:
- Pyhton
- Flask
- SQLAlchemy
### SentimentalAnalysisService
#### Functions:
- Text processing of tweets and sentiment analysis (positive or negative)
- Calculating the average sentiment value by state
- Storing and sharing sentiment data from tweets
#### Technologes:
- Python
- Flask
- SQLAlchemy
- Shapely
- JSON
### Client
#### Functions:
- Interaction with microservices
- Map display
#### Technologes:
- React
- Vite
## Installation
1. `Install git repository`
```
$ git clone https://github.com/Definazu/TweetMoodVisualizer.git
```
2. `Run Docker Compose` (Docker must be installed beforehand)
* For Linux (ArchLinux)
```
$ cd TweetMoodVisualizer
$ docker-compose up --build
```
* For Windows
```
$ cd TweetMoodVisualizer
$ docker compose up --build
```
3. After launching the docker you can go to the link localhost:5173 in your browser.
4. `To shut down` the project, write in the console
* For Linux (ArchLinux)
```
$ docker-compose down -v
```
* For Windows
```
$ docker compose down -v
```