ccm commited on
Commit
f186297
·
verified ·
1 Parent(s): b88549f

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +15 -9
main.py CHANGED
@@ -68,6 +68,7 @@ def preprocess(query: str, k: int) -> tuple[str, str]:
68
  tuple[str, str]: A tuple containing the prompt and references
69
  """
70
  encoded_query = numpy.expand_dims(model.encode(query), axis=0)
 
71
  faiss.normalize_L2(encoded_query)
72
  D, I = index.search(encoded_query, k)
73
  top_five = data.loc[I[0]]
@@ -85,11 +86,11 @@ def preprocess(query: str, k: int) -> tuple[str, str]:
85
  research_abstracts = ""
86
 
87
  for i in range(k):
88
- research_abstracts += top_five["bib_dict"].values[i]["abstract"] + "\n"
89
- references += (
90
- str(i + 1)
91
- + ". "
92
- + ", ".join(
93
  [
94
  author.split(" ")[-1]
95
  for author in top_five["bib_dict"]
@@ -97,13 +98,18 @@ def preprocess(query: str, k: int) -> tuple[str, str]:
97
  .split(" and ")
98
  ]
99
  )
 
 
 
 
 
 
100
  + ". ("
101
- + str(int(top_five["bib_dict"].values[i]["pub_year"]))
102
  + "). ["
103
- + top_five["bib_dict"].values[i]["title"]
104
  + "]"
105
- + "(https://scholar.google.com/citations?view_op=view_citation&citation_for_view="
106
- + top_five["author_pub_id"].values[i]
107
  + ").\n"
108
  )
109
 
 
68
  tuple[str, str]: A tuple containing the prompt and references
69
  """
70
  encoded_query = numpy.expand_dims(model.encode(query), axis=0)
71
+ print(query, encoded_query)
72
  faiss.normalize_L2(encoded_query)
73
  D, I = index.search(encoded_query, k)
74
  top_five = data.loc[I[0]]
 
86
  research_abstracts = ""
87
 
88
  for i in range(k):
89
+ year = str(int(top_five["bib_dict"].values[i]["pub_year"]))
90
+ abstract = top_five["bib_dict"].values[i]["abstract"]
91
+ url = "(https://scholar.google.com/citations?view_op=view_citation&citation_for_view=" + top_five["author_pub_id"].values[i]
92
+ title = top_five["bib_dict"].values[i]["title"]
93
+ authors = ", ".join(
94
  [
95
  author.split(" ")[-1]
96
  for author in top_five["bib_dict"]
 
98
  .split(" and ")
99
  ]
100
  )
101
+
102
+ research_abstracts += str(i + i) + ". '" + title + "' by " + authors + "\n" + abstract + "\n"
103
+ references += (
104
+ str(i + 1)
105
+ + ". "
106
+ + authors
107
  + ". ("
108
+ + year
109
  + "). ["
110
+ + title
111
  + "]"
112
+ + url
 
113
  + ").\n"
114
  )
115