Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
from
|
| 3 |
-
|
| 4 |
|
| 5 |
st.set_page_config(page_title="Pyserini x Datasets", page_icon='🌸', layout="centered")
|
| 6 |
-
|
| 7 |
|
| 8 |
|
| 9 |
cola, colb, colc = st.columns([5,4,5])
|
|
@@ -23,17 +23,21 @@ if search_query or button_clicked:
|
|
| 23 |
myquery = parser.parse(search_query)
|
| 24 |
num_results = None
|
| 25 |
#search_results = searcher.search(myquery, limit=num_results)
|
| 26 |
-
|
|
|
|
| 27 |
for result in search_results[:10]:
|
| 28 |
#keywords = ', '.join(result.key_terms('text'))
|
| 29 |
#meta = result['meta']
|
| 30 |
#st.write(f"<b>Document Keywords</b>: {keywords}", unsafe_allow_html=True)
|
| 31 |
#st.write(f"<b>Meta Field</b>: {meta}", unsafe_allow_html=True)
|
| 32 |
try:
|
| 33 |
-
st.write(
|
|
|
|
|
|
|
|
|
|
| 34 |
except:
|
| 35 |
pass
|
| 36 |
-
with st.expander("Document Text", expanded=False):
|
| 37 |
-
st.write(result['text'][:1600])
|
| 38 |
st.write('---')
|
| 39 |
|
|
|
|
| 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')
|
| 7 |
|
| 8 |
|
| 9 |
cola, colb, colc = st.columns([5,4,5])
|
|
|
|
| 23 |
myquery = parser.parse(search_query)
|
| 24 |
num_results = None
|
| 25 |
#search_results = searcher.search(myquery, limit=num_results)
|
| 26 |
+
search_results = searcher.search(myquery, k=1000)
|
| 27 |
+
#st.write(f"<p align=\"right\" style=\"color:grey;\">Retrieved {len(search_results):,.0f} documents in {search_results.runtime*1000:.2f} ms</p>", unsafe_allow_html=True)
|
| 28 |
for result in search_results[:10]:
|
| 29 |
#keywords = ', '.join(result.key_terms('text'))
|
| 30 |
#meta = result['meta']
|
| 31 |
#st.write(f"<b>Document Keywords</b>: {keywords}", unsafe_allow_html=True)
|
| 32 |
#st.write(f"<b>Meta Field</b>: {meta}", unsafe_allow_html=True)
|
| 33 |
try:
|
| 34 |
+
st.write(
|
| 35 |
+
json.loads(result.raw["contents"]),
|
| 36 |
+
unsafe_allow_html=True
|
| 37 |
+
)
|
| 38 |
except:
|
| 39 |
pass
|
| 40 |
+
#with st.expander("Document Text", expanded=False):
|
| 41 |
+
#st.write(result['text'][:1600])
|
| 42 |
st.write('---')
|
| 43 |
|