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 β¦