leavoigt commited on
Commit
13beabf
1 Parent(s): c7320de

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +67 -63
app.py CHANGED
@@ -138,67 +138,71 @@ if st.button("Analyze Document"):
138
 
139
  # If there is data stored
140
  if 'key0' in st.session_state:
141
- with st.sidebar:
142
- topic = st.radio(
143
- "Which category you want to explore?",
144
- (['Vulnerability', 'Concrete targets/actions']))
145
-
146
- if topic == 'Vulnerability':
147
-
148
- # Assign dataframe a name
149
- df_vul = st.session_state['key0']
150
-
151
- col1, col2 = st.columns([1,1])
152
-
153
- with col1:
154
- # Header
155
- st.subheader("Explore references to vulnerable groups:")
156
-
157
- # Text
158
- num_paragraphs = len(df_vul['Vulnerability Label'])
159
- num_references = len(df_vul[df_vul['Vulnerability Label'] != 'Other'])
160
-
161
- st.markdown(f"""<div style="text-align: justify;"> The document contains a
162
- total of <span style="color: red;">{num_paragraphs}</span> paragraphs.
163
- We identified <span style="color: red;">{num_references}</span>
164
- references to vulnerable groups.</div>
165
- <br>
166
- In the pie chart on the right you can see the distribution of the different
167
- groups defined. For a more detailed view in the text, see the paragraphs and
168
- their respective labels in the table below.</div>""", unsafe_allow_html=True)
169
-
170
- with col2:
171
-
172
- ### Pie chart
173
-
174
- # Create a df that stores all the labels
175
- df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
176
-
177
- # Count how often each label appears in the "Vulnerability Labels" column
178
- label_counts = df_vul['Vulnerability Label'].value_counts().reset_index()
179
- label_counts.columns = ['Label', 'Count']
180
-
181
- # Merge the label counts with the df_label DataFrame
182
- df_labels = df_labels.merge(label_counts, on='Label', how='left')
183
-
184
- # Configure graph
185
- fig = px.pie(df_labels,
186
- names="Label",
187
- values="Count",
188
- title='Label Counts',
189
- hover_name="Count",
190
- color_discrete_sequence=px.colors.qualitative.Plotly
191
- )
192
-
193
- #Show plot
194
- st.plotly_chart(fig, use_container_width=True)
195
 
196
- ### Table
197
- st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])
198
-
199
- # vulnerability_analysis.vulnerability_display()
200
- # elif topic == 'Action':
201
- # policyaction.action_display()
202
- # else:
203
- # policyaction.policy_display()
204
- #st.write(st.session_state.key0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
 
139
  # If there is data stored
140
  if 'key0' in st.session_state:
141
+
142
+ ###################################################################
143
+
144
+ #with st.sidebar:
145
+ # topic = st.radio(
146
+ # "Which category you want to explore?",
147
+ # (['Vulnerability', 'Concrete targets/actions/measures']))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148
 
149
+ #if topic == 'Vulnerability':
150
+
151
+ # Assign dataframe a name
152
+ df_vul = st.session_state['key0']
153
+
154
+ col1, col2 = st.columns([1,1])
155
+
156
+ with col1:
157
+
158
+ # Header
159
+ st.subheader("Explore references to vulnerable groups:")
160
+
161
+ # Text
162
+ num_paragraphs = len(df_vul['Vulnerability Label'])
163
+ num_references = len(df_vul[df_vul['Vulnerability Label'] != 'Other'])
164
+
165
+ st.markdown(f"""<div style="text-align: justify;"> The document contains a
166
+ total of <span style="color: red;">{num_paragraphs}</span> paragraphs.
167
+ We identified <span style="color: red;">{num_references}</span>
168
+ references to vulnerable groups.</div>
169
+ <br>
170
+ In the pie chart on the right you can see the distribution of the different
171
+ groups defined. For a more detailed view in the text, see the paragraphs and
172
+ their respective labels in the table below.</div>""", unsafe_allow_html=True)
173
+
174
+ with col2:
175
+
176
+ ### Pie chart
177
+
178
+ # Create a df that stores all the labels
179
+ df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
180
+
181
+ # Count how often each label appears in the "Vulnerability Labels" column
182
+ label_counts = df_vul['Vulnerability Label'].value_counts().reset_index()
183
+ label_counts.columns = ['Label', 'Count']
184
+
185
+ # Merge the label counts with the df_label DataFrame
186
+ df_labels = df_labels.merge(label_counts, on='Label', how='left')
187
+
188
+ # Configure graph
189
+ fig = px.pie(df_labels,
190
+ names="Label",
191
+ values="Count",
192
+ title='Label Counts',
193
+ hover_name="Count",
194
+ color_discrete_sequence=px.colors.qualitative.Plotly
195
+ )
196
+
197
+ #Show plot
198
+ st.plotly_chart(fig, use_container_width=True)
199
+
200
+ ### Table
201
+ st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])
202
+
203
+ # vulnerability_analysis.vulnerability_display()
204
+ # elif topic == 'Action':
205
+ # policyaction.action_display()
206
+ # else:
207
+ # policyaction.policy_display()
208
+ #st.write(st.session_state.key0)