Dmitry Beresnev commited on
Commit ·
07b3173
1
Parent(s): 444359f
fix breaking news scorer
Browse files242 unmodified lines243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273242 unmodified linesdef _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 datascore = 0.0# Twitter engagementif 'likes' in engagement:likes = engagement['likes']score += min(likes / 1000, 5.0) # Max 5 points for likesif 'retweets' in engagement:retweets = engagement['retweets']score += min(retweets / 500, 5.0) # Max 5 points for retweets# Reddit engagementif 'score' in engagement:reddit_score = engagement['score']score += min(reddit_score / 1000, 5.0) # Max 5 points for scoreif 'comments' in engagement:comments = engagement['comments']score += min(comments / 200, 5.0) # Max 5 points for commentsreturn min(score, 15.0)def _score_sentiment(self, sentiment: str) -> float:242 unmodified lines243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277242 unmodified linesdef _score_engagement(self, news_item: Dict) -> float:"""Score based on social engagement metrics"""score = 0.0has_engagement = False# Twitter engagement (top-level fields)likes = news_item.get('likes', 0)if likes > 0:has_engagement = Truescore += min(likes / 1000, 5.0) # Max 5 points for likesretweets = news_item.get('retweets', 0)if retweets > 0:has_engagement = Truescore += min(retweets / 500, 5.0) # Max 5 points for retweets# Reddit engagement (top-level fields)reddit_score = news_item.get('reddit_score', 0)if reddit_score > 0:has_engagement = Truescore += min(reddit_score / 1000, 5.0) # Max 5 points for scorecomments = news_item.get('reddit_comments', 0)if comments > 0:has_engagement = Truescore += min(comments / 200, 5.0) # Max 5 points for comments# If no engagement data, return default scoreif not has_engagement:return 5.0return min(score, 15.0)def _score_sentiment(self, sentiment: str) -> float:
app/utils/breaking_news_scorer.py+19-15