File size: 1,801 Bytes
8c0cea8
 
 
 
 
 
 
 
 
755c3f2
 
 
 
 
8c0cea8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
f07d6c7
755c3f2
 
8c0cea8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import streamlit as st
from pyserini.search.lucene import LuceneSearcher

st.set_page_config(
    page_title="Reddit CMV",
    page_icon="📄",
    layout="centered"
)

index_locations = {"shoe-sizes": "index/cmv'-shoe-sizes-should-be-the-same-for-both-men-and-women",
           "social-media": "index/cmv'-social-media-is-the-most-destructive-addiction-in-our-society",
           "depression": "index/cmv'-the-others-have-it-worse-argument-is-terrible-and-should-never-be-used-in-an-actual-conversation-with-a-depressed-person",
           "metric-system": "index/cmv'-there-shouldnt-be-anything-other-than-the-metric-system.",
           "best-time-period": "index/cmv'-today-is-the-best-time-period-in-human-history-to-be-alive-for-the-vast-majority-of-people.",
          }

@st.cache(suppress_st_warning=True, allow_output_mutation=True, show_spinner=False)
def search_chat_noir(key, search_query):
    return search(api_key=key, query=search_query)

def result_html(result):
    return (
    f"<div>{(result.contents)}</div><br>"
    )


discussion = st.selectbox(
    'How would you like to be contacted?',
    indexes.keys())
searcher = LuceneSearcher(index_locations[discussion])
searcher.set_rm3()

cola, colb, colc = st.columns([5,4,5])
with colb:
    st.write(discussion)

col1, col2 = st.columns([9, 1])
with col1:
    search_query = st.text_input(label="",
                placeholder="Search"
            )

with col2:
    st.write('#')
    button_clicked = st.button("🔎")


if search_query or button_clicked:
    search_results = searcher.search(query, k=10)
    for result in search_results:
        st.write(result_html(result), unsafe_allow_html=True)
    
with st.expander("Instructions", expanded=False):
    st.markdown(
        """
        INSTRUCTIONS HERE
	    """
    )