orionweller commited on
Commit
770d15a
1 Parent(s): 92aad95

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -4
app.py CHANGED
@@ -47,6 +47,9 @@ def load_narratives_data():
47
 
48
  narratives_df = load_narratives_data()
49
 
 
 
 
50
  col1, col2 = st.columns([1, 3], gap="large")
51
 
52
  with st.sidebar:
@@ -54,7 +57,19 @@ with st.sidebar:
54
 
55
  with col1:
56
  st.title("Narratives")
57
- narrative_ids = narratives_df["id"].tolist()
 
 
 
 
 
 
 
 
 
 
 
 
58
  container_for_nav = st.container()
59
 
60
  def sync_from_drop():
@@ -88,7 +103,7 @@ with col2:
88
  narrative_index = narrative_number
89
 
90
  if narrative_index >= 0:
91
- narrative = narratives_df.iloc[narrative_index]
92
 
93
  st.markdown("<h1 style='text-align: center; color: black;text-decoration: underline;'>Editor</h1>", unsafe_allow_html=True)
94
 
@@ -106,8 +121,9 @@ with col2:
106
  container.subheader("Original Text")
107
  original_input = container.text_area("Edit the original text", value=narrative['original'], height=300)
108
 
109
-
110
  elif narrative_index < 0:
111
  st.title("Overview")
112
- st.write(f"Total number of narratives: {len(narratives_df)}")
 
 
113
  st.write("Select a narrative from the sidebar to view and edit its details.")
 
47
 
48
  narratives_df = load_narratives_data()
49
 
50
+ # Extract language from id
51
+ narratives_df['language'] = narratives_df['id'].str.extract('-(rus|zho|fas)-')
52
+
53
  col1, col2 = st.columns([1, 3], gap="large")
54
 
55
  with st.sidebar:
 
57
 
58
  with col1:
59
  st.title("Narratives")
60
+
61
+ # Add language filter
62
+ selected_language = st.selectbox(
63
+ "Select language",
64
+ ["All", "rus", "zho", "fas"]
65
+ )
66
+
67
+ if selected_language != "All":
68
+ filtered_df = narratives_df[narratives_df['language'] == selected_language]
69
+ else:
70
+ filtered_df = narratives_df
71
+
72
+ narrative_ids = filtered_df["id"].tolist()
73
  container_for_nav = st.container()
74
 
75
  def sync_from_drop():
 
103
  narrative_index = narrative_number
104
 
105
  if narrative_index >= 0:
106
+ narrative = filtered_df.iloc[narrative_index]
107
 
108
  st.markdown("<h1 style='text-align: center; color: black;text-decoration: underline;'>Editor</h1>", unsafe_allow_html=True)
109
 
 
121
  container.subheader("Original Text")
122
  original_input = container.text_area("Edit the original text", value=narrative['original'], height=300)
123
 
 
124
  elif narrative_index < 0:
125
  st.title("Overview")
126
+ st.write(f"Total number of narratives: {len(filtered_df)}")
127
+ if selected_language != "All":
128
+ st.write(f"Selected language: {selected_language}")
129
  st.write("Select a narrative from the sidebar to view and edit its details.")