leavoigt commited on
Commit
174e5db
1 Parent(s): ccd8d04

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -35
app.py CHANGED
@@ -105,44 +105,48 @@ if 'key0' in st.session_state:
105
 
106
  # Assign dataframe a name
107
  df_vul = st.session_state['key0']
108
-
109
- # Header
110
- st.subheader("Explore the references to vulnerable groups:")
111
 
112
- # Text
113
- num_paragraphs = len(df_vul['Vulnerability Label'])
114
- num_references = len(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
- paragraphs that contain a reference to a vulnerable group.
120
- </div>""", unsafe_allow_html=True)
121
-
122
-
123
- ### Pie chart
124
-
125
- # Create a df that stores all the labels
126
- df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
127
 
128
- # Count how often each label appears in the "Vulnerability Labels" column
129
- label_counts = df_vul['Vulnerability Label'].value_counts().reset_index()
130
- label_counts.columns = ['Label', 'Count']
131
 
132
- # Merge the label counts with the df_label DataFrame
133
- df_labels = df_labels.merge(label_counts, on='Label', how='left')
134
-
135
- # Configure graph
136
- fig = px.pie(df_labels,
137
- names="Label",
138
- values="Count",
139
- title='Label Counts',
140
- hover_name="Count",
141
- color_discrete_sequence=px.colors.qualitative.Plotly
142
- )
143
-
144
- #Show plot
145
- st.plotly_chart(fig, use_container_width=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
146
 
147
  ### Table
148
  st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])
 
105
 
106
  # Assign dataframe a name
107
  df_vul = st.session_state['key0']
 
 
 
108
 
109
+ col1, col2 = st.columns([1,1])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
+ with col1:
112
+ # Header
113
+ st.subheader("Explore references to vulnerable groups:")
114
 
115
+ # Text
116
+ num_paragraphs = len(df_vul['Vulnerability Label'])
117
+ num_references = len(df_vul[df_vul['Vulnerability Label'] != 'Other'])
118
+
119
+ st.markdown(f"""<div style="text-align: justify;"> The document contains a
120
+ total of <span style="color: red;">{num_paragraphs}</span> paragraphs.
121
+ We found <span style="color: red;">{num_references}</span>
122
+ references to vulnerable group. The chart on the right shows the distribution
123
+ of those references. In the table below, you can find the text that has been
124
+ identified.</div>""", unsafe_allow_html=True)
125
+
126
+ with col2:
127
+ ### Pie chart
128
+
129
+ # Create a df that stores all the labels
130
+ df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
131
+
132
+ # Count how often each label appears in the "Vulnerability Labels" column
133
+ label_counts = df_vul['Vulnerability Label'].value_counts().reset_index()
134
+ label_counts.columns = ['Label', 'Count']
135
+
136
+ # Merge the label counts with the df_label DataFrame
137
+ df_labels = df_labels.merge(label_counts, on='Label', how='left')
138
+
139
+ # Configure graph
140
+ fig = px.pie(df_labels,
141
+ names="Label",
142
+ values="Count",
143
+ title='Label Counts',
144
+ hover_name="Count",
145
+ color_discrete_sequence=px.colors.qualitative.Plotly
146
+ )
147
+
148
+ #Show plot
149
+ st.plotly_chart(fig, use_container_width=True)
150
 
151
  ### Table
152
  st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])