File size: 4,931 Bytes
f5b7e31 a5f2bf9 2696124 a5f2bf9 f5b7e31 ffb6131 f5b7e31 cb05e7b f5b7e31 cb05e7b f5b7e31 cb05e7b f5b7e31 cb05e7b f5b7e31 cb05e7b f5b7e31 8c11cc0 f5b7e31 8c11cc0 f5b7e31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
---
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](https://huggingface.co/spaces/ai-sentiment-group/BootcampFinalProject)
## π οΈ Installation
### Prerequisites
- Python 3.9+
- NewsAPI key (get free at [newsapi.org](https://newsapi.org))
### Setup Instructions
1. **Clone the repository**
```bash
git clone https://github.com/alexoh2bd/BootcampFinalProject
cd BootcampFinalProject
```
2. **Create virtual environment**
```bash
# macOS/Linux
python3 -m venv .venv
source .venv/bin/activate
```
3. **Install dependencies**
```bash
pip install -r requirements.txt
```
4. **Set up environment variables**
Create a `.env` file in the project root:
```bash
NEWSAPI_KEY=your_newsapi_key_here
```
## π― Usage
### Web Application
Run the Streamlit app:
```bash
streamlit run src/streamlit_app.py
```
Then open your browser to `http://localhost:8501`
### Command Line Interface
For quick sentiment analysis:
```bash
# 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
```mermaid
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
```bash
π€ 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
1. Fork the repository
2. Create a feature branch: `git checkout -b feature/some-feature`
3. Make your changes and commit: `git commit -m 'Add some feature'`
4. Push to the branch: `git push origin feature/some-feature`
5. Open a Pull Request
## π License
This project is licensed under the MIT License - see the LICENSE file for details.
|