NLP sentiment analysis of Kenyan news headlines scraped from StandardMedia.co.ke TextBlob scoring, category breakdown and live headline scorer deployed on Streamlit
# 📰 Kenya News Sentiment Tracker
> NLP project — real Kenyan news headlines scraped from StandardMedia.co.ke, analysed for sentiment using TextBlob and deployed as a live interactive dashboard.
🔗 **Live App:** kenya-news-sentiment-tracker.streamlit.app
---
## 📸 Screenshots
---
## 🎯 Project Overview
This project scrapes real headlines from **StandardMedia.co.ke** across 6 news categories, scores each headline's sentiment using **TextBlob NLP**, and visualises the results in an interactive Streamlit dashboard.
**Key Question:** *Is Kenyan news coverage mostly positive, negative or neutral — and which categories drive the most negative sentiment?*
---
## 🔄 Project Pipeline
```
SCRAPE ──► CLEAN ──► SENTIMENT ──► VISUALISE ──► DEPLOY
```
---
## 📁 Project Structure
```
kenya-news-sentiment-tracker/
│
├── app.py # Streamlit dashboard
├── standard_scraper.py # Web scraper
├── sentiment_analysis.ipynb # Cleaning + sentiment notebook
│
├── news_raw.csv # Raw scraped headlines (214 rows)
├── news_clean.csv # Cleaned + scored dataset (213 rows)
│
├── requirements.txt # Python dependencies
└── README.md
```
---
## 🔍 Stage Breakdown
### 1️⃣ Web Scraping — `standard_scraper.py`
- Built with `requests` and `BeautifulSoup`
- Used Chrome DevTools to identify stable article link selectors
- Scraped 6 categories: Politics, Business, Health, Sports, World, Counties
- Fields collected: headline text, category, URL, scraped timestamp
- Output: `news_raw.csv` — **214 headlines**
### 2️⃣ Cleaning — `sentiment_analysis.ipynb`
- Removed extra whitespace and special characters
- Dropped duplicate and very short headlines
- Parsed timestamps into proper datetime format
- Output: `news_clean.csv` — **213 headlines, 0 missing values**
### 3️⃣ Sentiment Analysis — `sentiment_analysis.ipynb`
- Scored every headline using **TextBlob** polarity
- Polarity range: –1.0 (very negative) → 0.0 (neutra …