Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -9,9 +9,9 @@ CSV_FILENAME = "user_selections.csv"
|
|
9 |
# Function to assign samples to users
|
10 |
def assign_samples(csv_path):
|
11 |
df = pd.read_csv(csv_path)
|
12 |
-
group_1 = df[(df["pool_pos"] == 1) & (~df["question_category"].str.endswith("_B"))].head(
|
13 |
-
group_2 = df[(df["pool_pos"] == 2) & (~df["question_category"].str.endswith("_B"))].head(
|
14 |
-
group_3 = df[(df["pool_pos"] == 3) & (~df["question_category"].str.endswith("_B"))].head(
|
15 |
return {
|
16 |
"Bernardo": group_1,
|
17 |
"Alessandro": group_1,
|
@@ -47,15 +47,17 @@ if "index" not in st.session_state:
|
|
47 |
if "results" not in st.session_state:
|
48 |
st.session_state.results = []
|
49 |
|
50 |
-
# User
|
|
|
|
|
|
|
|
|
|
|
51 |
if st.session_state.username is None:
|
52 |
with st.form("user_form"):
|
53 |
st.write("### Select Your Name")
|
54 |
selected_user = st.selectbox("Choose your name:", valid_users, key="selected_user")
|
55 |
-
submit_button = st.form_submit_button("Start")
|
56 |
-
if submit_button:
|
57 |
-
st.session_state.username = selected_user
|
58 |
-
st.session_state.index = 0
|
59 |
st.stop()
|
60 |
|
61 |
# Retrieve assigned dataset and filter out already labeled samples
|
|
|
9 |
# Function to assign samples to users
|
10 |
def assign_samples(csv_path):
|
11 |
df = pd.read_csv(csv_path)
|
12 |
+
group_1 = df[(df["pool_pos"] == 1) & (~df["question_category"].str.endswith("_B"))].head(5)
|
13 |
+
group_2 = df[(df["pool_pos"] == 2) & (~df["question_category"].str.endswith("_B"))].head(5)
|
14 |
+
group_3 = df[(df["pool_pos"] == 3) & (~df["question_category"].str.endswith("_B"))].head(5)
|
15 |
return {
|
16 |
"Bernardo": group_1,
|
17 |
"Alessandro": group_1,
|
|
|
47 |
if "results" not in st.session_state:
|
48 |
st.session_state.results = []
|
49 |
|
50 |
+
# User selectiontion
|
51 |
+
def update_name():
|
52 |
+
"""Set username and reset index."""
|
53 |
+
st.session_state.username = st.session_state.selected_user
|
54 |
+
st.session_state.index = 0 # Reset progress
|
55 |
+
|
56 |
if st.session_state.username is None:
|
57 |
with st.form("user_form"):
|
58 |
st.write("### Select Your Name")
|
59 |
selected_user = st.selectbox("Choose your name:", valid_users, key="selected_user")
|
60 |
+
submit_button = st.form_submit_button("Start", on_click=update_name)
|
|
|
|
|
|
|
61 |
st.stop()
|
62 |
|
63 |
# Retrieve assigned dataset and filter out already labeled samples
|