LordXido commited on
Commit
90d3482
·
verified ·
1 Parent(s): 46c627f

Create sentiment_engine.py

Browse files
Files changed (1) hide show
  1. sentiment_engine.py +13 -0
sentiment_engine.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def sentiment_features(news_payload):
2
+ articles = []
3
+ for block in news_payload:
4
+ articles.extend(block.get("articles", []))
5
+
6
+ count = len(articles)
7
+ unique_titles = len(set(a.get("title","") for a in articles))
8
+
9
+ return {
10
+ "article_count": count,
11
+ "diversity_ratio": unique_titles / max(count, 1),
12
+ "sentiment_pressure": min(1.0, count / 50.0)
13
+ }