GNews icon indicating copy to clipboard operation
GNews copied to clipboard

Add AI Sentiment Analysis

Open ranahaani opened this issue 2 months ago • 4 comments

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.py
  • gnews/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 avatar Oct 21 '25 04:10 ranahaani

@ranahaani Please assign this task to me .I am excited to implement Sentiment analysis in this.

Lakshya-sketch avatar Oct 21 '25 15:10 Lakshya-sketch

can i work o this

Arihant2312 avatar Oct 22 '25 06:10 Arihant2312

assign this issue to me

Gowtham2801031902 avatar Oct 22 '25 17:10 Gowtham2801031902

please check my repo and please accept if it is upto the mark and revert me if you need any changes

Gowtham2801031902 avatar Oct 22 '25 18:10 Gowtham2801031902