820nam commited on
Commit
8cadfb7
ยท
verified ยท
1 Parent(s): a8c6507

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -2
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,