Skip to content

abdulsamad00529/sentiment-analyzer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 Real-Time Sentiment Analyzer

Instantly classify text as Positive or Negative using DistilBERT — no API key, no cloud cost, runs on any machine.

Python HuggingFace Gradio License


Features

  • Single-text analysis — paste any text and get an instant POSITIVE / NEGATIVE label with a confidence score and visual bar
  • Batch CSV processing — upload a CSV with a text column and analyze hundreds of rows at once
  • Downloadable results — export your batch results as a clean CSV file
  • Sentiment distribution chart — auto-generated bar chart showing the split across your dataset
  • Zero cost — powered by a free HuggingFace model that runs fully on CPU; no GPU or paid API required
  • Clean Gradio UI — two-tab layout built with gr.Blocks and gr.themes.Soft()

Quick Start

git clone https://github.com/your-username/sentiment-analyzer.git && cd sentiment-analyzer
pip install -r requirements.txt
python app.py

Then open your browser at http://localhost:7860


How It Works

DistilBERT is a smaller, faster version of Google's BERT language model — trained by reading billions of sentences from the internet until it learned what words, phrases, and sentence structures tend to mean. It was then fine-tuned specifically on movie and product reviews so it knows the difference between language that expresses satisfaction and language that expresses frustration. When you give it a sentence, it converts every word into a stream of numbers, passes those numbers through 6 layers of "attention" math that weighs how each word relates to every other word, and produces a single prediction: Positive or Negative, along with a confidence score showing how certain it is.


Demo

Demoadd your screen recording here


Project Structure

sentiment-analyzer/
├── app.py                # Gradio Blocks UI + tab logic
├── model.py              # Lazy model loading + analyze_text / analyze_batch
├── requirements.txt      # Pinned dependencies
├── sample_reviews.csv    # 10 Amazon-style test reviews
└── README.md

Use Cases

  • E-commerce — automatically flag negative product reviews for urgent review
  • Social media monitoring — gauge public sentiment on brand mentions or campaigns
  • Customer support — prioritize tickets that contain strongly negative language
  • Research — quickly label large text datasets without manual annotation
  • Education — learn how transformer-based NLP pipelines work end-to-end

Deploying to HuggingFace Spaces

  1. Create a new Space at huggingface.co/spaces (choose Gradio SDK)
  2. Push this repository to the Space's git remote
  3. HuggingFace will auto-install requirements.txt and run app.py

Or for a quick public share link, change the last line of app.py to:

demo.launch(share=True)

License

MIT © 2024 — free to use, modify, and distribute.

About

Real-time sentiment analysis web app using distilBERT + Gradio. Analyzes text and CSV batch inputs with confidence scores.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages