Mubarak2507 commited on
Commit
19be099
·
verified ·
1 Parent(s): e649907

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -30
app.py CHANGED
@@ -30,41 +30,61 @@ def analyze(text):
30
  return hate_label, f"{hate_conf:.2f}", dial_label, f"{dial_conf:.2f}", f"{score:.2f}", action
31
 
32
 
33
- with gr.Blocks() as demo:
34
- with gr.Row():
35
- # Sidebar
 
 
 
 
 
 
 
 
 
 
36
  with gr.Column(scale=1):
37
- gr.Markdown("""
38
- ## 🛡️ Arabic Content Safety Analyzer
 
 
39
 
40
- **Purpose:**
41
- Analyze Arabic text for harmful or threatening language.
42
 
43
- **Features:**
44
- - **Hate Speech Classification** (e.g., Offensive, Racism, Sexism, Religious Discrimination)
45
- - **Dialect Detection** (e.g., Gulf, Levant, Egyptian, MSA)
46
- - **Threat Severity Score** (0–1 scale based on type and confidence)
47
- - **Recommended Action** (automated moderation suggestion)
48
 
49
- **How to Use:**
50
- 1. Enter Arabic text in the box.
51
- 2. Click **Analyze**.
52
- 3. Review the results and suggested action.
53
- """)
 
54
 
55
- # Main app
56
  with gr.Column(scale=3):
57
  gr.Markdown("### Enter Arabic Text for Analysis")
 
58
  input_text = gr.Textbox(lines=4, placeholder="اكتب هنا...", label="Arabic Text")
59
- outputs = [
60
- gr.Text(label="Hate Speech Label"),
61
- gr.Text(label="Label Confidence"),
62
- gr.Text(label="Dialect"),
63
- gr.Text(label="Dialect Confidence"),
64
- gr.Text(label="Threat Score"),
65
- gr.Text(label="Recommended Action")
66
- ]
67
- submit_btn = gr.Button("Analyze")
68
- submit_btn.click(fn=analyze, inputs=input_text, outputs=outputs)
69
-
70
- demo.launch()
 
 
 
 
 
 
 
30
  return hate_label, f"{hate_conf:.2f}", dial_label, f"{dial_conf:.2f}", f"{score:.2f}", action
31
 
32
 
33
+ # ---------- UI (Blocks with Sidebar) ----------
34
+ SIDEBAR_CSS = """
35
+ #sidebar-panel {
36
+ background: #2b2b2b; /* darker grey than main area (good for dark theme) */
37
+ border: 1px solid rgba(255,255,255,0.08);
38
+ border-radius: 10px;
39
+ padding: 18px;
40
+ }
41
+ """
42
+
43
+ with gr.Blocks(css=SIDEBAR_CSS, theme="default") as demo:
44
+ with gr.Row(equal_height=True):
45
+ # Sidebar (left)
46
  with gr.Column(scale=1):
47
+ with gr.Group(elem_id="sidebar-panel"):
48
+ gr.Markdown(
49
+ """
50
+ ## 🛡️ Arabic Content Safety Analyzer
51
 
52
+ **Purpose**
53
+ Analyze Arabic text for harmful or threatening language.
54
 
55
+ **Features**
56
+ - **Hate Speech Classification** (Offensive, Racism, Sexism, Religious Discrimination)
57
+ - **Dialect Detection** (Gulf, Levant, Egyptian, MSA)
58
+ - **Threat Severity Score** (0–1 based on label + confidence)
59
+ - **Recommended Action** (rule-based suggestion)
60
 
61
+ **How to Use**
62
+ 1. Enter Arabic text in the box.
63
+ 2. Click **Analyze**.
64
+ 3. Review the results and suggested action.
65
+ """
66
+ )
67
 
68
+ # Main app (right)
69
  with gr.Column(scale=3):
70
  gr.Markdown("### Enter Arabic Text for Analysis")
71
+
72
  input_text = gr.Textbox(lines=4, placeholder="اكتب هنا...", label="Arabic Text")
73
+
74
+ out_hate = gr.Textbox(label="Hate Speech Label", interactive=False)
75
+ out_hate_conf = gr.Textbox(label="Label Confidence", interactive=False)
76
+ out_dialect = gr.Textbox(label="Dialect", interactive=False)
77
+ out_dialect_conf = gr.Textbox(label="Dialect Confidence", interactive=False)
78
+ out_score = gr.Textbox(label="Threat Score", interactive=False)
79
+ out_action = gr.Textbox(label="Recommended Action", interactive=False)
80
+
81
+ analyze_btn = gr.Button("Analyze", variant="primary")
82
+ analyze_btn.click(
83
+ fn=analyze,
84
+ inputs=input_text,
85
+ outputs=[out_hate, out_hate_conf, out_dialect, out_dialect_conf, out_score, out_action],
86
+ )
87
+
88
+ # ---------- Launch ----------
89
+ if __name__ == "__main__":
90
+ demo.launch()