cakiki commited on
Commit
a21f45a
1 Parent(s): 65124fb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -12,15 +12,15 @@ 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"), timeout=200)
15
- def mark_tokens_bold(string, query):
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
- string = re.sub(pattern, "<span style='color: #e6b800;'><b>" + token + "</b></span>", string)
23
- return string
24
 
25
 
26
  def process_results(results, query):
 
12
 
13
  # es = Elasticsearch(os.environ.get("host"), timeout=100, http_compress=True, maxsize=1000)
14
  es = Elasticsearch(os.environ.get("host"), timeout=200)
15
+ def mark_tokens_bold(text, query):
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)
23
+ return text
24
 
25
 
26
  def process_results(results, query):