cakiki commited on
Commit
626fb97
β€’
1 Parent(s): c408ec1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -34,19 +34,20 @@ def process_results(results, query):
34
  text_html = mark_tokens_bold(text_html, query[1:-1].split(" "))
35
  else:
36
  text_html = mark_tokens_bold(text_html, query.split(" "))
37
- repository = result['repository']
 
38
  license = result["license"]
39
  language = result["language"]
40
  code_height = min(600, len(text_html.split('\n')) * 20) # limit to maximum height of 600px
41
  results_html += """\
42
- <p style='font-size:16px; text-align: left;'><b>Source: </b><a target="_blank" href="https://github.com/tree/master/{}">{}</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<b>Language:</b> \
43
  <span style='color: #00134d;'>{}</span>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<b>License: </b><span style='color: #00134d;'>{}</span></p>
44
  <br>
45
  <pre style='height: {}px; overflow-y: scroll; overflow-x: hidden; color: #d9d9d9;border: 1px solid #e6b800; padding: 10px'><code>{}</code></pre>
46
  <br>
47
  <hr>
48
  <br>
49
- """.format(repository, repository, language, license, code_height, text_html)
50
  return results_html
51
 
52
 
@@ -70,7 +71,7 @@ def search(query, num_results=10):
70
  response = phrase_query(query[1:-1], num_results=num_results)
71
  else:
72
  response = match_query(query, num_results=num_results)
73
- results = [{"text": nh3.clean(html.escape(hit.content)), "repository": f"{hit.repository}/{hit.path}", "license": hit.license[0], "language": hit.language} for hit in response]
74
  return process_results(results, query)
75
 
76
  description = """# <p style="text-align: center;"><span style='color: #e6b800;'>StarCoder:</span> Dataset Search πŸ” </p>
 
34
  text_html = mark_tokens_bold(text_html, query[1:-1].split(" "))
35
  else:
36
  text_html = mark_tokens_bold(text_html, query.split(" "))
37
+ repository = result["repository"]
38
+ path = result["path"]
39
  license = result["license"]
40
  language = result["language"]
41
  code_height = min(600, len(text_html.split('\n')) * 20) # limit to maximum height of 600px
42
  results_html += """\
43
+ <p style='font-size:16px; text-align: left;'><b>Source: </b><a target="_blank" href="https://github.com/{}/tree/master/{}">{}</a>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<b>Language:</b> \
44
  <span style='color: #00134d;'>{}</span>&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<b>License: </b><span style='color: #00134d;'>{}</span></p>
45
  <br>
46
  <pre style='height: {}px; overflow-y: scroll; overflow-x: hidden; color: #d9d9d9;border: 1px solid #e6b800; padding: 10px'><code>{}</code></pre>
47
  <br>
48
  <hr>
49
  <br>
50
+ """.format(repository, path, f"{repository}/{path}", language, license, code_height, text_html)
51
  return results_html
52
 
53
 
 
71
  response = phrase_query(query[1:-1], num_results=num_results)
72
  else:
73
  response = match_query(query, num_results=num_results)
74
+ results = [{"text": nh3.clean(html.escape(hit.content)), "repository": hit.repository, "path":hit.path, "license": hit.license[0], "language": hit.language} for hit in response]
75
  return process_results(results, query)
76
 
77
  description = """# <p style="text-align: center;"><span style='color: #e6b800;'>StarCoder:</span> Dataset Search πŸ” </p>