Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -103,42 +103,48 @@ if 'key0' in st.session_state:
|
|
103 |
|
104 |
if topic == 'Vulnerability':
|
105 |
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
### Table
|
112 |
-
st.table(st.session_state['key0'])
|
113 |
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
# Create a df that stores all the labels
|
119 |
-
df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
|
120 |
-
|
121 |
-
# Count how often each label appears in the "Vulnerability Labels" column
|
122 |
-
label_counts = st.session_state['key0']['Vulnerability Label'].value_counts().reset_index()
|
123 |
-
label_counts.columns = ['Label', 'Count']
|
124 |
-
|
125 |
-
# Merge the label counts with the df_label DataFrame
|
126 |
-
df_labels = df_labels.merge(label_counts, on='Label', how='left')
|
127 |
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
|
|
|
|
|
|
140 |
### Table
|
141 |
-
|
142 |
|
143 |
# vulnerability_analysis.vulnerability_display()
|
144 |
# elif topic == 'Action':
|
|
|
103 |
|
104 |
if topic == 'Vulnerability':
|
105 |
|
106 |
+
# Assign dataframe easier name
|
107 |
+
df_vul = st.session_state['key0']
|
108 |
+
|
109 |
+
# Header
|
110 |
+
st.subheader("Explore here which references to vulnerable groups were identified:")
|
111 |
|
112 |
+
# Text
|
113 |
+
num_paragraphs = len(df_vul['Vulnerability Label'])
|
114 |
+
num_references = df_vul[df_vul['Vulnerability Label'] != 'Other']
|
|
|
|
|
|
|
115 |
|
116 |
+
st.markdown(f"""<div style="text-align: justify;"> The document has a
|
117 |
+
total of <span style="color: red;">{num_paragraphs}</span> paragraphs.
|
118 |
+
In total, we found <span style="color: red;">{num_references}</span>
|
119 |
+
to vulnerable groups.</div>""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
|
121 |
+
|
122 |
+
### Pie chart
|
123 |
+
|
124 |
+
# Create a df that stores all the labels
|
125 |
+
df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
|
126 |
+
|
127 |
+
# Count how often each label appears in the "Vulnerability Labels" column
|
128 |
+
label_counts = st.session_state['key0']['Vulnerability Label'].value_counts().reset_index()
|
129 |
+
label_counts.columns = ['Label', 'Count']
|
130 |
+
|
131 |
+
# Merge the label counts with the df_label DataFrame
|
132 |
+
df_labels = df_labels.merge(label_counts, on='Label', how='left')
|
133 |
+
|
134 |
+
# Configure graph
|
135 |
+
fig = px.pie(df_labels,
|
136 |
+
names="Label",
|
137 |
+
values="Count",
|
138 |
+
title='Label Counts',
|
139 |
+
hover_name="Count",
|
140 |
+
color_discrete_sequence=px.colors.qualitative.Plotly
|
141 |
+
)
|
142 |
|
143 |
+
#Show plot
|
144 |
+
st.plotly_chart(fig, use_container_width=True)
|
145 |
+
|
146 |
### Table
|
147 |
+
st.table(st.session_state['key0'])
|
148 |
|
149 |
# vulnerability_analysis.vulnerability_display()
|
150 |
# elif topic == 'Action':
|