Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# تحميل النموذج مرة واحدة عند بدء التشغيل
|
| 5 |
+
sentiment_pipeline = pipeline(
|
| 6 |
+
"sentiment-analysis",
|
| 7 |
+
model="CAMeL-Lab/bert-base-arabic-camelbert-da-sentiment"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
def analyze(text):
|
| 11 |
+
result = sentiment_pipeline(text)
|
| 12 |
+
# استخراج التصنيف فقط (positive, negative, neutral)
|
| 13 |
+
return result[0]['label']
|
| 14 |
+
|
| 15 |
+
# إنشاء الواجهة
|
| 16 |
+
iface = gr.Interface(
|
| 17 |
+
fn=analyze,
|
| 18 |
+
inputs=gr.Textbox(lines=2, placeholder="اكتب النص هنا..."),
|
| 19 |
+
outputs="text",
|
| 20 |
+
title="تحليل المشاعر العربية",
|
| 21 |
+
description="نموذج لتحليل ما إذا كان النص إيجابيًا، سلبيًا، أم محايدًا."
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
+
iface.launch()
|