Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -175,8 +175,9 @@ if uploaded_file:
|
|
175 |
result_path = os.path.join(
|
176 |
results_dir, "temp_file_result.json" if clipboard_use else f"{uploaded_file.name}_result.json")
|
177 |
|
|
|
|
|
178 |
# Display extracted text
|
179 |
-
st.subheader("Extracted Text (Cleaned & Polished)")
|
180 |
if 'cleaned_text' not in st.session_state:
|
181 |
st.session_state.cleaned_text = ""
|
182 |
if 'polished_text' not in st.session_state:
|
@@ -224,19 +225,21 @@ if uploaded_file:
|
|
224 |
st.session_state.cleaned_text = cleaned_text
|
225 |
st.session_state.polished_text = polished_text
|
226 |
|
227 |
-
# Display extracted text
|
228 |
-
st.
|
229 |
-
st.markdown(st.session_state.
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
|
|
|
|
|
175 |
result_path = os.path.join(
|
176 |
results_dir, "temp_file_result.json" if clipboard_use else f"{uploaded_file.name}_result.json")
|
177 |
|
178 |
+
cleaned_text = ""
|
179 |
+
polished_text = ""
|
180 |
# Display extracted text
|
|
|
181 |
if 'cleaned_text' not in st.session_state:
|
182 |
st.session_state.cleaned_text = ""
|
183 |
if 'polished_text' not in st.session_state:
|
|
|
225 |
st.session_state.cleaned_text = cleaned_text
|
226 |
st.session_state.polished_text = polished_text
|
227 |
|
228 |
+
# Display extracted text
|
229 |
+
st.subheader("Extracted Text (Cleaned & Polished)")
|
230 |
+
st.markdown(st.session_state.cleaned_text, unsafe_allow_html=True)
|
231 |
+
st.markdown(st.session_state.polished_text, unsafe_allow_html=True)
|
232 |
+
|
233 |
+
if os.path.exists(result_path):
|
234 |
+
# Input search term with real-time update on key press
|
235 |
+
search_query = st_keyup("Search in extracted text:")
|
236 |
+
|
237 |
+
if search_query:
|
238 |
+
index = st.session_state.cleaned_text.find(search_query)
|
239 |
+
start = index
|
240 |
+
len = search_query.length
|
241 |
+
end = index + len
|
242 |
+
if index != -1:
|
243 |
+
highlight_text(st.session_state.cleaned_text, start, end)
|
244 |
+
else:
|
245 |
+
st.write("No Search Found.")
|