The cry for justice against issues such as police brutality has inspired cities across the nation to reconsider their priorities. In order for city leaders to respond to citywide issues, there has to be a way for them to quickly understand public opinion. Social media sites, such as Twitter, provide large amounts of data that can be analyzed and then used to shape public policy.

Furthermore, the ability to gauge the opinion of both local and nationwide populations is important not only for public policy, but also to stay informed as a citizen. While tweets are far from the most ideal datasets, they are a genuine expression of people's opinions, have millions of data points to analyze using sentiment analysis, and it's also free. We believe that a careful analysis of data sampled from local, nationwide, and the most trending tweets can reveal much about popular opinion about anything from police brutality to dog pictures.

We think that this technology could have far-reaching implications due its ability to quickly and dynamically assess public opinion. In the age of COVID-19, tweets can often be the only way to express public dissent or approval, since many city halls and gatherings have been closed. In fact, in a study published in May 2020, researchers noticed a sharp, sustained increase in Twitter activity following the months of February and March. City councils have even resorted to public comment through email submissions, forcing city leaders to have to read through unreasonable amounts of content. We propose a solution not to replace, but simply to augment formal public comment through an informal analysis of aggregate data to inform policies ranging from budgets to education.

What it does

The app allows users to enter a zip code of interest and a search query, which is then used to generate sentiment data of local, nationwide, and trending tweets related to the query. Each dataset is then presented in a graph based on the progression of positive/negative/neutral sentiment with time. Furthermore, each dataset can also be compared to each other to see the differences between local, nationwide, and trending opinions.

How we built it

We used the Twitter API To collect tweets from our three filters (geolocation, popularity, random) related to our query and formed three separated datasets to be analyzed. Each dataset is then passed through Google Cloud's Sentiment Analysis API to generate a score between -1 and 1 of the tweets within the dataset. We then calculate the average sentiment of each dataset as well as the percentage of positive and negative tweets. This is then loaded into a JSON file, which is sent back to the frontend. Chart.js then displays this data on different graphs, and we used Google's Firebase Hosting to host the website and Firebase Cloud Functions to store our backend logic.

Challenges we ran into

We ran into issues with Firebase, since we had to learn how to use node for the backend. Furthermore, we also had issues dynamically updating our graph using Chartjs. For some of us, it was also the first time dealing with asynchronous functions and commands in Node.js which caused a lot of confusion. Furthemore, it was challenging dealing with a large amount of data, both in efficiently processing it and storing it for future use.

Accomplishments that we're proud of

None of us had prior experience working with Twitter API, so it was exciting to be able to successfully implement it in this project. We were also able to quickly refactor our backend code from Python to Node in order to use Firebase Cloud Functions. We're also proud of being able to extract useful data from the huge abundance of tweets and opinions online.

What we learned

"I learned how to use Firebase Cloud Functions for backend development" -Priya

"I used Figma for the first time for UI/UX design to demonstrate the application's features and use cases." -Angelina

"Things I did for the first time: working with the Twitter API, programming in Node.js, using an asynchronous function, deploying a firebase app, wow!" - Anthony

What's next for Project Tony

We hope to expand on the data visualization features of our app. Ideally, we would be able to compare local average to national average, display data in different formats, and allow users to choose the timeframe of the data search. The Google Cloud Platform was essential to our project, and we used Google Firebase (Hosting and Cloud Functions) and the Natural Language API. Furthermore, the Twitter API restricts free data to only within the past week, so we could look into powerful analytics with extended access to the Twitter API.

+ 3 more
Share this project: