Spaces:
Sleeping
Sleeping
Updated app.py
Browse files
app.py
CHANGED
@@ -16,8 +16,9 @@ st.set_page_config(page_title="Automated Question Answering System") # set pa
|
|
16 |
# heading
|
17 |
st.markdown("<h2 style='text-align: center;'>Question Answering on Academic Essays</h2>", unsafe_allow_html=True)
|
18 |
# description
|
19 |
-
st.markdown("<h3 style='text-align: left; color:#F63366; font-size:18px;'><b>What is
|
20 |
-
st.write("
|
|
|
21 |
|
22 |
# store the model in cache resources to enhance efficiency (ref: https://docs.streamlit.io/library/advanced-features/caching)
|
23 |
@st.cache_resource(show_spinner=True)
|
@@ -67,7 +68,7 @@ def extract_text(file_path):
|
|
67 |
|
68 |
#-------------------- Main Webpage --------------------
|
69 |
# choose the source with different tabs
|
70 |
-
tab1, tab2 = st.tabs(["Input
|
71 |
|
72 |
#---------- input text ----------
|
73 |
# if type the text as input
|
@@ -81,13 +82,7 @@ with tab1:
|
|
81 |
context = st.session_state.get("contextInput", "")
|
82 |
question = st.session_state.get("questionInput", "")
|
83 |
|
84 |
-
|
85 |
-
example = st.button("Try example")
|
86 |
-
|
87 |
-
# Update the values if the "Try example" button is clicked
|
88 |
-
if example:
|
89 |
-
context = sample_text
|
90 |
-
question = sample_question
|
91 |
|
92 |
# Display the text area and text input with the updated or default values
|
93 |
context = st.text_area("Enter the essay below:", value=context, key="contextInput", height=330)
|
@@ -95,6 +90,15 @@ with tab1:
|
|
95 |
|
96 |
# perform question answering when "get answer" button clicked
|
97 |
button = st.button("Get answer", key="textInput")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
if button:
|
99 |
if context=="" or question=="":
|
100 |
st.error ("Please enter BOTH the context and the question", icon="🚨")
|
@@ -105,7 +109,7 @@ with tab1:
|
|
105 |
# if upload file as input
|
106 |
with tab2:
|
107 |
# provide upload place
|
108 |
-
uploaded_file = st.file_uploader("
|
109 |
|
110 |
# Create a session-level variable to track the uploaded file
|
111 |
if 'file' not in st.session_state:
|
|
|
16 |
# heading
|
17 |
st.markdown("<h2 style='text-align: center;'>Question Answering on Academic Essays</h2>", unsafe_allow_html=True)
|
18 |
# description
|
19 |
+
st.markdown("<h3 style='text-align: left; color:#F63366; font-size:18px;'><b>What is this project about?<b></h3>", unsafe_allow_html=True)
|
20 |
+
st.write("The project is to develop a web-based automated question-and-answer system for academic essays using natural language processing (NLP). Users can enter the essay and ask questions about it, and the system will automatically create answers.")
|
21 |
+
st.write("Click 'Input Text' or 'Upload File' to start experience the system. ")
|
22 |
|
23 |
# store the model in cache resources to enhance efficiency (ref: https://docs.streamlit.io/library/advanced-features/caching)
|
24 |
@st.cache_resource(show_spinner=True)
|
|
|
68 |
|
69 |
#-------------------- Main Webpage --------------------
|
70 |
# choose the source with different tabs
|
71 |
+
tab1, tab2 = st.tabs(["Input Text", "Upload File"])
|
72 |
|
73 |
#---------- input text ----------
|
74 |
# if type the text as input
|
|
|
82 |
context = st.session_state.get("contextInput", "")
|
83 |
question = st.session_state.get("questionInput", "")
|
84 |
|
85 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
|
87 |
# Display the text area and text input with the updated or default values
|
88 |
context = st.text_area("Enter the essay below:", value=context, key="contextInput", height=330)
|
|
|
90 |
|
91 |
# perform question answering when "get answer" button clicked
|
92 |
button = st.button("Get answer", key="textInput")
|
93 |
+
|
94 |
+
# Button to try the example
|
95 |
+
example = st.button("Try with example")
|
96 |
+
|
97 |
+
# Update the values if the "Try with example" button is clicked
|
98 |
+
if example:
|
99 |
+
context = sample_text
|
100 |
+
question = sample_question
|
101 |
+
|
102 |
if button:
|
103 |
if context=="" or question=="":
|
104 |
st.error ("Please enter BOTH the context and the question", icon="🚨")
|
|
|
109 |
# if upload file as input
|
110 |
with tab2:
|
111 |
# provide upload place
|
112 |
+
uploaded_file = st.file_uploader("Upload essay in PDF format:", type=["pdf"])
|
113 |
|
114 |
# Create a session-level variable to track the uploaded file
|
115 |
if 'file' not in st.session_state:
|