Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -107,9 +107,9 @@ def extract_text_qwen(image_file, model, processor):
|
|
| 107 |
# Function to highlight the keyword in the text
|
| 108 |
|
| 109 |
|
| 110 |
-
def highlight_text(
|
| 111 |
text_highlighter(
|
| 112 |
-
text=
|
| 113 |
labels=[("KEYWORD", "#0000FF")],
|
| 114 |
annotations=[
|
| 115 |
{"start": start, "end": end, "tag": "KEYWORD"},
|
|
@@ -218,11 +218,11 @@ if uploaded_file:
|
|
| 218 |
search_query = st_keyup("Search in extracted text:")
|
| 219 |
|
| 220 |
if search_query:
|
| 221 |
-
index =
|
| 222 |
start = index
|
| 223 |
len = search_query.length
|
| 224 |
end = index + len
|
| 225 |
if index != -1:
|
| 226 |
-
highlight_text(
|
| 227 |
else:
|
| 228 |
st.write("No Search Found.")
|
|
|
|
| 107 |
# Function to highlight the keyword in the text
|
| 108 |
|
| 109 |
|
| 110 |
+
def highlight_text(text_sentence, start, end):
|
| 111 |
text_highlighter(
|
| 112 |
+
text=text_sentence,
|
| 113 |
labels=[("KEYWORD", "#0000FF")],
|
| 114 |
annotations=[
|
| 115 |
{"start": start, "end": end, "tag": "KEYWORD"},
|
|
|
|
| 218 |
search_query = st_keyup("Search in extracted text:")
|
| 219 |
|
| 220 |
if search_query:
|
| 221 |
+
index = extracted_text.find(search_query)
|
| 222 |
start = index
|
| 223 |
len = search_query.length
|
| 224 |
end = index + len
|
| 225 |
if index != -1:
|
| 226 |
+
highlight_text(extracted_text, start, end)
|
| 227 |
else:
|
| 228 |
st.write("No Search Found.")
|