Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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 |
-
#
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
285 |
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
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 ์ฑ ์คํ ์์")
|