Kims12 commited on
Commit
989a45c
ยท
verified ยท
1 Parent(s): fb6f347

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -30
app.py CHANGED
@@ -235,14 +235,7 @@ def process_keyword(keywords: str, include_related: bool):
235
  debug_log("process_keyword ์™„๋ฃŒ")
236
  return result_df, create_excel_file(result_df)
237
 
238
- # ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ: '๋ธ”๋กœ๊ทธ๋‚ด์šฉ๊ฐ€์ ธ์˜ค๊ธฐ' ์‹คํ–‰ ์‹œ ๋ธ”๋กœ๊ทธ ๋งํฌ๋กœ๋ถ€ํ„ฐ ์ œ๋ชฉ/๋ณธ๋ฌธ ์Šคํฌ๋ž˜ํ•‘
239
- def fetch_blog_content(url: str):
240
- debug_log("fetch_blog_content ํ•จ์ˆ˜ ์‹œ์ž‘")
241
- content = scrape_naver_blog(url)
242
- debug_log("fetch_blog_content ํ•จ์ˆ˜ ์™„๋ฃŒ")
243
- return content
244
-
245
- # ์ƒˆ๋กœ์šด ๊ธฐ๋Šฅ: ํ˜•ํƒœ์†Œ ๋ถ„์„ ๋ฐ ๊ฒ€์ƒ‰๋Ÿ‰, ๋ธ”๋กœ๊ทธ๋ฌธ์„œ์ˆ˜ ์ถ”๊ฐ€ (๋นˆ๋„์ˆ˜ 1 ์ œ๊ฑฐ ์˜ต์…˜ ์ถ”๊ฐ€)
246
  def morphological_analysis_and_enrich(text: str, remove_freq1: bool):
247
  debug_log("morphological_analysis_and_enrich ํ•จ์ˆ˜ ์‹œ์ž‘")
248
  df_freq, _ = analyze_text(text)
@@ -272,29 +265,35 @@ def morphological_analysis_and_enrich(text: str, remove_freq1: bool):
272
  debug_log("morphological_analysis_and_enrich ํ•จ์ˆ˜ ์™„๋ฃŒ")
273
  return merged_df, merged_excel_path
274
 
275
- # Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ (Hugging Face Spaces ํ™˜๊ฒฝ์— ์ ํ•ฉ)
276
- with gr.Blocks(title="๋ธ”๋กœ๊ทธ๊ธ€ ํ˜•ํƒœ์†Œ ๋ถ„์„ ์ŠคํŽ˜์ด์Šค", css=".gradio-container { max-width: 960px; margin: auto; }") as demo:
277
- gr.Markdown("# ๋ธ”๋กœ๊ทธ๊ธ€ ํ˜•ํƒœ์†Œ ๋ถ„์„ ์ŠคํŽ˜์ด์Šค")
278
-
279
- with gr.Tab("๋ธ”๋กœ๊ทธ ๋‚ด์šฉ ๊ฐ€์ ธ์˜ค๊ธฐ"):
280
- with gr.Row():
281
- blog_url_input = gr.Textbox(label="๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ ๋งํฌ", placeholder="์˜ˆ: https://blog.naver.com/ssboost/222983068507", lines=1)
282
- fetch_button = gr.Button("๋ธ”๋กœ๊ทธ๋‚ด์šฉ๊ฐ€์ ธ์˜ค๊ธฐ")
283
- blog_content = gr.Textbox(label="๋ธ”๋กœ๊ทธ ๋‚ด์šฉ", lines=10, placeholder="๋ธ”๋กœ๊ทธ ๋‚ด์šฉ์„ ๊ฐ€์ ธ์˜ค๊ฑฐ๋‚˜ ์ง์ ‘ ์ž…๋ ฅํ•˜์„ธ์š”.")
284
- fetch_button.click(fn=fetch_blog_content, inputs=blog_url_input, outputs=blog_content)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
285
 
