crystina-z commited on
Commit
48bcd5d
·
1 Parent(s): 7a18ba5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -29
app.py CHANGED
@@ -120,33 +120,45 @@ def aggregate(list_of_hits):
120
  aggregated_ranking = aggregate(query2outputs[search_query])
121
  qrels = load_qrels("dl19")
122
 
123
- if search_query or button_clicked:
124
 
125
- num_results = None
126
- t_0 = time.time()
127
- # search_results = query2outputs[search_query][0] # first from the 20
128
- search_results = aggregated_ranking
129
-
130
- st.write(
131
- f'<p align=\"right\" style=\"color:grey;\"> Before aggregation for query [{search_query}] ms</p>', unsafe_allow_html=True)
132
-
133
- qid = {result["qid"] for result in search_results}
134
- assert len(qid) == 1
135
- qid = list(qid)[0]
136
-
137
- for i, result in enumerate(search_results):
138
- result_id = result["docid"]
139
- contents = result["content"]
140
-
141
- style = "style=\"color:grey;\"" if qrels[qid].get(result_id, 0) else "style=\"color:red;\""
142
- # output = f'<div class="row"> <b>Rank</b>: {i+1} | <b>Document ID</b>: {result_id} | <b>Score</b>:{result_score:.2f}</div>'
143
- output = f'<div class="row" {style}> <b>Rank</b>: {i+1} | <b>Document ID</b>: {result_id}'
144
-
145
- try:
146
- st.write(output, unsafe_allow_html=True)
147
- st.write(
148
- f'<div class="row" {style}>{contents}</div>', unsafe_allow_html=True)
149
-
150
- except:
151
- pass
152
- st.write('---')
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  aggregated_ranking = aggregate(query2outputs[search_query])
121
  qrels = load_qrels("dl19")
122
 
123
+ col1, col2 = st.columns([5, 5])
124
 
125
+ with col2:
126
+ if search_query or button_clicked:
127
+
128
+ num_results = None
129
+ t_0 = time.time()
130
+ # search_results = query2outputs[search_query][0] # first from the 20
131
+ search_results = aggregated_ranking
132
+
133
+ st.write(
134
+ f'<p align=\"right\" style=\"color:grey;\"> Before aggregation for query [{search_query}] ms</p>', unsafe_allow_html=True)
135
+
136
+ qid = {result["qid"] for result in search_results}
137
+ assert len(qid) == 1
138
+ qid = list(qid)[0]
139
+
140
+ for i, result in enumerate(search_results):
141
+ result_id = result["docid"]
142
+ contents = result["content"]
143
+
144
+ label = qrels[qid].get(result_id, 0)
145
+ if label == 3:
146
+ style = "style=\"color:blue;\""
147
+ elif label == 2:
148
+ style = "style=\"color:green;\""
149
+ elif label == 1:
150
+ style = "style=\"color:red;\""
151
+ else:
152
+ style = "style=\"color:grey;\""
153
+
154
+ # output = f'<div class="row"> <b>Rank</b>: {i+1} | <b>Document ID</b>: {result_id} | <b>Score</b>:{result_score:.2f}</div>'
155
+ output = f'<div class="row" {style}> <b>Rank</b>: {i+1} | <b>Document ID</b>: {result_id}'
156
+
157
+ try:
158
+ st.write(output, unsafe_allow_html=True)
159
+ st.write(
160
+ f'<div class="row" {style}>{contents}</div>', unsafe_allow_html=True)
161
+
162
+ except:
163
+ pass
164
+ st.write('---')