Update app.py
Browse files
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 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
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}**")
|