Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
from pyserini.search.lucene import LuceneSearcher
|
3 |
import json
|
|
|
4 |
|
5 |
st.set_page_config(page_title="Pyserini x Datasets", page_icon='🌸', layout="centered")
|
6 |
searcher = LuceneSearcher('index')
|
@@ -22,9 +23,11 @@ with col2:
|
|
22 |
if search_query or button_clicked:
|
23 |
num_results = None
|
24 |
#search_results = searcher.search(myquery, limit=num_results)
|
25 |
-
|
|
|
|
|
26 |
#st.write(dir(search_results[0]))
|
27 |
-
|
28 |
for result in search_results[:10]:
|
29 |
#keywords = ', '.join(result.key_terms('text'))
|
30 |
#meta = result['meta']
|
@@ -32,12 +35,10 @@ if search_query or button_clicked:
|
|
32 |
result = json.loads(result.raw)
|
33 |
doc = result["contents"]
|
34 |
result_id = result["id"]
|
35 |
-
st.write(f"<b>Document ID</b>: {result_id}", unsafe_allow_html=True)
|
36 |
try:
|
37 |
-
st.write(
|
38 |
-
|
39 |
-
|
40 |
-
)
|
41 |
except:
|
42 |
pass
|
43 |
#with st.expander("Document Text", expanded=False):
|
|
|
1 |
import streamlit as st
|
2 |
from pyserini.search.lucene import LuceneSearcher
|
3 |
import json
|
4 |
+
import time
|
5 |
|
6 |
st.set_page_config(page_title="Pyserini x Datasets", page_icon='🌸', layout="centered")
|
7 |
searcher = LuceneSearcher('index')
|
|
|
23 |
if search_query or button_clicked:
|
24 |
num_results = None
|
25 |
#search_results = searcher.search(myquery, limit=num_results)
|
26 |
+
t_0 = time.time()
|
27 |
+
search_results = searcher.search(search_query)
|
28 |
+
search_time = time.time() - t_0
|
29 |
#st.write(dir(search_results[0]))
|
30 |
+
st.write(f"<p align=\"right\" style=\"color:grey;\">Retrieved {len(search_results):,.0f} documents in {search_time*1000:.2f} ms</p>", unsafe_allow_html=True)
|
31 |
for result in search_results[:10]:
|
32 |
#keywords = ', '.join(result.key_terms('text'))
|
33 |
#meta = result['meta']
|
|
|
35 |
result = json.loads(result.raw)
|
36 |
doc = result["contents"]
|
37 |
result_id = result["id"]
|
|
|
38 |
try:
|
39 |
+
st.write(doc[:1000], unsafe_allow_html=True)
|
40 |
+
st.write(f"<div align="right"><b>Document ID</b>: {result_id}</div>", unsafe_allow_html=True)
|
41 |
+
|
|
|
42 |
except:
|
43 |
pass
|
44 |
#with st.expander("Document Text", expanded=False):
|