aml987 commited on
Commit
f52cdba
·
verified ·
1 Parent(s): fe62a63

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # تحميل نموذج معالجة اللغة العربية
5
+ qa_pipeline = pipeline("question-answering", model="aubmindlab/bert-base-arabertv02")
6
+
7
+ # دالة لمعالجة السؤال والإجابة
8
+ def answer_question(question, context):
9
+ result = qa_pipeline(question=question, context=context)
10
+ return result["answer"]
11
+
12
+ # إنشاء واجهة API باستخدام Gradio
13
+ iface = gr.Interface(
14
+ fn=answer_question,
15
+ inputs=["text", "text"],
16
+ outputs="text",
17
+ title="Arabic Grammar API",
18
+ description="API للإجابة على أسئلة الإعراب باللغة العربية",
19
+ )
20
+
21
+ # تشغيل الواجهة
22
+ iface.launch()