Spaces:
Running
on
Zero
Running
on
Zero
Update main.py
Browse files
main.py
CHANGED
@@ -34,12 +34,13 @@ index.add(numpy.stack(data["embedding"].to_list(), axis=0))
|
|
34 |
# Define the search function
|
35 |
def search(query: str, k: int):
|
36 |
query = numpy.expand_dims(model.encode(query), axis=0)
|
37 |
-
|
38 |
top_five = data.loc[I[0]]
|
39 |
search_results = ""
|
40 |
|
41 |
for i in range(k):
|
42 |
search_results += "### " + top_five["bib_dict"].values[i]["title"] + "\n\n"
|
|
|
43 |
if top_five["pub_url"].values[i] is not None:
|
44 |
search_results += "[Full Text](" + top_five["pub_url"].values[i] + ") "
|
45 |
if top_five["citedby_url"].values[i] is not None:
|
|
|
34 |
# Define the search function
|
35 |
def search(query: str, k: int):
|
36 |
query = numpy.expand_dims(model.encode(query), axis=0)
|
37 |
+
D, I = index.search(query, k)
|
38 |
top_five = data.loc[I[0]]
|
39 |
search_results = ""
|
40 |
|
41 |
for i in range(k):
|
42 |
search_results += "### " + top_five["bib_dict"].values[i]["title"] + "\n\n"
|
43 |
+
search_results += str(D[i]) + "\n\n"
|
44 |
if top_five["pub_url"].values[i] is not None:
|
45 |
search_results += "[Full Text](" + top_five["pub_url"].values[i] + ") "
|
46 |
if top_five["citedby_url"].values[i] is not None:
|