820nam commited on
Commit
4f7bc9c
ยท
verified ยท
1 Parent(s): 14ae745

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -23,7 +23,7 @@ def load_huggingface_data():
23
  return dataset
24
 
25
  # ๋„ค์ด๋ฒ„ ๋‰ด์Šค API๋ฅผ ํ†ตํ•ด ๋‰ด์Šค ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
26
- def fetch_naver_news(query, display=5):
27
  client_id = "I_8koTJh3R5l4wLurQbG" # ๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์„ผํ„ฐ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ Client ID
28
  client_secret = "W5oWYlAgur" # ๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์„ผํ„ฐ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ Client Secret
29
 
@@ -117,11 +117,12 @@ if st.button("๋ฐ์ดํ„ฐ ๊ฒฐํ•ฉ ๋ฐ ํ•™์Šต"):
117
 
118
  # ๋‰ด์Šค ๋ฐ์ดํ„ฐ ๋ถ„์„ ๋ฐ ๋ฐ˜๋Œ€ ๊ด€์  ๊ธฐ์‚ฌ ์ƒ์„ฑ
119
  if st.button("๋‰ด์Šค ์„ฑํ–ฅ ๋ถ„์„"):
120
- model, vectorizer = initialize_model()
121
- news_items = fetch_naver_news(query)
 
122
 
123
  if news_items:
124
- st.subheader("๋ถ„์„ ๊ฒฐ๊ณผ")
125
  for item in news_items:
126
  title = item["title"]
127
  description = item["description"]
@@ -143,4 +144,4 @@ if st.button("๋‰ด์Šค ์„ฑํ–ฅ ๋ถ„์„"):
143
  st.write(f"**์„ฑํ–ฅ:** {sentiment}")
144
  st.write(f"**๋ฐ˜๋Œ€ ๊ด€์  ๊ธฐ์‚ฌ:** {opposite_article}")
145
  st.write(f"**๋งํฌ:** [๊ธฐ์‚ฌ ๋งํฌ]({link})")
146
- st.markdown("---")
 
23
  return dataset
24
 
25
  # ๋„ค์ด๋ฒ„ ๋‰ด์Šค API๋ฅผ ํ†ตํ•ด ๋‰ด์Šค ๋ฐ์ดํ„ฐ ๊ฐ€์ ธ์˜ค๊ธฐ
26
+ def fetch_naver_news(query, display=15):
27
  client_id = "I_8koTJh3R5l4wLurQbG" # ๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์„ผํ„ฐ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ Client ID
28
  client_secret = "W5oWYlAgur" # ๋„ค์ด๋ฒ„ ๊ฐœ๋ฐœ์ž ์„ผํ„ฐ์—์„œ ๋ฐœ๊ธ‰๋ฐ›์€ Client Secret
29
 
 
117
 
118
  # ๋‰ด์Šค ๋ฐ์ดํ„ฐ ๋ถ„์„ ๋ฐ ๋ฐ˜๋Œ€ ๊ด€์  ๊ธฐ์‚ฌ ์ƒ์„ฑ
119
  if st.button("๋‰ด์Šค ์„ฑํ–ฅ ๋ถ„์„"):
120
+ # Hugging Face ๋””๋ ‰ํ† ๋ฆฌ์—์„œ ๋ชจ๋ธ ๋กœ๋“œ
121
+ model, vectorizer = load_model_from_huggingface(directory="huggingface_model")
122
+ news_items = fetch_naver_news(query, display=15) # ๋‰ด์Šค 15๊ฐœ ๊ฐ€์ ธ์˜ค๊ธฐ
123
 
124
  if news_items:
125
+ st.subheader("๋‰ด์Šค ์„ฑํ–ฅ ๋ถ„์„ ๊ฒฐ๊ณผ")
126
  for item in news_items:
127
  title = item["title"]
128
  description = item["description"]
 
144
  st.write(f"**์„ฑํ–ฅ:** {sentiment}")
145
  st.write(f"**๋ฐ˜๋Œ€ ๊ด€์  ๊ธฐ์‚ฌ:** {opposite_article}")
146
  st.write(f"**๋งํฌ:** [๊ธฐ์‚ฌ ๋งํฌ]({link})")
147
+ st.markdown("---")