File size: 1,815 Bytes
1b1aa1e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a210a96
1b1aa1e
4301ead
 
 
1b1aa1e
 
 
 
 
 
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
import streamlit as st
import pandas as pd
st.set_page_config(layout="wide")

segment_len_limit = st.number_input("Minimum segment length (# of words)", min_value=0, max_value=10000,value=100, step = 10)
xl1 = st.file_uploader("Choose csv file", key="xl1")
if xl1 is not None :
    #assert that the first few columns are the same
    df = pd.read_csv(xl1)
    df = df.drop(["T5 title - Candidates","T5 headline - Candidates", "BART", "BART Meeting"], axis=1)
    st.title(df["session_title"].iloc[0])
    with st.form("Headline Candidates"):
        methods_score = {x:0 for x in df.columns.values if x!="text"}
        i = 0
        j = 0
        for index, row in df.iterrows():
            #if segment has fewer words than segment_len_limit, ignore it
            if len(row["text"].split(' ')) < segment_len_limit:
                continue
            col1, col2= st.columns(2)
            with col1:
                st.write(row["text"])
            with col2:
                ignore_segment = st.checkbox("Ignore?", value=False, key=f"{j}_ignore")
                if ignore_segment:
                    mult = 0
                else:
                    mult = 1
                j +=1
                for method in row.keys():
                    if method=="text" or method=="session_title":
                        continue
                    #methods_score[method] += st.slider(f"{row[method]}",min_value=1,max_value=3,value=2,step=1, key=i) * mult
                    methods_score[method] += int(st.radio(f"{row[method]}",(0,1,2,3), index=2, horizontal = True,
                                                       key=i)) * mult
                    i += 1

            st.markdown("""---""")
        submitted = st.form_submit_button("Submit")
        if submitted:
            st.write(methods_score)