Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
CHANGED
@@ -21,38 +21,38 @@ def question_model():
|
|
21 |
return question_answerer
|
22 |
|
23 |
|
24 |
-
if option == "Extractive question answering":
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
button = st.button("Get answer")
|
37 |
if button:
|
38 |
-
with st.spinner(text="Loading
|
39 |
question_answerer = question_model()
|
40 |
with st.spinner(text="Getting answer..."):
|
41 |
answer = question_answerer(context=context, question=question)
|
42 |
answer = answer["answer"]
|
43 |
st.text(answer)
|
44 |
-
elif source == "I want to upload a file":
|
45 |
-
uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
|
46 |
-
if uploaded_file is not None:
|
47 |
-
raw_text = str(uploaded_file.read(),"utf-8")
|
48 |
-
context = st.text_area("", value=raw_text, height=330)
|
49 |
-
question = st.text_input(label="Enter your question", value=sample_question)
|
50 |
-
button = st.button("Get answer")
|
51 |
-
if button:
|
52 |
-
with st.spinner(text="Loading summarization model..."):
|
53 |
-
question_answerer = question_model()
|
54 |
-
with st.spinner(text="Getting answer..."):
|
55 |
-
answer = question_answerer(context=context, question=question)
|
56 |
-
answer = answer["answer"]
|
57 |
-
st.text(answer)
|
58 |
|
|
|
21 |
return question_answerer
|
22 |
|
23 |
|
24 |
+
# if option == "Extractive question answering":
|
25 |
+
st.markdown("<h2 style='text-align: center; color:grey;'>Extractive Question Answering</h2>", unsafe_allow_html=True)
|
26 |
+
st.markdown("<h3 style='text-align: left; color:#F63366; font-size:18px;'><b>What is extractive question answering about?<b></h3>", unsafe_allow_html=True)
|
27 |
+
st.write("Extractive question answering is a Natural Language Processing task where text is provided for a model so that the model can refer to it and make predictions about where the answer to a question is.")
|
28 |
+
st.markdown('___')
|
29 |
+
source = st.radio("How would you like to start? Choose an option below", ["I want to input some text", "I want to upload a file"])
|
30 |
+
sample_question = "What did the shepherd boy do to amuse himself?"
|
31 |
+
if source == "I want to input some text":
|
32 |
+
with open("sample.txt", "r") as text_file:
|
33 |
+
sample_text = text_file.read()
|
34 |
+
context = st.text_area("Use the example below or input your own text in English (10,000 characters max)", value=sample_text, max_chars=10000, height=330)
|
35 |
+
question = st.text_input(label="Use the question below or enter your own question", value=sample_question)
|
36 |
+
button = st.button("Get answer")
|
37 |
+
if button:
|
38 |
+
with st.spinner(text="Loading question model..."):
|
39 |
+
question_answerer = question_model()
|
40 |
+
with st.spinner(text="Getting answer..."):
|
41 |
+
answer = question_answerer(context=context, question=question)
|
42 |
+
answer = answer["answer"]
|
43 |
+
st.text(answer)
|
44 |
+
elif source == "I want to upload a file":
|
45 |
+
uploaded_file = st.file_uploader("Choose a .txt file to upload", type=["txt"])
|
46 |
+
if uploaded_file is not None:
|
47 |
+
raw_text = str(uploaded_file.read(),"utf-8")
|
48 |
+
context = st.text_area("", value=raw_text, height=330)
|
49 |
+
question = st.text_input(label="Enter your question", value=sample_question)
|
50 |
button = st.button("Get answer")
|
51 |
if button:
|
52 |
+
with st.spinner(text="Loading summarization model..."):
|
53 |
question_answerer = question_model()
|
54 |
with st.spinner(text="Getting answer..."):
|
55 |
answer = question_answerer(context=context, question=question)
|
56 |
answer = answer["answer"]
|
57 |
st.text(answer)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
|