Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -242,14 +242,19 @@ def fetch_blog_content(url: str):
|
|
| 242 |
debug_log("fetch_blog_content ν¨μ μλ£")
|
| 243 |
return content
|
| 244 |
|
| 245 |
-
# μλ‘μ΄ κΈ°λ₯: ννμ λΆμ λ° κ²μλ, λΈλ‘κ·Έλ¬Έμμ μΆκ°
|
| 246 |
-
def morphological_analysis_and_enrich(text: str):
|
| 247 |
debug_log("morphological_analysis_and_enrich ν¨μ μμ")
|
| 248 |
df_freq, _ = analyze_text(text)
|
| 249 |
if df_freq.empty:
|
| 250 |
debug_log("ννμ λΆμ κ²°κ³Όκ° λΉ λ°μ΄ν°νλ μμ
λλ€.")
|
| 251 |
return df_freq, ""
|
| 252 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 253 |
# ννμ λΆμ κ²°κ³Όμμ ν€μλ μΆμΆ (κ° λ¨μ΄λ₯Ό μν°λ‘ ꡬλΆ)
|
| 254 |
keywords = "\n".join(df_freq["λ¨μ΄"].tolist())
|
| 255 |
debug_log(f"λΆμλ ν€μλ: {keywords}")
|
|
@@ -281,13 +286,15 @@ with gr.Blocks(title="λΈλ‘κ·ΈκΈ ννμ λΆμ μ€νμ΄μ€", css=".gradio-
|
|
| 281 |
with gr.Tab("ννμ λΆμ"):
|
| 282 |
with gr.Row():
|
| 283 |
analysis_input = gr.Textbox(label="λΆμν ν
μ€νΈ", lines=10, placeholder="λΆμν ν
μ€νΈλ₯Ό μ
λ ₯νκ±°λ 'λΈλ‘κ·Έ λ΄μ© κ°μ Έμ€κΈ°'μμ κ°μ Έμ¨ λ΄μ©μ μμ νμΈμ.")
|
|
|
|
|
|
|
| 284 |
with gr.Row():
|
| 285 |
analyze_button = gr.Button("ννμλΆμ")
|
| 286 |
with gr.Row():
|
| 287 |
analysis_result = gr.Dataframe(label="λΆμ κ²°κ³Ό (λ¨μ΄, λΉλμ, κ²μλ, λΈλ‘κ·Έλ¬Έμμ λ±)")
|
| 288 |
with gr.Row():
|
| 289 |
analysis_excel = gr.File(label="Excel λ€μ΄λ‘λ")
|
| 290 |
-
analyze_button.click(fn=morphological_analysis_and_enrich, inputs=analysis_input, outputs=[analysis_result, analysis_excel])
|
| 291 |
|
| 292 |
if __name__ == "__main__":
|
| 293 |
debug_log("Gradio μ± μ€ν μμ")
|
|
|
|
| 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)
|
| 249 |
if df_freq.empty:
|
| 250 |
debug_log("ννμ λΆμ κ²°κ³Όκ° λΉ λ°μ΄ν°νλ μμ
λλ€.")
|
| 251 |
return df_freq, ""
|
| 252 |
|
| 253 |
+
if remove_freq1:
|
| 254 |
+
before_shape = df_freq.shape
|
| 255 |
+
df_freq = df_freq[df_freq["λΉλμ"] != 1]
|
| 256 |
+
debug_log(f"λΉλμ 1 μ κ±° μ μ©λ¨. {before_shape} -> {df_freq.shape}")
|
| 257 |
+
|
| 258 |
# ννμ λΆμ κ²°κ³Όμμ ν€μλ μΆμΆ (κ° λ¨μ΄λ₯Ό μν°λ‘ ꡬλΆ)
|
| 259 |
keywords = "\n".join(df_freq["λ¨μ΄"].tolist())
|
| 260 |
debug_log(f"λΆμλ ν€μλ: {keywords}")
|
|
|
|
| 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 μ± μ€ν μμ")
|