tahamueed23 commited on
Commit
a7b66c5
Β·
verified Β·
1 Parent(s): 16b4ab7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +71 -15
app.py CHANGED
@@ -1,3 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
3
  import pandas as pd
@@ -466,8 +493,11 @@ with gr.Blocks(title="Multilingual Sentiment Analysis") as demo:
466
  - Language detection: papluca/xlm-roberta-base-language-detection
467
  """)
468
 
 
469
  with gr.Row():
470
- with gr.Column():
 
 
471
  user_text = gr.Textbox(
472
  label="✍️ Enter Text",
473
  placeholder="Type in English, Urdu, or Roman Urdu...",
@@ -484,21 +514,47 @@ with gr.Blocks(title="Multilingual Sentiment Analysis") as demo:
484
  btn_show = gr.Button("πŸ“‚ Show Logs")
485
  btn_clear = gr.Button("πŸ—‘οΈ Clear Logs")
486
 
487
- with gr.Column():
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
- logs_df = gr.Dataframe(
495
- headers=["Sentence", "Language", "Sentiment", "Confidence", "Strong_Words", "Timestamp"],
496
- label="πŸ“‹ Analysis History",
497
- interactive=False,
498
- wrap=True
499
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
500
 
501
- # Event handlers - FIXED: Added missing closing parenthesis
502
  btn_analyze.click(
503
  analyze_sentiment_complete,
504
  inputs=[user_text, lang_dropdown],
 
1
+ [file name]: image.png
2
+ [file content begin]
3
+ Enter Text
4
+
5
+ Type in English, Urdu, or Roman Urdu...
6
+
7
+ Language Selection
8
+ Auto Detect
9
+
10
+ Analyze Sentiment
11
+ Show Logs
12
+
13
+ Clear Logs
14
+
15
+ Sentiment
16
+ Confidence Score
17
+ Detailed Explanation
18
+ Strong Words
19
+
20
+ Download Logs
21
+
22
+ Analysis History
23
+ Sent_ Lang_Sent_ Conf_ Stro_Tima_
24
+
25
+
26
+ [file content end]
27
+
28
  import gradio as gr
29
  from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
30
  import pandas as pd
 
493
  - Language detection: papluca/xlm-roberta-base-language-detection
494
  """)
495
 
496
+ # Top row with two columns
497
  with gr.Row():
498
+ # Left column - Input section
499
+ with gr.Column(scale=1):
500
+ gr.Markdown("### πŸ“₯ Input Section")
501
  user_text = gr.Textbox(
502
  label="✍️ Enter Text",
503
  placeholder="Type in English, Urdu, or Roman Urdu...",
 
514
  btn_show = gr.Button("πŸ“‚ Show Logs")
515
  btn_clear = gr.Button("πŸ—‘οΈ Clear Logs")
516
 
517
+ # Right column - Results section
518
+ with gr.Column(scale=1):
519
+ gr.Markdown("### πŸ“Š Results")
520
+ with gr.Row():
521
+ with gr.Column():
522
+ out_sent = gr.Textbox(label="🎭 Sentiment")
523
+ out_conf = gr.Textbox(label="πŸ“Š Confidence Score")
524
+ with gr.Column():
525
+ out_strong = gr.Textbox(label="πŸ’ͺ Strong Words")
526
+ out_file = gr.File(label="⬇️ Download Logs")
527
+
528
+ out_exp = gr.Textbox(label="πŸ’‘ Detailed Explanation", lines=3)
529
+
530
+ # Bottom row with analysis history taking 75% width
531
+ with gr.Row():
532
+ with gr.Column(scale=3): # 75% width (3/4)
533
+ logs_df = gr.Dataframe(
534
+ headers=["Sentence", "Language", "Sentiment", "Confidence", "Strong_Words", "Timestamp"],
535
+ label="πŸ“‹ Analysis History",
536
+ interactive=False,
537
+ wrap=True,
538
+ height=400
539
+ )
540
+ with gr.Column(scale=1): # 25% width (1/4)
541
+ gr.Markdown("### ℹ️ Information")
542
+ gr.Markdown("""
543
+ **How to use:**
544
+ 1. Enter text in any supported language
545
+ 2. Select language or use Auto Detect
546
+ 3. Click Analyze Sentiment
547
+ 4. View results and history
548
+
549
+ **Supported Languages:**
550
+ - English
551
+ - Urdu (Script)
552
+ - Roman Urdu (Latin script)
553
+
554
+ **Note:** Auto Detect works best with clear text samples.
555
+ """)
556
 
557
+ # Event handlers
558
  btn_analyze.click(
559
  analyze_sentiment_complete,
560
  inputs=[user_text, lang_dropdown],