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,32 @@ 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 |
-
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 analyze_blog_by_url(url: str, remove_freq1: bool):
|
270 |
+
debug_log("analyze_blog_by_url ํจ์ ์์")
|
271 |
+
# ๋ธ๋ก๊ทธ ๋งํฌ๋ฅผ ํตํด ๋ด์ฉ ์คํฌ๋ํ
|
272 |
+
blog_text = scrape_naver_blog(url)
|
273 |
+
debug_log(f"์คํฌ๋ํ๋ ๋ธ๋ก๊ทธ ๋ด์ฉ(์ผ๋ถ): {blog_text[:100]}")
|
274 |
+
# ์คํฌ๋ํ๋ ๋ด์ฉ์ ๋ฐ๋ก ๋ถ์ ํ
์คํธ๋ก ํ์ฉ
|
275 |
+
analysis_df, analysis_excel = morphological_analysis_and_enrich(blog_text, remove_freq1)
|
276 |
+
debug_log("analyze_blog_by_url ํจ์ ์๋ฃ")
|
277 |
+
return analysis_df, analysis_excel
|
278 |
+
|
279 |
+
# Gradio ์ธํฐํ์ด์ค ๊ตฌ์ฑ (๋จ์ผ ํญ ๊ตฌ์ฑ)
|
280 |
+
with gr.Blocks(title="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ํํ์ ๋ถ์ ์คํ์ด์ค", css=".gradio-container { max-width: 960px; margin: auto; }") as demo:
|
281 |
+
gr.Markdown("# ๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ํํ์ ๋ถ์ ์คํ์ด์ค")
|
282 |
+
with gr.Row():
|
283 |
+
blog_url_input = gr.Textbox(label="๋ค์ด๋ฒ ๋ธ๋ก๊ทธ ๋งํฌ", placeholder="์: https://blog.naver.com/ssboost/222983068507", lines=1)
|
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 |
+
analyze_button.click(fn=analyze_blog_by_url, inputs=[blog_url_input, remove_freq_checkbox], outputs=[analysis_result, analysis_excel])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
295 |
if __name__ == "__main__":
|
296 |
debug_log("Gradio ์ฑ ์คํ ์์")
|