Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -34,7 +34,7 @@ def install_packages():
|
|
34 |
install_packages()
|
35 |
|
36 |
import appStore.vulnerability_analysis as vulnerability_analysis
|
37 |
-
import appStore.target as
|
38 |
import appStore.doc_processing as processing
|
39 |
from utils.uploadAndExample import add_upload
|
40 |
from utils.vulnerability_classifier import label_dict
|
@@ -95,79 +95,82 @@ if st.button("Analyze Document"):
|
|
95 |
# If there is data stored
|
96 |
if 'key0' in st.session_state:
|
97 |
|
98 |
-
|
|
|
|
|
|
|
99 |
|
100 |
-
#with st.sidebar:
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
|
105 |
-
#if topic == 'Vulnerability':
|
106 |
|
107 |
-
# Assign dataframe a name
|
108 |
-
df_vul = st.session_state['key0']
|
109 |
-
st.write(df_vul)
|
110 |
|
111 |
-
col1, col2 = st.columns([1,1])
|
112 |
|
113 |
-
with col1:
|
114 |
|
115 |
-
|
116 |
-
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
with col2:
|
132 |
|
133 |
-
|
134 |
|
135 |
-
|
136 |
-
|
137 |
|
138 |
-
|
139 |
-
|
140 |
|
141 |
-
|
142 |
-
|
143 |
|
144 |
-
|
145 |
-
|
146 |
|
147 |
-
|
148 |
-
|
149 |
|
150 |
-
|
151 |
-
|
152 |
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
|
157 |
-
# # Configure graph
|
158 |
-
# fig = px.pie(df_labels,
|
159 |
-
# names="Label",
|
160 |
-
# values="Count",
|
161 |
-
# title='Label Counts',
|
162 |
-
# hover_name="Count",
|
163 |
-
# color_discrete_sequence=px.colors.qualitative.Plotly
|
164 |
-
# )
|
165 |
|
166 |
-
# #Show plot
|
167 |
-
# st.plotly_chart(fig, use_container_width=True)
|
168 |
|
169 |
-
# ### Table
|
170 |
-
st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])
|
171 |
|
172 |
# vulnerability_analysis.vulnerability_display()
|
173 |
# elif topic == 'Action':
|
|
|
34 |
install_packages()
|
35 |
|
36 |
import appStore.vulnerability_analysis as vulnerability_analysis
|
37 |
+
import appStore.target as target_analysis
|
38 |
import appStore.doc_processing as processing
|
39 |
from utils.uploadAndExample import add_upload
|
40 |
from utils.vulnerability_classifier import label_dict
|
|
|
95 |
# If there is data stored
|
96 |
if 'key0' in st.session_state:
|
97 |
|
98 |
+
vulnerability_analysis.vulnerability_display()
|
99 |
+
target_analysis.target_display()
|
100 |
+
|
101 |
+
# ###################################################################
|
102 |
|
103 |
+
# #with st.sidebar:
|
104 |
+
# # topic = st.radio(
|
105 |
+
# # "Which category you want to explore?",
|
106 |
+
# # (['Vulnerability', 'Concrete targets/actions/measures']))
|
107 |
|
108 |
+
# #if topic == 'Vulnerability':
|
109 |
|
110 |
+
# # Assign dataframe a name
|
111 |
+
# df_vul = st.session_state['key0']
|
112 |
+
# st.write(df_vul)
|
113 |
|
114 |
+
# col1, col2 = st.columns([1,1])
|
115 |
|
116 |
+
# with col1:
|
117 |
|
118 |
+
# # Header
|
119 |
+
# st.subheader("Explore references to vulnerable groups:")
|
120 |
|
121 |
+
# # Text
|
122 |
+
# num_paragraphs = len(df_vul['Vulnerability Label'])
|
123 |
+
# num_references = df_vul['Vulnerability Label'].apply(lambda x: 'Other' not in x).sum()
|
124 |
|
125 |
+
# st.markdown(f"""<div style="text-align: justify;"> The document contains a
|
126 |
+
# total of <span style="color: red;">{num_paragraphs}</span> paragraphs.
|
127 |
+
# We identified <span style="color: red;">{num_references}</span>
|
128 |
+
# references to vulnerable groups.</div>
|
129 |
+
# <br>
|
130 |
+
# In the pie chart on the right you can see the distribution of the different
|
131 |
+
# groups defined. For a more detailed view in the text, see the paragraphs and
|
132 |
+
# their respective labels in the table below.</div>""", unsafe_allow_html=True)
|
133 |
+
|
134 |
+
# with col2:
|
135 |
|
136 |
+
# ### Bar chart
|
137 |
|
138 |
+
# # # Create a df that stores all the labels
|
139 |
+
# df_labels = pd.DataFrame(list(label_dict.items()), columns=['Label ID', 'Label'])
|
140 |
|
141 |
+
# # Count how often each label appears in the "Vulnerability Labels" column
|
142 |
+
# group_counts = {}
|
143 |
|
144 |
+
# # Iterate through each sublist
|
145 |
+
# for index, row in df_vul.iterrows():
|
146 |
|
147 |
+
# # Iterate through each group in the sublist
|
148 |
+
# for sublist in row['Vulnerability Label']:
|
149 |
|
150 |
+
# # Update the count in the dictionary
|
151 |
+
# group_counts[sublist] = group_counts.get(sublist, 0) + 1
|
152 |
|
153 |
+
# # Create a new dataframe from group_counts
|
154 |
+
# df_label_count = pd.DataFrame(list(group_counts.items()), columns=['Label', 'Count'])
|
155 |
|
156 |
+
# # Merge the label counts with the df_label DataFrame
|
157 |
+
# df_label_count = df_labels.merge(df_label_count, on='Label', how='left')
|
158 |
+
# st.write("df_label_count")
|
159 |
|
160 |
+
# # # Configure graph
|
161 |
+
# # fig = px.pie(df_labels,
|
162 |
+
# # names="Label",
|
163 |
+
# # values="Count",
|
164 |
+
# # title='Label Counts',
|
165 |
+
# # hover_name="Count",
|
166 |
+
# # color_discrete_sequence=px.colors.qualitative.Plotly
|
167 |
+
# # )
|
168 |
|
169 |
+
# # #Show plot
|
170 |
+
# # st.plotly_chart(fig, use_container_width=True)
|
171 |
|
172 |
+
# # ### Table
|
173 |
+
# st.table(df_vul[df_vul['Vulnerability Label'] != 'Other'])
|
174 |
|
175 |
# vulnerability_analysis.vulnerability_display()
|
176 |
# elif topic == 'Action':
|