Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -15,9 +15,8 @@ def extract_text_from_pdf_file(pdf_file):
|
|
| 15 |
extracted_text = extract_text_from_pdf(pdf_file.name)
|
| 16 |
return extracted_text
|
| 17 |
|
| 18 |
-
def question_answering(pdf_file):
|
| 19 |
extracted_text = extract_text_from_pdf(pdf_file.name)
|
| 20 |
-
question = "Which name is also used to describe the Amazon rainforest in English?"
|
| 21 |
context = extracted_text
|
| 22 |
question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
|
| 23 |
result = question_answerer(question=question, context=context)
|
|
@@ -26,10 +25,9 @@ def question_answering(pdf_file):
|
|
| 26 |
title = 'PDF Text Extraction and Question Answering Demo'
|
| 27 |
|
| 28 |
iface = gr.Interface(fn=question_answering,
|
| 29 |
-
inputs="file",
|
| 30 |
outputs="text",
|
| 31 |
title=title,
|
| 32 |
-
description="Upload a PDF file
|
| 33 |
theme="peach")
|
| 34 |
-
|
| 35 |
iface.launch()
|
|
|
|
| 15 |
extracted_text = extract_text_from_pdf(pdf_file.name)
|
| 16 |
return extracted_text
|
| 17 |
|
| 18 |
+
def question_answering(pdf_file, question):
|
| 19 |
extracted_text = extract_text_from_pdf(pdf_file.name)
|
|
|
|
| 20 |
context = extracted_text
|
| 21 |
question_answerer = pipeline("question-answering", model='distilbert-base-cased-distilled-squad')
|
| 22 |
result = question_answerer(question=question, context=context)
|
|
|
|
| 25 |
title = 'PDF Text Extraction and Question Answering Demo'
|
| 26 |
|
| 27 |
iface = gr.Interface(fn=question_answering,
|
| 28 |
+
inputs=["file", "text"],
|
| 29 |
outputs="text",
|
| 30 |
title=title,
|
| 31 |
+
description="Upload a PDF file and ask a question about its content to get an answer.",
|
| 32 |
theme="peach")
|
|
|
|
| 33 |
iface.launch()
|