Spaces:
Running
Running
removed table coloring
Browse files
app.py
CHANGED
|
@@ -72,11 +72,11 @@ def highlight_matching_words(text: str, query: str) -> str:
|
|
| 72 |
for token in tokens:
|
| 73 |
token_lc = token.lower()
|
| 74 |
if token_lc in query_words:
|
| 75 |
-
highlighted.append(f'<
|
| 76 |
elif token.strip() and token.isalpha() and any(w in token_lc and w != token_lc for w in query_words):
|
| 77 |
-
def
|
| 78 |
-
return f'<
|
| 79 |
-
highlighted.append(partial_pattern.sub(
|
| 80 |
else:
|
| 81 |
highlighted.append(token)
|
| 82 |
return ''.join(highlighted)
|
|
@@ -150,83 +150,7 @@ def format_results_html(results: List[Dict[str, Any]]) -> str:
|
|
| 150 |
if "Error" in results[0]:
|
| 151 |
return f'<div style="color:red">Error: {results[0]["Error"]}</div>'
|
| 152 |
html = [
|
| 153 |
-
'<
|
| 154 |
-
'/* CSS variables for theming */',
|
| 155 |
-
':root {',
|
| 156 |
-
' --table-bg: #fff;',
|
| 157 |
-
' --table-text: #222;',
|
| 158 |
-
' --header-bg: #f4f1e9;',
|
| 159 |
-
' --row-even-bg: #f9f9f9;',
|
| 160 |
-
' --row-hover-bg: #e6e2d3;',
|
| 161 |
-
' --table-shadow: 0 2px 8px #e6e2d3;',
|
| 162 |
-
' --exact-match-bg: #ffeb3b;',
|
| 163 |
-
' --exact-match-text: #000;',
|
| 164 |
-
' --partial-match-bg: #c8e6c9;',
|
| 165 |
-
' --partial-match-text: #000;',
|
| 166 |
-
'}',
|
| 167 |
-
'',
|
| 168 |
-
'/* Dark mode styles */',
|
| 169 |
-
'@media (prefers-color-scheme: dark) {',
|
| 170 |
-
' :root {',
|
| 171 |
-
' --table-bg: #2d2d2d;',
|
| 172 |
-
' --table-text: #e0e0e0;',
|
| 173 |
-
' --header-bg: #3d3d3d;',
|
| 174 |
-
' --row-even-bg: #333333;',
|
| 175 |
-
' --row-hover-bg: #404040;',
|
| 176 |
-
' --table-shadow: 0 2px 8px rgba(0,0,0,0.5);',
|
| 177 |
-
' --exact-match-bg: #fbc02d;',
|
| 178 |
-
' --exact-match-text: #000;',
|
| 179 |
-
' --partial-match-bg: #4caf50;',
|
| 180 |
-
' --partial-match-text: #fff;',
|
| 181 |
-
' }',
|
| 182 |
-
'}',
|
| 183 |
-
'',
|
| 184 |
-
'/* Table styles */',
|
| 185 |
-
'table {',
|
| 186 |
-
' border-collapse: collapse;',
|
| 187 |
-
' width: 100%;',
|
| 188 |
-
' font-size: 1em;',
|
| 189 |
-
' background: var(--table-bg);',
|
| 190 |
-
' color: var(--table-text);',
|
| 191 |
-
' border-radius: 8px;',
|
| 192 |
-
' overflow: hidden;',
|
| 193 |
-
' box-shadow: var(--table-shadow);',
|
| 194 |
-
'}',
|
| 195 |
-
'',
|
| 196 |
-
'td, th {',
|
| 197 |
-
' padding: 8px;',
|
| 198 |
-
' vertical-align: top;',
|
| 199 |
-
'}',
|
| 200 |
-
'',
|
| 201 |
-
'th {',
|
| 202 |
-
' background: var(--header-bg);',
|
| 203 |
-
' font-weight: bold;',
|
| 204 |
-
'}',
|
| 205 |
-
'',
|
| 206 |
-
'tr:nth-child(even) {',
|
| 207 |
-
' background: var(--row-even-bg);',
|
| 208 |
-
'}',
|
| 209 |
-
'',
|
| 210 |
-
'tr:hover {',
|
| 211 |
-
' background: var(--row-hover-bg);',
|
| 212 |
-
'}',
|
| 213 |
-
'',
|
| 214 |
-
'/* Highlighting styles */',
|
| 215 |
-
'.exact-match {',
|
| 216 |
-
' background: var(--exact-match-bg);',
|
| 217 |
-
' color: var(--exact-match-text);',
|
| 218 |
-
' padding: 1px 2px;',
|
| 219 |
-
' border-radius: 2px;',
|
| 220 |
-
'}',
|
| 221 |
-
'',
|
| 222 |
-
'.partial-match {',
|
| 223 |
-
' background: var(--partial-match-bg);',
|
| 224 |
-
' color: var(--partial-match-text);',
|
| 225 |
-
' padding: 1px 2px;',
|
| 226 |
-
' border-radius: 2px;',
|
| 227 |
-
'}',
|
| 228 |
-
'</style>',
|
| 229 |
-
'<table>',
|
| 230 |
'<thead><tr>'
|
| 231 |
'<th>Reference</th><th>Text</th><th>Similarity</th><th>Book</th><th>Chapter</th><th>Verse</th>'
|
| 232 |
'</tr></thead><tbody>'
|
|
|
|
| 72 |
for token in tokens:
|
| 73 |
token_lc = token.lower()
|
| 74 |
if token_lc in query_words:
|
| 75 |
+
highlighted.append(f'<b>{token}</b>')
|
| 76 |
elif token.strip() and token.isalpha() and any(w in token_lc and w != token_lc for w in query_words):
|
| 77 |
+
def bold_sub(m):
|
| 78 |
+
return f'<em>{m.group(0)}</em>'
|
| 79 |
+
highlighted.append(partial_pattern.sub(bold_sub, token))
|
| 80 |
else:
|
| 81 |
highlighted.append(token)
|
| 82 |
return ''.join(highlighted)
|
|
|
|
| 150 |
if "Error" in results[0]:
|
| 151 |
return f'<div style="color:red">Error: {results[0]["Error"]}</div>'
|
| 152 |
html = [
|
| 153 |
+
'<table border="1">',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
'<thead><tr>'
|
| 155 |
'<th>Reference</th><th>Text</th><th>Similarity</th><th>Book</th><th>Chapter</th><th>Verse</th>'
|
| 156 |
'</tr></thead><tbody>'
|