Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -31,30 +31,24 @@ def bullete(text,wikipedia_language="en"):
|
|
| 31 |
result = list(filter(lambda x: x != '', final_out.split('\n\n')))
|
| 32 |
|
| 33 |
answer = []
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
}
|
| 53 |
-
print(QA_input)
|
| 54 |
-
res = nlp(QA_input)
|
| 55 |
-
values = list(res.values())[3]
|
| 56 |
-
|
| 57 |
-
return values
|
| 58 |
|
| 59 |
|
| 60 |
interface = gr.Interface(fn=bullete,
|
|
@@ -62,4 +56,4 @@ interface = gr.Interface(fn=bullete,
|
|
| 62 |
outputs="text",
|
| 63 |
title='Bullet Point')
|
| 64 |
|
| 65 |
-
interface.launch(inline=False)
|
|
|
|
| 31 |
result = list(filter(lambda x: x != '', final_out.split('\n\n')))
|
| 32 |
|
| 33 |
answer = []
|
| 34 |
+
try:
|
| 35 |
+
for i in range(len(result[0].split('.'))):
|
| 36 |
+
nlp = pipeline('question-answering', model=model_name, tokenizer=model_name)
|
| 37 |
+
QA_input = {
|
| 38 |
+
'question': text,
|
| 39 |
+
'context': result[0].split('.')[i]
|
| 40 |
+
}
|
| 41 |
+
res = nlp(QA_input)
|
| 42 |
+
print(QA_input)
|
| 43 |
+
values = list(res.values())[3]
|
| 44 |
+
answer.append(values)
|
| 45 |
+
except:
|
| 46 |
+
gen_output = []
|
| 47 |
+
for i in range(len(answer)):
|
| 48 |
+
gen_output.append("* " + answer[i] + ".")
|
| 49 |
+
paraphrase = "\n".join(gen_output)
|
| 50 |
+
final_answer = paraphrase.replace(" ", " ")
|
| 51 |
+
return final_answer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
interface = gr.Interface(fn=bullete,
|
|
|
|
| 56 |
outputs="text",
|
| 57 |
title='Bullet Point')
|
| 58 |
|
| 59 |
+
interface.launch(inline=False)
|