Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -98,26 +98,41 @@ def main():
|
|
98 |
st.header("π News Articles")
|
99 |
for idx, article in enumerate(data["articles"], 1):
|
100 |
with st.expander(f"Article {idx}: {article['title']}"):
|
101 |
-
|
102 |
-
if "
|
103 |
-
st.
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
105 |
|
106 |
# Enhanced sentiment display
|
107 |
if "sentiment" in article:
|
108 |
sentiment_col1, sentiment_col2 = st.columns(2)
|
109 |
with sentiment_col1:
|
110 |
-
st.
|
111 |
-
st.write("
|
|
|
|
|
112 |
|
113 |
with sentiment_col2:
|
114 |
# Display fine-grained sentiment if available
|
115 |
if "fine_grained_sentiment" in article and article["fine_grained_sentiment"]:
|
|
|
116 |
fine_grained = article["fine_grained_sentiment"]
|
117 |
if "category" in fine_grained:
|
118 |
-
st.write("
|
119 |
if "confidence" in fine_grained:
|
120 |
-
st.write("
|
121 |
|
122 |
# Display sentiment indices if available
|
123 |
if "sentiment_indices" in article and article["sentiment_indices"]:
|
@@ -178,8 +193,9 @@ def main():
|
|
178 |
st.markdown(f"> {target['context']}")
|
179 |
st.markdown("---")
|
180 |
|
|
|
181 |
if "url" in article:
|
182 |
-
st.
|
183 |
|
184 |
# Display Comparative Analysis
|
185 |
st.header("π Comparative Analysis")
|
@@ -338,9 +354,28 @@ def main():
|
|
338 |
# Display Final Analysis
|
339 |
st.header("π Final Analysis")
|
340 |
|
341 |
-
# Display overall sentiment analysis
|
342 |
if data.get("final_sentiment_analysis"):
|
343 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
344 |
|
345 |
# Display ensemble model details
|
346 |
if data.get("ensemble_info"):
|
|
|
98 |
st.header("π News Articles")
|
99 |
for idx, article in enumerate(data["articles"], 1):
|
100 |
with st.expander(f"Article {idx}: {article['title']}"):
|
101 |
+
# Display content with proper formatting
|
102 |
+
if article.get("content"):
|
103 |
+
st.markdown("**Content:**")
|
104 |
+
st.write(article["content"])
|
105 |
+
else:
|
106 |
+
st.warning("No content available for this article")
|
107 |
+
|
108 |
+
# Display summary if available
|
109 |
+
if article.get("summary"):
|
110 |
+
st.markdown("**Summary:**")
|
111 |
+
st.write(article["summary"])
|
112 |
+
|
113 |
+
# Display source
|
114 |
+
if article.get("source"):
|
115 |
+
st.markdown("**Source:**")
|
116 |
+
st.write(article["source"])
|
117 |
|
118 |
# Enhanced sentiment display
|
119 |
if "sentiment" in article:
|
120 |
sentiment_col1, sentiment_col2 = st.columns(2)
|
121 |
with sentiment_col1:
|
122 |
+
st.markdown("**Basic Sentiment:**")
|
123 |
+
st.write(article["sentiment"])
|
124 |
+
if "sentiment_score" in article:
|
125 |
+
st.write(f"**Confidence Score:** {article['sentiment_score']*100:.1f}%")
|
126 |
|
127 |
with sentiment_col2:
|
128 |
# Display fine-grained sentiment if available
|
129 |
if "fine_grained_sentiment" in article and article["fine_grained_sentiment"]:
|
130 |
+
st.markdown("**Detailed Sentiment:**")
|
131 |
fine_grained = article["fine_grained_sentiment"]
|
132 |
if "category" in fine_grained:
|
133 |
+
st.write(f"Category: {fine_grained['category']}")
|
134 |
if "confidence" in fine_grained:
|
135 |
+
st.write(f"Confidence: {fine_grained['confidence']*100:.1f}%")
|
136 |
|
137 |
# Display sentiment indices if available
|
138 |
if "sentiment_indices" in article and article["sentiment_indices"]:
|
|
|
193 |
st.markdown(f"> {target['context']}")
|
194 |
st.markdown("---")
|
195 |
|
196 |
+
# Display URL if available
|
197 |
if "url" in article:
|
198 |
+
st.markdown(f"**[Read More]({article['url']})**")
|
199 |
|
200 |
# Display Comparative Analysis
|
201 |
st.header("π Comparative Analysis")
|
|
|
354 |
# Display Final Analysis
|
355 |
st.header("π Final Analysis")
|
356 |
|
357 |
+
# Display overall sentiment analysis with enhanced formatting
|
358 |
if data.get("final_sentiment_analysis"):
|
359 |
+
st.markdown("### Overall Sentiment Analysis")
|
360 |
+
analysis_parts = data["final_sentiment_analysis"].split(". ")
|
361 |
+
if len(analysis_parts) >= 2:
|
362 |
+
# First sentence - Overall sentiment
|
363 |
+
st.markdown(f"**{analysis_parts[0]}.**")
|
364 |
+
# Second sentence - Key findings
|
365 |
+
st.markdown(f"**{analysis_parts[1]}.**")
|
366 |
+
# Third sentence - Additional insights (if available)
|
367 |
+
if len(analysis_parts) > 2:
|
368 |
+
st.markdown(f"**{analysis_parts[2]}.**")
|
369 |
+
else:
|
370 |
+
st.write(data["final_sentiment_analysis"])
|
371 |
+
|
372 |
+
# Add sentiment strength indicator
|
373 |
+
if data.get("ensemble_info"):
|
374 |
+
ensemble_info = data["ensemble_info"]
|
375 |
+
if "model_agreement" in ensemble_info:
|
376 |
+
agreement = ensemble_info["model_agreement"]
|
377 |
+
strength = "Strong" if agreement > 0.8 else "Moderate" if agreement > 0.6 else "Weak"
|
378 |
+
st.markdown(f"**Sentiment Strength:** {strength} (Agreement: {agreement:.2f})")
|
379 |
|
380 |
# Display ensemble model details
|
381 |
if data.get("ensemble_info"):
|