286
- with gr.Tab("ํ˜•ํƒœ์†Œ ๋ถ„์„"):
287
- with gr.Row():
288
- analysis_input = gr.Textbox(label="๋ถ„์„ํ•  ํ…์ŠคํŠธ", lines=10, placeholder="๋ถ„์„ํ•  ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๊ฑฐ๋‚˜ '๋ธ”๋กœ๊ทธ ๋‚ด์šฉ ๊ฐ€์ ธ์˜ค๊ธฐ'์—์„œ ๊ฐ€์ ธ์˜จ ๋‚ด์šฉ์„ ์ˆ˜์ •ํ•˜์„ธ์š”.")
289
- with gr.Row():
290
- remove_freq_checkbox = gr.Checkbox(label="๋นˆ๋„์ˆ˜1 ์ œ๊ฑฐ", value=False)
291
- with gr.Row():
292
- analyze_button = gr.Button("ํ˜•ํƒœ์†Œ๋ถ„์„")
293
- with gr.Row():
294
- analysis_result = gr.Dataframe(label="๋ถ„์„ ๊ฒฐ๊ณผ (๋‹จ์–ด, ๋นˆ๋„์ˆ˜, ๊ฒ€์ƒ‰๋Ÿ‰, ๋ธ”๋กœ๊ทธ๋ฌธ์„œ์ˆ˜ ๋“ฑ)")
295
- with gr.Row():
296
- analysis_excel = gr.File(label="Excel ๋‹ค์šด๋กœ๋“œ")
297
- analyze_button.click(fn=morphological_analysis_and_enrich, inputs=[analysis_input, remove_freq_checkbox], outputs=[analysis_result, analysis_excel])
298
 
299
  if __name__ == "__main__":
300
  debug_log("Gradio ์•ฑ ์‹คํ–‰ ์‹œ์ž‘")
 
235
  debug_log("process_keyword ์™„๋ฃŒ")
236
  return result_df, create_excel_file(result_df)
237
 
238
+ # [์ฐธ์กฐ์ฝ”๋“œ-1] ๋ฐ [์ฐธ์กฐ์ฝ”๋“œ-2]๋ฅผ ํ™œ์šฉํ•œ ํ˜•ํƒœ์†Œ ๋ถ„์„ ๋ฐ ๊ฒ€์ƒ‰๋Ÿ‰, ๋ธ”๋กœ๊ทธ๋ฌธ์„œ์ˆ˜ ์ถ”๊ฐ€ (๋นˆ๋„์ˆ˜1 ์ œ๊ฑฐ ์˜ต์…˜ ํฌํ•จ)
 
 
 
 
 
 
 
239
  def morphological_analysis_and_enrich(text: str, remove_freq1: bool):
240
  debug_log("morphological_analysis_and_enrich ํ•จ์ˆ˜ ์‹œ์ž‘")
241
  df_freq, _ = analyze_text(text)
 
265
  debug_log("morphological_analysis_and_enrich ํ•จ์ˆ˜ ์™„๋ฃŒ")
266
  return merged_df, merged_excel_path
267
 
