UniquePratham commited on
Commit
bc97c42
1 Parent(s): 77fc61e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -175,8 +175,6 @@ 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
- cleaned_text = ""
179
- polished_text = ""
180
  # Display extracted text
181
  if 'cleaned_text' not in st.session_state:
182
  st.session_state.cleaned_text = ""
@@ -225,19 +223,18 @@ if uploaded_file:
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)
 
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
  if 'cleaned_text' not in st.session_state:
180
  st.session_state.cleaned_text = ""
 
223
  st.session_state.cleaned_text = cleaned_text
224
  st.session_state.polished_text = polished_text
225
 
226
+ if os.path.exists(result_path) and st.session_state.cleaned_text != "" and st.session_state.polished_text != "":
227
  # Display extracted text
228
  st.subheader("Extracted Text (Cleaned & Polished)")
229
  st.markdown(st.session_state.cleaned_text, unsafe_allow_html=True)
230
  st.markdown(st.session_state.polished_text, unsafe_allow_html=True)
 
 
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 = len(search_query)
238
  end = index + len
239
  if index != -1:
240
  highlight_text(st.session_state.cleaned_text, start, end)