Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
from ocr_utils import extract_text
|
| 4 |
-
|
| 5 |
import numpy as np
|
| 6 |
# Streamlit application title
|
| 7 |
st.title("OCR and Keyword Search Application")
|
|
@@ -28,15 +28,13 @@ if uploaded_file is not None:
|
|
| 28 |
# Text input for keyword search
|
| 29 |
keyword = st.text_input("Enter Keyword to Search")
|
| 30 |
|
| 31 |
-
|
| 32 |
# Display highlighted content if a keyword is entered
|
| 33 |
if keyword:
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
# CSS styles for highlighting
|
| 40 |
st.markdown('''
|
| 41 |
<style>
|
| 42 |
.highlight {
|
|
@@ -49,6 +47,5 @@ if uploaded_file is not None:
|
|
| 49 |
''', unsafe_allow_html=True)
|
| 50 |
st.markdown(highlighted_text, unsafe_allow_html=True)
|
| 51 |
else:
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from PIL import Image
|
| 3 |
from ocr_utils import extract_text
|
| 4 |
+
|
| 5 |
import numpy as np
|
| 6 |
# Streamlit application title
|
| 7 |
st.title("OCR and Keyword Search Application")
|
|
|
|
| 28 |
# Text input for keyword search
|
| 29 |
keyword = st.text_input("Enter Keyword to Search")
|
| 30 |
|
|
|
|
| 31 |
# Display highlighted content if a keyword is entered
|
| 32 |
if keyword:
|
| 33 |
|
| 34 |
+
highlighted_text = full_text.replace(
|
| 35 |
+
keyword, f"<span class='highlight'>{keyword}</span>)")
|
| 36 |
+
st.subheader("Highlighted Search Results")
|
| 37 |
+
# CSS styles for highlighting
|
|
|
|
| 38 |
st.markdown('''
|
| 39 |
<style>
|
| 40 |
.highlight {
|
|
|
|
| 47 |
''', unsafe_allow_html=True)
|
| 48 |
st.markdown(highlighted_text, unsafe_allow_html=True)
|
| 49 |
else:
|
| 50 |
+
st.subheader("Highlighted Search Results")
|
| 51 |
+
st.write("No keyword entered for highlighting.")
|
|
|