268
+ # ์ƒˆ๋กญ๊ฒŒ ์ถ”๊ฐ€๋œ ๊ธฐ๋Šฅ: ์ž…๋ ฅํ•œ ๋ธ”๋กœ๊ทธ ๋งํฌ๋กœ๋ถ€ํ„ฐ ์Šคํฌ๋ž˜ํ•‘ํ•˜์—ฌ ์ˆ˜์ • ๊ฐ€๋Šฅํ•œ ํ…์ŠคํŠธ ๋ฐ•์Šค์— ์ถœ๋ ฅ
269
+ def fetch_blog_content(url: str):
270
+ debug_log("fetch_blog_content ํ•จ์ˆ˜ ์‹œ์ž‘")
271
+ content = scrape_naver_blog(url)
272
+ debug_log("fetch_blog_content ํ•จ์ˆ˜ ์™„๋ฃŒ")
273
+ return content
274
+
275
+ # Gradio ์ธํ„ฐํŽ˜์ด์Šค ๊ตฌ์„ฑ (๋‹จ์ผ ํƒญ)
276
+ with gr.Blocks(title="๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ ํ˜•ํƒœ์†Œ ๋ถ„์„ ์ŠคํŽ˜์ด์Šค", css=".gradio-container { max-width: 960px; margin: auto; }") as demo:
277
+ gr.Markdown("# ๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ ํ˜•ํƒœ์†Œ ๋ถ„์„ ์ŠคํŽ˜์ด์Šค")
278
+ with gr.Row():
279
+ blog_url_input = gr.Textbox(label="๋„ค์ด๋ฒ„ ๋ธ”๋กœ๊ทธ ๋งํฌ", placeholder="์˜ˆ: https://blog.naver.com/ssboost/222983068507", lines=1)
280
+ with gr.Row():
281
+ scrape_button = gr.Button("์Šคํฌ๋ž˜ํ•‘ ์‹คํ–‰")
282
+ with gr.Row():
283
+ blog_content_box = gr.Textbox(label="๋ธ”๋กœ๊ทธ ๋‚ด์šฉ (์ˆ˜์ • ๊ฐ€๋Šฅ)", lines=10, placeholder="์Šคํฌ๋ž˜ํ•‘๋œ ๋ธ”๋กœ๊ทธ ๋‚ด์šฉ์ด ์—ฌ๊ธฐ์— ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค.")
284
+ with gr.Row():
285
+ remove_freq_checkbox = gr.Checkbox(label="๋นˆ๋„์ˆ˜1 ์ œ๊ฑฐ", value=False)
286
+ with gr.Row():
287
+ analyze_button = gr.Button("๋ถ„์„ ์‹คํ–‰")
288
+ with gr.Row():
289
+ analysis_result = gr.Dataframe(label="๋ถ„์„ ๊ฒฐ๊ณผ (๋‹จ์–ด, ๋นˆ๋„์ˆ˜, ๊ฒ€์ƒ‰๋Ÿ‰, ๋ธ”๋กœ๊ทธ๋ฌธ์„œ์ˆ˜ ๋“ฑ)")
290
+ with gr.Row():
291
+ analysis_excel = gr.File(label="Excel ๋‹ค์šด๋กœ๋“œ")
292
 
293
+ # ์Šคํฌ๋ž˜ํ•‘ ์‹คํ–‰ ์‹œ URL๋กœ๋ถ€ํ„ฐ ๋ธ”๋กœ๊ทธ ๋ณธ๋ฌธ ์Šคํฌ๋ž˜ํ•‘ ํ›„ ์ˆ˜์ • ๊ฐ€๋Šฅํ•œ ํ…์ŠคํŠธ ๋ฐ•์Šค์— ์ถœ๋ ฅ
294
+ scrape_button.click(fn=fetch_blog_content, inputs=blog_url_input, outputs=blog_content_box)
295
+ # ๋ถ„์„ ์‹คํ–‰ ์‹œ ์ˆ˜์ •๋œ ๋ธ”๋กœ๊ทธ ๋‚ด์šฉ์„ ๋Œ€์ƒ์œผ๋กœ ํ˜•ํƒœ์†Œ ๋ถ„์„ ๋ฐ ๊ฒ€์ƒ‰๋Ÿ‰/๋ธ”๋กœ๊ทธ๋ฌธ์„œ์ˆ˜ ์กฐํšŒ ์ง„ํ–‰
296
+ analyze_button.click(fn=morphological_analysis_and_enrich, inputs=[blog_content_box, remove_freq_checkbox], outputs=[analysis_result, analysis_excel])
 
 
 
 
 
 
 
 
297
 
298
  if __name__ == "__main__":
299
  debug_log("Gradio ์•ฑ ์‹คํ–‰ ์‹œ์ž‘")