leavoigt commited on
Commit
879b028
1 Parent(s): d550acd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -31
app.py CHANGED
@@ -103,42 +103,48 @@ if 'key0' in st.session_state:
103
 
104
  if topic == 'Vulnerability':
105
 
 
 
 
 
 
106
 
107
- col1, col2 = st.columns([1,1])
108
-
109
- with col1:
110
-
111
- ### Table
112
- st.table(st.session_state['key0'])
113
 
114
- with col2:
115
-
116
- ### Pie chart
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
- # Configure graph
129
- fig = px.pie(df_labels,
130
- names="Label",
131
- values="Count",
132
- title='Label Counts',
133
- hover_name="Count",
134
- color_discrete_sequence=px.colors.qualitative.Plotly
135
- )
136
-
137
- #Show plot
138
- st.plotly_chart(fig, use_container_width=True)
 
 
 
 
 
 
 
 
 
 
139
 
 
 
 
140
  ### Table
141
- #st.table(st.session_state['key0'])
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':