cakiki commited on
Commit
b8705b2
·
1 Parent(s): 78f9731

Create new file

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from whoosh.index import create_in, open_dir
3
+ from whoosh.qparser import QueryParser
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])
10
+ with colb:
11
+ st.image("logo.png")
12
+
13
+ col1, col2 = st.columns([9, 1])
14
+ with col1:
15
+ search_query = st.text_input(label="", placeholder="Search")
16
+
17
+ with col2:
18
+ st.write('#')
19
+ button_clicked = st.button("🔎")
20
+
21
+
22
+ 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
+ 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)
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(result.highlights('text'), unsafe_allow_html=True)
34
+ except:
35
+ pass
36
+ with st.expander("Document Text", expanded=False):
37
+ st.write(result['text'][:1600])
38
+ st.write('---')
39
+