Spaces:
Runtime error
Runtime error
flynn-chen
commited on
Commit
•
cff8766
1
Parent(s):
4086d0d
qg
Browse files
app.py
CHANGED
@@ -9,7 +9,6 @@ import pandas as pd
|
|
9 |
from question_generation.pipelines import pipeline
|
10 |
import docx2txt
|
11 |
|
12 |
-
qa_list = []
|
13 |
def process_file(Notes):
|
14 |
|
15 |
nlp = pipeline("question-generation", model="valhalla/t5-small-qg-prepend", qg_format="prepend")
|
@@ -36,17 +35,11 @@ def process_file(Notes):
|
|
36 |
if content == True:
|
37 |
processed_sentence_list.append(i.lstrip())
|
38 |
|
39 |
-
qa_list
|
40 |
formatted_questions = "\n".join([str(idx+1) + ". " + i["question"] for idx, i in enumerate(qa_list)])
|
41 |
formatted_answers = "\n".join([str(idx+1) + ". " + i["answer"] for idx, i in enumerate(qa_list)])
|
42 |
return [formatted_questions, formatted_answers]
|
43 |
|
44 |
-
def reveal_answer():
|
45 |
-
global qa_list
|
46 |
-
|
47 |
-
qa_list = []
|
48 |
-
return formatted_answers
|
49 |
-
|
50 |
io = gr.Interface(process_file, "file", outputs=
|
51 |
[gr.Textbox(lines=1, label="Questions"),
|
52 |
gr.Textbox(lines=1, label="Answers")])
|
|
|
9 |
from question_generation.pipelines import pipeline
|
10 |
import docx2txt
|
11 |
|
|
|
12 |
def process_file(Notes):
|
13 |
|
14 |
nlp = pipeline("question-generation", model="valhalla/t5-small-qg-prepend", qg_format="prepend")
|
|
|
35 |
if content == True:
|
36 |
processed_sentence_list.append(i.lstrip())
|
37 |
|
38 |
+
qa_list = nlp(" ".join(processed_sentence_list))
|
39 |
formatted_questions = "\n".join([str(idx+1) + ". " + i["question"] for idx, i in enumerate(qa_list)])
|
40 |
formatted_answers = "\n".join([str(idx+1) + ". " + i["answer"] for idx, i in enumerate(qa_list)])
|
41 |
return [formatted_questions, formatted_answers]
|
42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
io = gr.Interface(process_file, "file", outputs=
|
44 |
[gr.Textbox(lines=1, label="Questions"),
|
45 |
gr.Textbox(lines=1, label="Answers")])
|