Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,32 +1,32 @@
|
|
1 |
pip install transformers
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
-
pipe_ar = pipeline("question-answering",model='ZeyadAhmed/AraElectra-Arabic-SQuADv2-QA')
|
5 |
-
pipe_en = pipeline("question-answering",model='deepset/roberta-base-squad2')
|
6 |
|
7 |
def q_a(lang,text,question):
|
8 |
-
if lang == 'Arabic':
|
9 |
myinput = {
|
10 |
'question': question,
|
11 |
'context':text
|
12 |
}
|
13 |
-
return pipe_ar(myinput)['answer']
|
14 |
|
15 |
-
elif lang == 'English':
|
16 |
myinput = {
|
17 |
'question': question,
|
18 |
'context':text
|
19 |
}
|
20 |
-
return pipe_en(myinput)['answer']
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
app = gr.Interface(
|
26 |
fn= q_a,
|
27 |
-
inputs=[gr.Radio(['Arabic', 'English'], label='Select Language',value= 'Arabic'),
|
28 |
-
gr.Textbox(label = 'enter text',lines=10)
|
29 |
-
gr.Textbox(label = 'enter question')]
|
30 |
-
outputs=gr.Textbox(label = 'answer')
|
31 |
)
|
32 |
app.launch()
|
|
|
1 |
pip install transformers
|
2 |
from transformers import pipeline
|
3 |
import gradio as gr
|
4 |
+
pipe_ar = pipeline("question-answering",model='ZeyadAhmed/AraElectra-Arabic-SQuADv2-QA')
|
5 |
+
pipe_en = pipeline("question-answering",model='deepset/roberta-base-squad2')
|
6 |
|
7 |
def q_a(lang,text,question):
|
8 |
+
if lang == 'Arabic':
|
9 |
myinput = {
|
10 |
'question': question,
|
11 |
'context':text
|
12 |
}
|
13 |
+
return pipe_ar(myinput)['answer']
|
14 |
|
15 |
+
elif lang == 'English':
|
16 |
myinput = {
|
17 |
'question': question,
|
18 |
'context':text
|
19 |
}
|
20 |
+
return pipe_en(myinput)['answer']
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
app = gr.Interface(
|
26 |
fn= q_a,
|
27 |
+
inputs=[gr.Radio(['Arabic', 'English'], label='Select Language',value= 'Arabic'),
|
28 |
+
gr.Textbox(label = 'enter text',lines=10),
|
29 |
+
gr.Textbox(label = 'enter question')],
|
30 |
+
outputs=gr.Textbox(label = 'answer')
|
31 |
)
|
32 |
app.launch()
|