Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -465,9 +465,13 @@ with gr.Blocks(title="Multilingual Sentiment Analysis") as demo:
|
|
| 465 |
- Roman Urdu: tahamueed23/roman-urdu-sentiment
|
| 466 |
- Language detection: papluca/xlm-roberta-base-language-detection
|
| 467 |
""")
|
| 468 |
-
|
|
|
|
|
|
|
|
|
|
| 469 |
with gr.Row():
|
| 470 |
-
|
|
|
|
| 471 |
user_text = gr.Textbox(
|
| 472 |
label="βοΈ Enter Text",
|
| 473 |
placeholder="Type in English, Urdu, or Roman Urdu...",
|
|
@@ -478,27 +482,39 @@ with gr.Blocks(title="Multilingual Sentiment Analysis") as demo:
|
|
| 478 |
value="Auto Detect",
|
| 479 |
label="π Language Selection"
|
| 480 |
)
|
| 481 |
-
|
| 482 |
with gr.Row():
|
| 483 |
btn_analyze = gr.Button("π Analyze Sentiment", variant="primary")
|
| 484 |
btn_show = gr.Button("π Show Logs")
|
| 485 |
btn_clear = gr.Button("ποΈ Clear Logs")
|
| 486 |
-
|
| 487 |
-
|
|
|
|
| 488 |
out_sent = gr.Textbox(label="π Sentiment")
|
| 489 |
out_conf = gr.Textbox(label="π Confidence Score")
|
| 490 |
-
out_exp = gr.Textbox(label="π‘ Detailed Explanation")
|
| 491 |
out_strong = gr.Textbox(label="πͺ Strong Words")
|
| 492 |
out_file = gr.File(label="β¬οΈ Download Logs")
|
| 493 |
-
|
| 494 |
-
|
| 495 |
-
|
| 496 |
-
|
| 497 |
-
|
| 498 |
-
|
| 499 |
-
|
| 500 |
-
|
| 501 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 502 |
btn_analyze.click(
|
| 503 |
analyze_sentiment_complete,
|
| 504 |
inputs=[user_text, lang_dropdown],
|
|
|
|
| 465 |
- Roman Urdu: tahamueed23/roman-urdu-sentiment
|
| 466 |
- Language detection: papluca/xlm-roberta-base-language-detection
|
| 467 |
""")
|
| 468 |
+
|
| 469 |
+
# -----------------------------
|
| 470 |
+
# TOP ROW (Two Blocks)
|
| 471 |
+
# -----------------------------
|
| 472 |
with gr.Row():
|
| 473 |
+
# Left block (Text input + buttons)
|
| 474 |
+
with gr.Column(scale=1):
|
| 475 |
user_text = gr.Textbox(
|
| 476 |
label="βοΈ Enter Text",
|
| 477 |
placeholder="Type in English, Urdu, or Roman Urdu...",
|
|
|
|
| 482 |
value="Auto Detect",
|
| 483 |
label="π Language Selection"
|
| 484 |
)
|
| 485 |
+
|
| 486 |
with gr.Row():
|
| 487 |
btn_analyze = gr.Button("π Analyze Sentiment", variant="primary")
|
| 488 |
btn_show = gr.Button("π Show Logs")
|
| 489 |
btn_clear = gr.Button("ποΈ Clear Logs")
|
| 490 |
+
|
| 491 |
+
# Right block (output results)
|
| 492 |
+
with gr.Column(scale=1):
|
| 493 |
out_sent = gr.Textbox(label="π Sentiment")
|
| 494 |
out_conf = gr.Textbox(label="π Confidence Score")
|
| 495 |
+
out_exp = gr.Textbox(label="π‘ Detailed Explanation", lines=4)
|
| 496 |
out_strong = gr.Textbox(label="πͺ Strong Words")
|
| 497 |
out_file = gr.File(label="β¬οΈ Download Logs")
|
| 498 |
+
|
| 499 |
+
# -----------------------------
|
| 500 |
+
# BOTTOM ROW (Two Blocks)
|
| 501 |
+
# -----------------------------
|
| 502 |
+
with gr.Row():
|
| 503 |
+
# Left block (analysis history)
|
| 504 |
+
with gr.Column(scale=1):
|
| 505 |
+
logs_df = gr.Dataframe(
|
| 506 |
+
headers=["Sentence", "Language", "Sentiment", "Confidence", "Strong_Words", "Timestamp"],
|
| 507 |
+
label="π Analysis History",
|
| 508 |
+
interactive=False,
|
| 509 |
+
wrap=True,
|
| 510 |
+
height=350
|
| 511 |
+
)
|
| 512 |
+
|
| 513 |
+
# Right block can be empty or used later
|
| 514 |
+
with gr.Column(scale=1):
|
| 515 |
+
gr.Markdown("")
|
| 516 |
+
|
| 517 |
+
# Event handlers
|
| 518 |
btn_analyze.click(
|
| 519 |
analyze_sentiment_complete,
|
| 520 |
inputs=[user_text, lang_dropdown],
|