File size: 800 Bytes
9c2391e
 
38a3fa2
 
9c2391e
 
38a3fa2
9c2391e
 
 
 
38a3fa2
9c2391e
38a3fa2
9c2391e
 
 
 
38a3fa2
9c2391e
 
 
 
a4c8a63
9c2391e
38a3fa2
 
 
 
9c2391e
a4c8a63
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from transformers import pipeline
import gradio as gr
pipe_ar = pipeline("question-answering",model='ZeyadAhmed/AraElectra-Arabic-SQuADv2-QA') 
pipe_en = pipeline("question-answering",model='deepset/roberta-base-squad2')

def q_a(lang,text,question):
  if lang == 'Arabic':
    myinput = {
      'question': question,
      'context':text
  }
    return pipe_ar(myinput)['answer']

  elif lang == 'English':
    myinput = {
    'question': question,
    'context':text
    }
    return pipe_en(myinput)['answer']




demo = gr.Interface(
    fn= q_a,
    inputs=[gr.Radio(['Arabic', 'English'], label='Select Language',value= 'Arabic'), 
            gr.Textbox(label = 'enter text',lines=10),
            gr.Textbox(label = 'enter question')],
    outputs=gr.Textbox(label = 'answer')
)
demo.launch()