820nam commited on
Commit
db118f0
ยท
verified ยท
1 Parent(s): fd1df6b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -23,7 +23,6 @@ def fetch_naver_news(query, display=10, start=1, sort="date"):
23
  response = requests.get(url, headers=headers, params=params)
24
  if response.status_code == 200:
25
  news_data = response.json()
26
- st.write("News Data:", news_data) # ์‘๋‹ต ๋‚ด์šฉ ํ™•์ธ
27
  return news_data
28
  else:
29
  raise Exception(f"Error: {response.status_code}, {response.text}")
@@ -36,7 +35,6 @@ def load_translation_model():
36
  # Step 3: Hugging Face ์ •์น˜ ์„ฑํ–ฅ ๋ถ„์„ ๋ชจ๋ธ ๋กœ๋“œ
37
  def load_huggingface_model():
38
  classifier = pipeline("text-classification", model="bucketresearch/politicalBiasBERT")
39
- st.write("๋ชจ๋ธ ๋กœ๋“œ ์™„๋ฃŒ")
40
  return classifier
41
 
42
  # Step 4: ์ •์น˜ ์„ฑํ–ฅ ๋ถ„๋ฅ˜ ํ•จ์ˆ˜
@@ -73,17 +71,16 @@ def analyze_news_political_orientation(news_items, classifier, translator):
73
 
74
  # ๋ฒˆ์—ญ: ํ•œ๊ตญ์–ด -> ์˜์–ด
75
  translated_text = translator(combined_text)[0]['translation_text']
76
- st.write("Translated Text:", translated_text) # ๋ฒˆ์—ญ๋œ ํ…์ŠคํŠธ ํ™•์ธ
77
 
78
  # ์ •์น˜ ์„ฑํ–ฅ ๋ถ„๋ฅ˜
79
  orientation, score = classify_political_sentiment(translated_text, classifier)
80
- st.write(f"Orientation: {orientation}, Score: {score}") # ์„ฑํ–ฅ ๋ฐ ์ ์ˆ˜ ํ™•์ธ
81
  results[orientation] += 1
82
  detailed_results.append({
83
  "์ œ๋ชฉ": title,
84
  "์š”์•ฝ": description,
85
  "์„ฑํ–ฅ": orientation,
86
  "์ ์ˆ˜": score,
 
87
  })
88
 
89
  return results, detailed_results
@@ -127,7 +124,7 @@ if st.button("๋ถ„์„ ์‹œ์ž‘"):
127
  # ๋งํฌ ํฌํ•จํ•œ ๋‰ด์Šค ์ถœ๋ ฅ
128
  st.subheader("๋‰ด์Šค ๋งํฌ")
129
  for index, row in df.iterrows():
130
- st.write(f"- [{row['์ œ๋ชฉ']}] (์„ฑํ–ฅ: {row['์„ฑํ–ฅ']}, ์ ์ˆ˜: {row['์ ์ˆ˜']:.2f})")
131
 
132
  except Exception as e:
133
  st.error(f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {e}")
 
23
  response = requests.get(url, headers=headers, params=params)
24
  if response.status_code == 200:
25
  news_data = response.json()
 
26
  return news_data
27
  else:
28
  raise Exception(f"Error: {response.status_code}, {response.text}")
 
35
  # Step 3: Hugging Face ์ •์น˜ ์„ฑํ–ฅ ๋ถ„์„ ๋ชจ๋ธ ๋กœ๋“œ
36
  def load_huggingface_model():
37
  classifier = pipeline("text-classification", model="bucketresearch/politicalBiasBERT")
 
38
  return classifier
39
 
40
  # Step 4: ์ •์น˜ ์„ฑํ–ฅ ๋ถ„๋ฅ˜ ํ•จ์ˆ˜
 
71
 
72
  # ๋ฒˆ์—ญ: ํ•œ๊ตญ์–ด -> ์˜์–ด
73
  translated_text = translator(combined_text)[0]['translation_text']
 
74
 
75
  # ์ •์น˜ ์„ฑํ–ฅ ๋ถ„๋ฅ˜
76
  orientation, score = classify_political_sentiment(translated_text, classifier)
 
77
  results[orientation] += 1
78
  detailed_results.append({
79
  "์ œ๋ชฉ": title,
80
  "์š”์•ฝ": description,
81
  "์„ฑํ–ฅ": orientation,
82
  "์ ์ˆ˜": score,
83
+ "๋งํฌ": item["link"]
84
  })
85
 
86
  return results, detailed_results
 
124
  # ๋งํฌ ํฌํ•จํ•œ ๋‰ด์Šค ์ถœ๋ ฅ
125
  st.subheader("๋‰ด์Šค ๋งํฌ")
126
  for index, row in df.iterrows():
127
+ st.write(f"- [{row['์ œ๋ชฉ']}]({row['๋งํฌ']}) (์„ฑํ–ฅ: {row['์„ฑํ–ฅ']}, ์ ์ˆ˜: {row['์ ์ˆ˜']:.2f})")
128
 
129
  except Exception as e:
130
  st.error(f"์˜ค๋ฅ˜ ๋ฐœ์ƒ: {e}")