UniquePratham commited on
Commit
77fc61e
·
verified ·
1 Parent(s): 8308624

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -17
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.markdown(st.session_state.cleaned_text, unsafe_allow_html=True)
229
- st.markdown(st.session_state.polished_text, unsafe_allow_html=True)
230
-
231
- # Input search term with real-time update on key press
232
- search_query = st_keyup("Search in extracted text:")
233
-
234
- if search_query:
235
- index = st.session_state.cleaned_text.find(search_query)
236
- start = index
237
- len = search_query.length
238
- end = index + len
239
- if index != -1:
240
- highlight_text(st.session_state.cleaned_text, start, end)
241
- else:
242
- st.write("No Search Found.")
 
 
 
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.")