abokbot commited on
Commit
d51ec0e
·
1 Parent(s): 988f448

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -72,16 +72,18 @@ def search():
72
  # Sort results by the cross-encoder scores
73
  for idx in range(len(cross_scores)):
74
  hits[idx]['cross-score'] = cross_scores[idx]
75
-
 
 
76
  # Output of top-3 hits from re-ranker
77
  print("\n-------------------------\n")
78
  print("Top-3 Cross-Encoder Re-ranker hits")
79
- hits = sorted(hits, key=lambda x: x['cross-score'], reverse=True)
80
- for hit in hits[0:3]:
81
- print("score: ", round(hit['cross-score'], 3),"\n",
82
- "title: ", dataset["title"][hit['corpus_id']], "\n",
83
- "substract: ", dataset["text"][hit['corpus_id']].replace("\n", " "), "\n",
84
- "link: ", dataset["url"][hit['corpus_id']],"\n")
85
 
86
 
87
  # search button
 
72
  # Sort results by the cross-encoder scores
73
  for idx in range(len(cross_scores)):
74
  hits[idx]['cross-score'] = cross_scores[idx]
75
+
76
+ hits = sorted(hits, key=lambda x: x['cross-score'], reverse=True)
77
+ st.session_state.results = hits[:3]
78
  # Output of top-3 hits from re-ranker
79
  print("\n-------------------------\n")
80
  print("Top-3 Cross-Encoder Re-ranker hits")
81
+ st.subheader("Top-3 Search results")
82
+ for hit in hits[:3]:
83
+ st.markdown("score: " + round(hit['cross-score'], 3),
84
+ st.markdown("title: " + dataset["title"][hit['corpus_id']]),
85
+ st.markdown("substract: " + dataset["text"][hit['corpus_id']].replace("\n", " ")),
86
+ st.markdown("link: " + dataset["url"][hit['corpus_id']])
87
 
88
 
89
  # search button