Spaces:
Build error
Build error
BilalSardar
commited on
Commit
•
9ab118d
1
Parent(s):
50a201b
Update app.py
Browse files
app.py
CHANGED
@@ -247,39 +247,43 @@ output = gr.outputs.HTML( label="Question and Answers")
|
|
247 |
radiobutton = gr.inputs.Radio(["Wordnet", "Gensim"])
|
248 |
|
249 |
def generate_question(context1,radiobutton):
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
|
|
|
|
|
|
|
|
283 |
|
284 |
|
285 |
iface = gr.Interface(
|
|
|
247 |
radiobutton = gr.inputs.Radio(["Wordnet", "Gensim"])
|
248 |
|
249 |
def generate_question(context1,radiobutton):
|
250 |
+
try:
|
251 |
+
UrlToAudio(context1)
|
252 |
+
f = open("The_audio.txt", "r")
|
253 |
+
context=f.read()
|
254 |
+
summary_text = summarizer(context,summary_model,summary_tokenizer)
|
255 |
+
for wrp in wrap(summary_text, 150):
|
256 |
+
print (wrp)
|
257 |
+
# np = getnounphrases(summary_text,sentence_transformer_model,3)
|
258 |
+
np = get_keywords(context,summary_text)
|
259 |
+
print ("\n\nNoun phrases",np)
|
260 |
+
output=""
|
261 |
+
for answer in np:
|
262 |
+
ques = get_question(summary_text,answer,question_model,question_tokenizer)
|
263 |
+
if radiobutton=="Wordnet":
|
264 |
+
distractors = get_distractors_wordnet(answer)
|
265 |
+
else:
|
266 |
+
distractors = generate_distractors(answer.capitalize(),3)
|
267 |
+
print(distractors)
|
268 |
+
|
269 |
+
# output= output + ques + "\n" + "Ans: "+answer.capitalize() + "\n\n"
|
270 |
+
output ="\n"+ output + "<b style='color:blue;'>" + ques + "</b>"
|
271 |
+
# output = output + "<br>"
|
272 |
+
output ="\n"+ output + "<b style='color:green;'>" + "Ans: " +answer.capitalize()+ "</b>"
|
273 |
+
if len(distractors)>0:
|
274 |
+
for distractor in distractors[:4]:
|
275 |
+
output = output + " <b style='color:brown;'>" + distractor+ "</b>\n"
|
276 |
+
output = output + "<br>"
|
277 |
+
|
278 |
+
summary ="Summary: "+ summary_text
|
279 |
+
for answer in np:
|
280 |
+
summary = summary.replace(answer,"<b>"+answer+"</b>")
|
281 |
+
summary = summary.replace(answer.capitalize(),"<b>"+answer.capitalize()+"</b>")
|
282 |
+
output = output + "<p>"+summary+"</p>"
|
283 |
+
return output
|
284 |
+
except:
|
285 |
+
return "Something Went Wrong...Please Check Link or try Again"
|
286 |
+
|
287 |
|
288 |
|
289 |
iface = gr.Interface(
|