mohammedxxxxq commited on
Commit
b6f0e0d
·
verified ·
1 Parent(s): 4e92e20

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +39 -0
  2. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # تحميل النموذج
5
+ model = pipeline("text-classification",
6
+ model="CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment")
7
+
8
+ def analyze(text):
9
+ if not text.strip():
10
+ return "الرجاء إدخال نص للتحليل"
11
+
12
+ result = model(text)[0]
13
+ return f"المشاعر: {result['label']}, الثقة: {result['score']:.2%}"
14
+
15
+ # إنشاء واجهة أفضل مع تفاصيل
16
+ demo = gr.Interface(
17
+ fn=analyze,
18
+ inputs=gr.Textbox(
19
+ label="أدخل النص العربي",
20
+ placeholder="اكتب نصًا عربيًا هنا...",
21
+ lines=3
22
+ ),
23
+ outputs=gr.Textbox(
24
+ label="نتيجة تحليل المشاعر",
25
+ lines=2
26
+ ),
27
+ title="محلل المشاعر للنصوص العربية",
28
+ description="""
29
+ هذا التطبيق يحلل المشاعر في النصوص العربية باستخدام نموذج CAMeL-Lab/BERT.
30
+ يدعم: إيجابي ⚫ سلبي ⚫ محايد
31
+ """,
32
+ examples=[
33
+ ["المنتج رائع وأنا سعيد جدًا به"],
34
+ ["الخدمة كانت سيئة ومخيبة للآمال"],
35
+ ["التجربة عادية ولا بأس بها"]
36
+ ]
37
+ )
38
+
39
+ demo.launch()
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio>=4.0.0
2
+ transformers>=4.30.0
3
+ torch