Spaces:
Paused
Paused
Commit
·
01c2292
1
Parent(s):
158e92d
Update app.py
Browse files
app.py
CHANGED
@@ -21,12 +21,30 @@ def get_prediction(context, question):
|
|
21 |
def question_answer(context, question):
|
22 |
prediction = get_prediction(context,question)
|
23 |
return prediction
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
def greet(texts):
|
26 |
-
question =
|
27 |
-
answer =
|
28 |
-
# for question, answer in texts:
|
29 |
-
# question_answer(context, question)
|
30 |
return answer
|
31 |
|
32 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
21 |
def question_answer(context, question):
|
22 |
prediction = get_prediction(context,question)
|
23 |
return prediction
|
24 |
+
|
25 |
+
def split(texts):
|
26 |
+
words = word_tokenize(texts)
|
27 |
+
context, question = '', ''
|
28 |
+
act = False
|
29 |
+
|
30 |
+
for w in words:
|
31 |
+
if w == '///':
|
32 |
+
act = True
|
33 |
+
|
34 |
+
if act == False:
|
35 |
+
context += w + ' '
|
36 |
+
else:
|
37 |
+
if w == '///':
|
38 |
+
w = ''
|
39 |
+
question += w + ' '
|
40 |
+
|
41 |
+
context = context[:-1]
|
42 |
+
question = question[1:-1]
|
43 |
+
return context, question
|
44 |
|
45 |
def greet(texts):
|
46 |
+
context, question = split(texts)
|
47 |
+
answer = question_answer(context, question)
|
|
|
|
|
48 |
return answer
|
49 |
|
50 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|