LinkLinkWu commited on
Commit
eb4439d
·
verified ·
1 Parent(s): e3ea312

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -123,7 +123,13 @@ if st.button("Get News and Sentiment"):
123
  # Determine overall sentiment based on majority
124
  positive_count = sentiments.count("Positive")
125
  negative_count = sentiments.count("Negative")
126
- overall_sentiment = "Positive" if positive_count > negative_count else "Negative"
 
 
 
 
 
 
127
 
128
  # Display top 3 news articles with sentiment
129
  st.write(f"**Top 3 News Articles for {ticker}**")
 
123
  # Determine overall sentiment based on majority
124
  positive_count = sentiments.count("Positive")
125
  negative_count = sentiments.count("Negative")
126
+ total = len(sentiments)
127
+ positive_ratio = positive_count / total if total else 0
128
+ negative_ratio = negative_count / total if total else 0
129
+ if positive_ratio >= 0.4:
130
+ overall_sentiment = "Positive"
131
+ else negative_ratio >= 0.6:
132
+ overall_sentiment = "Negative"
133
 
134
  # Display top 3 news articles with sentiment
135
  st.write(f"**Top 3 News Articles for {ticker}**")