Dmitry Beresnev commited on
Commit ·
07b3173
1
Parent(s): 444359f
fix breaking news scorer
Browse files242 unmodified lines243244245246247248249250246247248253254255249250251252253254258259255256257258259262263264260261262263264265267268266267268269270271272273274275276277242 unmodified lines
def _score_engagement(self, news_item: Dict) -> float: """Score based on social engagement metrics""" engagement = news_item.get('engagement', {})
if not engagement: return 5.0 # Default score if no engagement data
score = 0.0 has_engagement = False
# Twitter engagement if 'likes' in engagement: likes = engagement['likes'] # Twitter engagement (top-level fields) likes = news_item.get('likes', 0) if likes > 0: has_engagement = True score += min(likes / 1000, 5.0) # Max 5 points for likes
if 'retweets' in engagement: retweets = engagement['retweets'] retweets = news_item.get('retweets', 0) if retweets > 0: has_engagement = True score += min(retweets / 500, 5.0) # Max 5 points for retweets
# Reddit engagement if 'score' in engagement: reddit_score = engagement['score'] # Reddit engagement (top-level fields) reddit_score = news_item.get('reddit_score', 0) if reddit_score > 0: has_engagement = True score += min(reddit_score / 1000, 5.0) # Max 5 points for score
if 'comments' in engagement: comments = engagement['comments'] comments = news_item.get('reddit_comments', 0) if comments > 0: has_engagement = True score += min(comments / 200, 5.0) # Max 5 points for comments
# If no engagement data, return default score if not has_engagement: return 5.0
return min(score, 15.0)
def _score_sentiment(self, sentiment: str) -> float:app/utils/breaking_news_scorer.py+19-15