Spaces:
Runtime error
Runtime error
Commit
·
b8c5764
1
Parent(s):
6ab9a49
Update app.py
Browse files
app.py
CHANGED
@@ -62,13 +62,28 @@ for output in outputs:
|
|
62 |
|
63 |
search_query = sorted(query2outputs)[0]
|
64 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
if search_query or button_clicked:
|
66 |
|
67 |
num_results = None
|
68 |
t_0 = time.time()
|
69 |
search_results = query2outputs[search_query][0] # first from the 20
|
70 |
-
print(search_results)
|
71 |
-
print()
|
72 |
|
73 |
print(len(search_results), type(search_results[0]))
|
74 |
|
|
|
62 |
|
63 |
search_query = sorted(query2outputs)[0]
|
64 |
|
65 |
+
|
66 |
+
def aggregate(list_of_hits):
|
67 |
+
import numpy as np
|
68 |
+
from permsc import KemenyOptimalAggregator, sum_kendall_tau, ranks_from_preferences
|
69 |
+
|
70 |
+
preferences = []
|
71 |
+
for result in list_of_hits:
|
72 |
+
preferences.append([doc["rank"] for doc in result])
|
73 |
+
|
74 |
+
preferences = np.array(preferences)
|
75 |
+
y_optimal = KemenyOptimalAggregator().aggregate(preferences)
|
76 |
+
rank2doc = {}
|
77 |
+
for doc in list_of_hits[0]:
|
78 |
+
rank2doc[doc["rank"]] = doc
|
79 |
+
return [rank2doc[rank] for rank in y_optimal]
|
80 |
+
|
81 |
+
|
82 |
if search_query or button_clicked:
|
83 |
|
84 |
num_results = None
|
85 |
t_0 = time.time()
|
86 |
search_results = query2outputs[search_query][0] # first from the 20
|
|
|
|
|
87 |
|
88 |
print(len(search_results), type(search_results[0]))
|
89 |
|