Mubarak2507 commited on
Commit
dc07e95
·
verified ·
1 Parent(s): 42b8010

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -17
app.py CHANGED
@@ -30,21 +30,41 @@ def analyze(text):
30
  return hate_label, f"{hate_conf:.2f}", dial_label, f"{dial_conf:.2f}", f"{score:.2f}", action
31
 
32
 
33
- iface = gr.Interface(
34
- fn=analyze,
35
- inputs=gr.Textbox(lines=4, placeholder="اكتب هنا...", label="Arabic Text"),
36
- outputs=[
37
- gr.Text(label="Hate Speech Label"),
38
- gr.Text(label="Label Confidence"),
39
- gr.Text(label="Dialect"),
40
- gr.Text(label="Dialect Confidence"),
41
- gr.Text(label="Threat Score"),
42
- gr.Text(label="Recommended Action")
43
- ],
44
- title="🛡️ Arabic Content Safety Analyzer",
45
- description="Classifies Arabic text for hate speech, detects dialect, assigns threat severity score, and recommends action.",
46
- theme="default"
47
- )
48
-
49
- iface.launch()
50
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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()