Update app.py
Browse files
app.py
CHANGED
|
@@ -106,13 +106,15 @@ def analyze_news_political_viewpoint(query):
|
|
| 106 |
|
| 107 |
return results, sentiment_counts
|
| 108 |
|
| 109 |
-
# 성향 분포 시각화
|
| 110 |
def visualize_sentiment_distribution(sentiment_counts):
|
| 111 |
fig, ax = plt.subplots()
|
| 112 |
labels = list(sentiment_counts.keys())
|
| 113 |
sizes = list(sentiment_counts.values())
|
| 114 |
-
ax.
|
| 115 |
-
ax.
|
|
|
|
|
|
|
| 116 |
st.pyplot(fig)
|
| 117 |
|
| 118 |
# Streamlit 애플리케이션
|
|
@@ -132,7 +134,7 @@ if st.button("🔍 분석 시작"):
|
|
| 132 |
if analysis_results:
|
| 133 |
st.success("뉴스 분석이 완료되었습니다.")
|
| 134 |
|
| 135 |
-
# 성향 분포 시각화
|
| 136 |
st.subheader("📊 성향 분포 시각화")
|
| 137 |
visualize_sentiment_distribution(sentiment_counts)
|
| 138 |
|
|
@@ -147,4 +149,3 @@ if st.button("🔍 분석 시작"):
|
|
| 147 |
st.write("---")
|
| 148 |
else:
|
| 149 |
st.error("분석된 뉴스 데이터가 없습니다.")
|
| 150 |
-
|
|
|
|
| 106 |
|
| 107 |
return results, sentiment_counts
|
| 108 |
|
| 109 |
+
# 성향 분포 시각화 (막대 그래프)
|
| 110 |
def visualize_sentiment_distribution(sentiment_counts):
|
| 111 |
fig, ax = plt.subplots()
|
| 112 |
labels = list(sentiment_counts.keys())
|
| 113 |
sizes = list(sentiment_counts.values())
|
| 114 |
+
ax.bar(labels, sizes, color=["blue", "red", "gray"])
|
| 115 |
+
ax.set_xlabel('성향')
|
| 116 |
+
ax.set_ylabel('건수')
|
| 117 |
+
ax.set_title('뉴스 성향 분포')
|
| 118 |
st.pyplot(fig)
|
| 119 |
|
| 120 |
# Streamlit 애플리케이션
|
|
|
|
| 134 |
if analysis_results:
|
| 135 |
st.success("뉴스 분석이 완료되었습니다.")
|
| 136 |
|
| 137 |
+
# 성향 분포 시각화 (막대 그래프)
|
| 138 |
st.subheader("📊 성향 분포 시각화")
|
| 139 |
visualize_sentiment_distribution(sentiment_counts)
|
| 140 |
|
|
|
|
| 149 |
st.write("---")
|
| 150 |
else:
|
| 151 |
st.error("분석된 뉴스 데이터가 없습니다.")
|
|
|