{"id":24890608,"url":"https://github.com/trflorian/sentiment-analysis-viz","last_synced_at":"2025-07-08T11:37:07.161Z","repository":{"id":274340227,"uuid":"922608249","full_name":"trflorian/sentiment-analysis-viz","owner":"trflorian","description":"Real-time visualization of sentiment analysis on text input","archived":false,"fork":false,"pushed_at":"2025-05-20T22:06:56.000Z","size":243,"stargazers_count":18,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-20T22:51:41.833Z","etag":null,"topics":["customtkinter","data-science","huggingface","opencv-python","python","sentiment-analysis","tokenizer","transformers"],"latest_commit_sha":null,"homepage":"https://towardsdatascience.com/real-time-interactive-sentiment-analysis-in-python/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/trflorian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-01-26T16:56:44.000Z","updated_at":"2025-05-20T22:06:57.000Z","dependencies_parsed_at":"2025-01-26T18:25:07.846Z","dependency_job_id":"0408f016-f68f-41e5-a658-517ea83ef02a","html_url":"https://github.com/trflorian/sentiment-analysis-viz","commit_stats":null,"previous_names":["trflorian/sentiment-analysis-viz"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/trflorian/sentiment-analysis-viz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trflorian%2Fsentiment-analysis-viz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trflorian%2Fsentiment-analysis-viz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trflorian%2Fsentiment-analysis-viz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trflorian%2Fsentiment-analysis-viz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/trflorian","download_url":"https://codeload.github.com/trflorian/sentiment-analysis-viz/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/trflorian%2Fsentiment-analysis-viz/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264260680,"owners_count":23581049,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["customtkinter","data-science","huggingface","opencv-python","python","sentiment-analysis","tokenizer","transformers"],"created_at":"2025-02-01T17:17:02.708Z","updated_at":"2025-07-08T11:37:07.155Z","avatar_url":"https://github.com/trflorian.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\r\n\u003cdiv align=\"center\"\u003e\r\n\u003ch1\u003e \r\n\r\nSENTIMENT ANALYSIS\r\n\r\n![Python](https://img.shields.io/badge/python-3.13-blue.svg)\r\n![GitHub License](https://img.shields.io/github/license/trflorian/sentiment-analysis-viz)\r\n\r\n\u003c/h1\u003e\r\n\r\n![demo](https://github.com/user-attachments/assets/baf39a9b-2025-4bd6-9ffe-79cc1ce992dd)\r\n\r\n\u003c/div\u003e\r\n\r\nThis project showcases a real-time sentiment analysis visualization with a smiley based on a text input.\r\nThe more positive the sentiment of the input is, the happier the smiley looks and vice versa if the sentiment is really negative.\r\n\r\n## How it works\r\n\r\nThe text input is passed to a sentiment analysis pipeline with a tokenizer and a transformer model pre-trained on twitter data, roughly 58 million tweets.\r\nThe specific model used is `cardiffnlp/twitter-roberta-base-sentiment` (https://huggingface.co/cardiffnlp/twitter-roberta-base-sentiment), which outputs three labels and a confidence score each.\r\nThe labels correspond to the classifications *negative*, *neutral* and *positive*. To calculate the final sentiment score in a range of `[-1, 1]`, I simply apply a weighted scaling based on the confidence of each label. \r\nThe negative label prediction confidence score is multiplied by -1, the neutral one by 0 and the positive score by 1.\r\n\r\n## Procedural Smiley\r\n\r\nUsing linear color interpolation in the HSV color space and a simple parabola for the mouth of the smiley, the face is procedurally generated.\r\n\r\n![score_smiley_sketch](https://github.com/user-attachments/assets/4e2dd697-fc68-40c6-b4c1-c67f9661f9e4)\r\n\r\n## Examples\r\n\r\n| Positive Sentiment | Negative Sentiment |\r\n| -------- | ------- |\r\n| ![love_is_in_the_air](https://github.com/user-attachments/assets/196b33d0-de47-4f3b-aaad-7d816b622184)  | ![bad weather](https://github.com/user-attachments/assets/d55f4598-065c-4f98-8814-dcd8452a35d5)    |\r\n\r\n\r\n## Quickstart\r\n\r\n### Prerequisites\r\n\r\nThis project uses [uv](https://docs.astral.sh/uv/) as its package/project manager.\r\nYou can run `uv sync` in the cloned project folder to get all dependencies setup in a local virtual environment specific for this project.\r\n\r\n### Run Demo\r\n\r\nTo run the project there are currently two applications available:\r\n- An interactve web app using Marimo\r\n- A desktop application using TKinter\r\n\r\n#### Interactive Web App\r\n\r\nThe project includes an interactive web application built with Marimo that provides a user-friendly interface on a webpage. \r\n\r\n```bash\r\nuv run marimo run src/sentiment_analysis/marimo/marimo_app.py\r\n```\r\n\r\n![marimo_app](https://github.com/user-attachments/assets/f8b92b65-d26c-4f81-88c3-667a83be720e)\r\n\r\n\r\n#### Tkinter Desktop App\r\n\r\nMake sure that you have all required packages installed for tkinter in order to run the standalone application.\r\n\r\n```bash\r\nuv run ctk_app\r\n```\r\n\r\n![ctk](https://github.com/user-attachments/assets/379c2e76-c9c0-4187-b70e-e771dd9487ef)\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrflorian%2Fsentiment-analysis-viz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftrflorian%2Fsentiment-analysis-viz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftrflorian%2Fsentiment-analysis-viz/lists"}