A newer version of the Streamlit SDK is available:
1.54.0
metadata
title: AI News Sentiment Analyzer
emoji: π€
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: 1.28.0
app_file: src/streamlit_app.py
pinned: false
π€ AI News Sentiment Analyzer
An interactive web application that fetches the latest AI-related news and analyzes the sentiment of headlines and articles. Built with Python, Streamlit, and powered by NewsAPI.
π Live Demo
π Try it live: https://huggingface.co/spaces/ai-sentiment-group/BootcampFinalProject
π οΈ Installation
Prerequisites
- Python 3.9+
- NewsAPI key (get free at newsapi.org)
Setup Instructions
Clone the repository
git clone https://github.com/alexoh2bd/BootcampFinalProject cd BootcampFinalProjectCreate virtual environment
# macOS/Linux python3 -m venv .venv source .venv/bin/activateInstall dependencies
pip install -r requirements.txtSet up environment variables
Create a
.envfile in the project root:NEWSAPI_KEY=your_newsapi_key_here
π― Usage
Web Application
Run the Streamlit app:
streamlit run src/streamlit_app.py
Then open your browser to http://localhost:8501
Command Line Interface
For quick sentiment analysis:
# Basic usage
python src/cli_demo.py
# Custom search query
python src/cli_demo.py --query "ChatGPT" --days 3
# Filter to specific sources
python src/cli_demo.py --sources "techcrunch,wired" --max-articles 5
# Show only positive articles
python src/cli_demo.py --positive-only
# Show detailed sentiment analysis
python src/cli_demo.py --sentiment-only
CLI Options
--query, -q: Search query (default: "artificial intelligence")--days, -d: Days to look back (default: 7)--sources, -s: Comma-separated news sources--max-articles, -m: Maximum articles to display (default: 10)--positive-only: Show only positive sentiment articles--negative-only: Show only negative sentiment articles--sentiment-only: Show only sentiment analysis summary
π§ Technical Architecture
flowchart TB
subgraph Frontend["π¨ Frontend Layer"]
A["π Streamlit UI"]
B["π» CLI Interface"]
end
subgraph Application["βοΈ Application Layer"]
C["api_handler.py<br/>π§ Core Logic"]
D["streamlit_app.py<br/>π Web Framework"]
E["cli_demo.py<br/>β¨οΈ Command Line"]
end
subgraph Processing["π§ Data Processing"]
F["TextBlob + VADER<br/>Sentiment Engines"]
G["Plotly<br/>Visualizations"]
H["Pandas<br/>Data Processing"]
end
subgraph External["π External Services"]
I["π‘ NewsAPI<br/>TechCrunch, Wired, etc."]
J["π Environment<br/>API Keys"]
end
A --> D
B --> E
D --> C
E --> C
C --> F
C --> H
D --> G
C --> I
C --> J
classDef frontend fill:#1f6feb,stroke:#58a6ff,stroke-width:2px,color:#f0f6fc
classDef application fill:#2ea043,stroke:#3fb950,stroke-width:2px,color:#f0f6fc
classDef processing fill:#a371f7,stroke:#d2a8ff,stroke-width:2px,color:#f0f6fc
classDef external fill:#f85149,stroke:#ff7b72,stroke-width:2px,color:#f0f6fc
class A,B frontend
class C,D,E application
class F,G,H processing
class I,J external
π Example Output
CLI Example
π€ AI News Sentiment Analyzer
==================================================
π Searching for: "artificial intelligence"
π
Looking back: 7 days
π° Found 43 articles
Sentiment Distribution:
π Positive: 18 articles (41.9%)
π Neutral: 15 articles (34.9%)
π Negative: 10 articles (23.2%)
π Top 10 Articles:
--------------------------------------------------------------------------------
1. π [TechCrunch] 2024-01-20 14:30
AI startup raises $50M for breakthrough in healthcare diagnosis
Sentiment: Positive (Score: 0.45)
π Revolutionary AI technology promises to transform medical diagnosis...
π https://techcrunch.com/...
2. π [Reuters] 2024-01-20 12:15
Concerns grow over AI job displacement in manufacturing
Sentiment: Negative (Score: -0.32)
π Labor unions express worry about automation replacing workers...
π https://reuters.com/...
π€ Contributing
This project was built as part of the Duke AIPI 503 Bootcamp.
Development Setup
- Fork the repository
- Create a feature branch:
git checkout -b feature/some-feature - Make your changes and commit:
git commit -m 'Add some feature' - Push to the branch:
git push origin feature/some-feature - Open a Pull Request
π License
This project is licensed under the MIT License - see the LICENSE file for details.