Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -12,11 +12,11 @@ from elasticsearch_dsl import Search, Q
|
|
12 |
|
13 |
# es = Elasticsearch(os.environ.get("host"), timeout=100, http_compress=True, maxsize=1000)
|
14 |
es = Elasticsearch(os.environ.get("host"), http_compress=True, timeout=200)
|
15 |
-
def mark_tokens_bold(text,
|
16 |
-
if query.startswith('"') and query.endswith('"'):
|
17 |
-
|
18 |
-
else:
|
19 |
-
|
20 |
for token in tokens:
|
21 |
pattern = re.escape(token) #r"\b" + re.escape(token) + r"\b"
|
22 |
text = re.sub(pattern, "<span style='color: #e6b800;'><b>" + token + "</b></span>", text)
|
@@ -30,7 +30,7 @@ def process_results(results, query):
|
|
30 |
results_html = ""
|
31 |
for result in results:
|
32 |
text_html = result["text"]
|
33 |
-
|
34 |
repository = result['repository']
|
35 |
license = result["license"]
|
36 |
language = result["language"]
|
|
|
12 |
|
13 |
# es = Elasticsearch(os.environ.get("host"), timeout=100, http_compress=True, maxsize=1000)
|
14 |
es = Elasticsearch(os.environ.get("host"), http_compress=True, timeout=200)
|
15 |
+
def mark_tokens_bold(text, tokens):
|
16 |
+
# if query.startswith('"') and query.endswith('"'):
|
17 |
+
# tokens = query[1:-1]
|
18 |
+
# else:
|
19 |
+
# tokens = query.split(" ")
|
20 |
for token in tokens:
|
21 |
pattern = re.escape(token) #r"\b" + re.escape(token) + r"\b"
|
22 |
text = re.sub(pattern, "<span style='color: #e6b800;'><b>" + token + "</b></span>", text)
|
|
|
30 |
results_html = ""
|
31 |
for result in results:
|
32 |
text_html = result["text"]
|
33 |
+
text_html = mark_tokens_bold(text_html, query.split(" "))
|
34 |
repository = result['repository']
|
35 |
license = result["license"]
|
36 |
language = result["language"]
|