Add AI Sentiment Analysis
Description
Integrate AI-powered sentiment analysis using transformers library to automatically analyze the sentiment of news articles. This will add valuable insights to news data and enable sentiment-based filtering and analysis.
Why?
Sentiment analysis adds significant value to news data by providing emotional context. This enables users to filter news by sentiment, track sentiment trends over time, and make data-driven decisions based on public opinion.
How?
Create a new ai/sentiment.py module that:
- Uses a lightweight transformer model (DistilBERT or similar)
- Analyzes article titles and descriptions for sentiment
- Returns sentiment scores (positive, negative, neutral)
- Supports batch processing for performance
- Integrates seamlessly with existing GNews workflow
Files to Create
gnews/ai/sentiment.pygnews/ai/__init__.py
Files to Modify
requirements.txt(add transformers, torch dependencies)gnews/gnews.py(add sentiment analysis integration)
Acceptance Criteria
- [ ] Sentiment analysis module created with transformer model
- [ ] Integration with GNews article processing
- [ ] Batch processing support for performance
- [ ] Sentiment scores added to article data structure
- [ ] Configurable sentiment thresholds
- [ ] Error handling for model loading/processing
- [ ] Tests added for sentiment analysis
- [ ] Documentation with usage examples
Example Usage
from gnews import GNews
google_news = GNews()
articles = google_news.get_news('artificial intelligence', analyze_sentiment=True)
for article in articles:
print(f"Title: {article['title']}")
print(f"Sentiment: {article['sentiment']} (Score: {article['sentiment_score']})")
Resources
Difficulty: Hard
Time Estimate: 6-10 hours
@ranahaani Please assign this task to me .I am excited to implement Sentiment analysis in this.
can i work o this
assign this issue to me
please check my repo and please accept if it is upto the mark and revert me if you need any changes