File size: 4,309 Bytes
8c0cea8
 
 
 
 
 
0c25f74
8c0cea8
 
755c3f2
 
 
 
 
8c0cea8
 
dd2d5d0
 
 
 
 
 
 
6bbbe0e
 
 
 
 
 
 
1204d04
 
 
 
 
 
 
8c0cea8
 
 
dd2d5d0
 
8c0cea8
 
 
 
eefd1fd
562c654
f07d6c7
b4eb4c4
755c3f2
8c0cea8
 
dd2d5d0
8c0cea8
 
 
 
 
 
 
 
 
 
 
 
 
1204d04
 
 
 
 
 
 
 
8c0cea8
 
 
 
6bbbe0e
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import streamlit as st
from pyserini.search.lucene import LuceneSearcher

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

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.",
          }

titles = {"shoe-sizes": "Shoes sizes should be the same for both men and women",
           "social-media": "Social Media is the most destructive addiction in our society",
           "depression": "'The others have it worse' argument is terrible and should never be used in an actual conversation with a depressed person",
           "metric-system": "There shouldn't be anything other than the metric system",
           "best-time-period": "Today is the best time period in human history to be alive for the vast majority of people",
          }

instructions = {"shoe-sizes": "Explore this discussion by searching for comments using your queries of interest. You may want to introduce your own arguments to the discussion (assuming that you can do so with this interface) or simply find interesting ones from other participants.",
              "social-media": "Explore this discussion by searching for comments using your queries of interest. You may want to introduce your own arguments to the discussion (assuming that you can do so with this interface) or simply find interesting ones from other participants.",
              "depression": "Explore this discussion by searching for comments using your queries of interest. You may want to introduce your own arguments to the discussion (assuming that you can do so with this interface) or simply find interesting ones from other participants.",
              "metric-system": "Explore this discussion by searching for comments using your queries of interest. You may want to introduce your own arguments to the discussion (assuming that you can do so with this interface) or simply find interesting ones from other participants.",
              "best-time-period": "Explore this discussion by searching for comments using your queries of interest. You may want to introduce your own arguments to the discussion (assuming that you can do so with this interface) or simply find interesting ones from other participants.",
             }

num_docs = {"shoe-sizes": 623,
           "social-media": 1133,
           "depression": 982,
           "metric-system": 4679,
           "best-time-period": 2516,
          }


def result_html(result):
    return (
    f"<div style=\"color:#2a5cb3;font-weight: 500\">{(result.docid)}</div>"
    f"<div>{(result.contents)}</div><hr><br>"
    )


discussion = st.selectbox(
    'Choose discussion',
    index_locations.keys())
searcher = LuceneSearcher(index_locations[discussion])
# searcher.set_rm3()

cola, colb, colc = st.columns([5,4,5])
with colb:
    st.write(titles[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:
    k=num_docs[discussion]
    search_results = searcher.search(search_query, k=k)
    if len(search_results) == 0:
        st.write("Retrieved 0 documents")
    else:
        st.write(f"retrieved {len(search_results)} out of {k} total posts")
        for result in search_results:
            st.write(result_html(result), unsafe_allow_html=True)
    
with st.expander("Instructions", expanded=False):
    st.markdown(
        """
        Explore this discussion by searching for comments using your queries of interest. You may want to introduce your own arguments to the discussion (assuming that you can do so with this interface) or simply find interesting ones from other participants.
	    """
    )