Update app.py
Browse files
app.py
CHANGED
@@ -71,10 +71,18 @@ def analyze_news_political_orientation(news_items, classifier, translator):
|
|
71 |
description = item["description"]
|
72 |
combined_text = f"{title}. {description}"
|
73 |
|
|
|
74 |
translated_text = translator(combined_text)[0]['translation_text']
|
75 |
-
st.write("Translated Text:", translated_text) # ๋ฒ์ญ๋ ํ
์คํธ
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
|
77 |
-
orientation, score = classify_political_sentiment(translated_text, classifier)
|
78 |
results[orientation] += 1
|
79 |
detailed_results.append({
|
80 |
"์ ๋ชฉ": title,
|
|
|
71 |
description = item["description"]
|
72 |
combined_text = f"{title}. {description}"
|
73 |
|
74 |
+
# ๋ฒ์ญ: ํ๊ตญ์ด -> ์์ด
|
75 |
translated_text = translator(combined_text)[0]['translation_text']
|
76 |
+
st.write("Translated Text:", translated_text) # ๋ฒ์ญ๋ ํ
์คํธ ์ถ๋ ฅ
|
77 |
+
|
78 |
+
# ์ ์น ์ฑํฅ ๋ถ๋ฅ
|
79 |
+
try:
|
80 |
+
orientation, score = classify_political_sentiment(translated_text, classifier)
|
81 |
+
st.write(f"Orientation: {orientation}, Score: {score}") # ์์ธก๋ ์ฑํฅ ๋ฐ ์ ์ ์ถ๋ ฅ
|
82 |
+
except Exception as e:
|
83 |
+
st.write(f"Error in sentiment analysis: {e}") # ์์ธก ์คํจ ์ ์ค๋ฅ ๋ฉ์์ง ์ถ๋ ฅ
|
84 |
+
continue # ์์ธ ๋ฐ์ ์ ํด๋น ๋ด์ค ๊ฑด ๋์ด๊ฐ๊ธฐ
|
85 |
|
|
|
86 |
results[orientation] += 1
|
87 |
detailed_results.append({
|
88 |
"์ ๋ชฉ": title,
|