Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -279,10 +279,10 @@ def combined_analysis(blog_text: str, remove_freq1: bool, direct_keyword_input:
|
|
| 279 |
def analysis_handler(blog_text: str, remove_freq1: bool, direct_keyword_input: str, direct_keyword_only: bool):
|
| 280 |
debug_log("analysis_handler ν¨μ μμ")
|
| 281 |
if direct_keyword_only:
|
| 282 |
-
# μ§μ ν€μλ λΆμ
|
| 283 |
return direct_keyword_analysis(blog_text, direct_keyword_input)
|
| 284 |
else:
|
| 285 |
-
# ν΅ν© λΆμ
|
| 286 |
return combined_analysis(blog_text, remove_freq1, direct_keyword_input)
|
| 287 |
|
| 288 |
# --- μ€ν¬λν μ€ν ---
|
|
@@ -292,39 +292,96 @@ def fetch_blog_content(url: str):
|
|
| 292 |
debug_log("fetch_blog_content ν¨μ μλ£")
|
| 293 |
return content
|
| 294 |
|
| 295 |
-
# ---
|
| 296 |
custom_css = """
|
| 297 |
-
|
| 298 |
-
.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 299 |
"""
|
| 300 |
-
|
| 301 |
-
|
|
|
|
|
|
|
| 302 |
# λΈλ‘κ·Έ λ§ν¬μ μ€ν¬λν μ€ν λ²νΌμ ν κ·Έλ£Ή λ΄μ λ°°μΉ (λ²νΌμ κ°μ΄λ° μ λ ¬)
|
| 303 |
-
with gr.Group():
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
|
|
|
| 308 |
blog_content_box = gr.Textbox(label="λΈλ‘κ·Έ λ΄μ© (μμ κ°λ₯)", lines=10, placeholder="μ€ν¬λνλ λΈλ‘κ·Έ λ΄μ©μ΄ μ¬κΈ°μ νμλ©λλ€.")
|
| 309 |
-
with gr.
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
|
|
|
| 320 |
result_df = gr.Dataframe(label="ν΅ν© λΆμ κ²°κ³Ό (λ¨μ΄, λΉλμ, κ²μλ, λΈλ‘κ·Έλ¬Έμμ, μ§μ μ
λ ₯)", interactive=True)
|
| 321 |
-
with gr.
|
| 322 |
excel_file = gr.File(label="Excel λ€μ΄λ‘λ")
|
| 323 |
|
| 324 |
# μ΄λ²€νΈ μ°κ²°
|
| 325 |
scrape_button.click(fn=fetch_blog_content, inputs=blog_url_input, outputs=blog_content_box)
|
| 326 |
-
analyze_button.click(fn=analysis_handler,
|
| 327 |
-
|
|
|
|
| 328 |
|
| 329 |
if __name__ == "__main__":
|
| 330 |
debug_log("Gradio μ± μ€ν μμ")
|
|
|
|
| 279 |
def analysis_handler(blog_text: str, remove_freq1: bool, direct_keyword_input: str, direct_keyword_only: bool):
|
| 280 |
debug_log("analysis_handler ν¨μ μμ")
|
| 281 |
if direct_keyword_only:
|
| 282 |
+
# "μ§μ ν€μλ μ
λ ₯λ§ λΆμ" μ ν μ λ¨λ
λΆμ μν
|
| 283 |
return direct_keyword_analysis(blog_text, direct_keyword_input)
|
| 284 |
else:
|
| 285 |
+
# κΈ°λ³Έ ν΅ν© λΆμ μν
|
| 286 |
return combined_analysis(blog_text, remove_freq1, direct_keyword_input)
|
| 287 |
|
| 288 |
# --- μ€ν¬λν μ€ν ---
|
|
|
|
| 292 |
debug_log("fetch_blog_content ν¨μ μλ£")
|
| 293 |
return content
|
| 294 |
|
| 295 |
+
# --- Custom CSS ---
|
| 296 |
custom_css = """
|
| 297 |
+
/* μ 체 컨ν
μ΄λ μ€νμΌ */
|
| 298 |
+
.gradio-container {
|
| 299 |
+
max-width: 960px;
|
| 300 |
+
margin: auto;
|
| 301 |
+
font-family: 'Helvetica Neue', Arial, sans-serif;
|
| 302 |
+
background: #f5f7fa;
|
| 303 |
+
padding: 2rem;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/* ν€λ μ€νμΌ */
|
| 307 |
+
.custom-header {
|
| 308 |
+
text-align: center;
|
| 309 |
+
font-size: 2.5rem;
|
| 310 |
+
font-weight: bold;
|
| 311 |
+
margin-bottom: 1.5rem;
|
| 312 |
+
color: #333;
|
| 313 |
+
}
|
| 314 |
+
|
| 315 |
+
/* κ·Έλ£Ή λ°μ€ μ€νμΌ */
|
| 316 |
+
.custom-group {
|
| 317 |
+
background: #ffffff;
|
| 318 |
+
border-radius: 8px;
|
| 319 |
+
padding: 1.5rem;
|
| 320 |
+
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
|
| 321 |
+
margin-bottom: 1.5rem;
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
/* λ²νΌ μ€νμΌ */
|
| 325 |
+
.custom-button {
|
| 326 |
+
background-color: #007bff;
|
| 327 |
+
color: #fff;
|
| 328 |
+
border: none;
|
| 329 |
+
border-radius: 4px;
|
| 330 |
+
padding: 0.6rem 1.2rem;
|
| 331 |
+
font-size: 1rem;
|
| 332 |
+
cursor: pointer;
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
/* 체ν¬λ°μ€ μ€νμΌ */
|
| 336 |
+
.custom-checkbox {
|
| 337 |
+
margin-right: 1rem;
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
/* κ²°κ³Ό ν
μ΄λΈ λ° λ€μ΄λ‘λ λ²νΌ */
|
| 341 |
+
.custom-result {
|
| 342 |
+
margin-top: 1.5rem;
|
| 343 |
+
}
|
| 344 |
+
|
| 345 |
+
/* κ°μ΄λ° μ λ ¬ */
|
| 346 |
+
.centered {
|
| 347 |
+
display: flex;
|
| 348 |
+
justify-content: center;
|
| 349 |
+
align-items: center;
|
| 350 |
+
}
|
| 351 |
"""
|
| 352 |
+
|
| 353 |
+
# --- Gradio μΈν°νμ΄μ€ κ΅¬μ± ---
|
| 354 |
+
with gr.Blocks(title="λ€μ΄λ² λΈλ‘κ·Έ ννμ λΆμ μλΉμ€", css=custom_css) as demo:
|
| 355 |
+
gr.HTML("<div class='custom-header'>λ€μ΄λ² λΈλ‘κ·Έ ννμ λΆμ μλΉμ€</div>")
|
| 356 |
# λΈλ‘κ·Έ λ§ν¬μ μ€ν¬λν μ€ν λ²νΌμ ν κ·Έλ£Ή λ΄μ λ°°μΉ (λ²νΌμ κ°μ΄λ° μ λ ¬)
|
| 357 |
+
with gr.Group(elem_classes="custom-group"):
|
| 358 |
+
with gr.Row():
|
| 359 |
+
blog_url_input = gr.Textbox(label="λ€μ΄λ² λΈλ‘κ·Έ λ§ν¬", placeholder="μ: https://blog.naver.com/ssboost/222983068507", lines=1)
|
| 360 |
+
with gr.Row(elem_classes="centered"):
|
| 361 |
+
scrape_button = gr.Button("μ€ν¬λν μ€ν", elem_classes="custom-button")
|
| 362 |
+
with gr.Group(elem_classes="custom-group"):
|
| 363 |
blog_content_box = gr.Textbox(label="λΈλ‘κ·Έ λ΄μ© (μμ κ°λ₯)", lines=10, placeholder="μ€ν¬λνλ λΈλ‘κ·Έ λ΄μ©μ΄ μ¬κΈ°μ νμλ©λλ€.")
|
| 364 |
+
with gr.Group(elem_classes="custom-group"):
|
| 365 |
+
with gr.Row():
|
| 366 |
+
remove_freq_checkbox = gr.Checkbox(label="λΉλμ1 μ κ±°", value=True, elem_classes="custom-checkbox")
|
| 367 |
+
with gr.Row():
|
| 368 |
+
# "λΉλμ1 μ κ±°" μλμ "μ§μ ν€μλ μ
λ ₯λ§ λΆμ" 체ν¬λ°μ€ λ°°μΉ
|
| 369 |
+
direct_keyword_only_checkbox = gr.Checkbox(label="μ§μ ν€μλ μ
λ ₯λ§ λΆμ", value=False, elem_classes="custom-checkbox")
|
| 370 |
+
with gr.Row():
|
| 371 |
+
direct_keyword_box = gr.Textbox(label="μ§μ ν€μλ μ
λ ₯ (μν° λλ ','λ‘ κ΅¬λΆ)", lines=2, placeholder="μ: ν€μλ1, ν€μλ2\nν€μλ3")
|
| 372 |
+
with gr.Group(elem_classes="custom-group"):
|
| 373 |
+
with gr.Row(elem_classes="centered"):
|
| 374 |
+
analyze_button = gr.Button("λΆμ μ€ν", elem_classes="custom-button")
|
| 375 |
+
with gr.Group(elem_classes="custom-group custom-result"):
|
| 376 |
result_df = gr.Dataframe(label="ν΅ν© λΆμ κ²°κ³Ό (λ¨μ΄, λΉλμ, κ²μλ, λΈλ‘κ·Έλ¬Έμμ, μ§μ μ
λ ₯)", interactive=True)
|
| 377 |
+
with gr.Group(elem_classes="custom-group"):
|
| 378 |
excel_file = gr.File(label="Excel λ€μ΄λ‘λ")
|
| 379 |
|
| 380 |
# μ΄λ²€νΈ μ°κ²°
|
| 381 |
scrape_button.click(fn=fetch_blog_content, inputs=blog_url_input, outputs=blog_content_box)
|
| 382 |
+
analyze_button.click(fn=analysis_handler,
|
| 383 |
+
inputs=[blog_content_box, remove_freq_checkbox, direct_keyword_box, direct_keyword_only_checkbox],
|
| 384 |
+
outputs=[result_df, excel_file])
|
| 385 |
|
| 386 |
if __name__ == "__main__":
|
| 387 |
debug_log("Gradio μ± μ€ν μμ")
|