khaled06 commited on
Commit
38a3fa2
·
verified ·
1 Parent(s): f88ecf8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -10
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') # arabic model
5
- pipe_en = pipeline("question-answering",model='deepset/roberta-base-squad2') # english model
6
 
7
  def q_a(lang,text,question):
8
- if lang == 'Arabic': # if user select arabic
9
  myinput = {
10
  'question': question,
11
  'context':text
12
  }
13
- return pipe_ar(myinput)['answer'] # here will use pipe_ar which is the arabic model and return the answer
14
 
15
- elif lang == 'English': # user select english
16
  myinput = {
17
  'question': question,
18
  'context':text
19
  }
20
- return pipe_en(myinput)['answer'] #use english model
21
 
22
 
23
 
24
 
25
  app = gr.Interface(
26
  fn= q_a,
27
- inputs=[gr.Radio(['Arabic', 'English'], label='Select Language',value= 'Arabic'), # radio bottom for select the language and the defult languses will be arabic
28
- gr.Textbox(label = 'enter text',lines=10),# text box to enter the context
29
- gr.Textbox(label = 'enter question')],# text box for enter the question
30
- outputs=gr.Textbox(label = 'answer')# the output will display here
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()