Spaces:
Runtime error
Runtime error
rotaba
commited on
Commit
·
2a2cc4e
1
Parent(s):
0d986e2
changes layout
Browse files
app.py
CHANGED
|
@@ -117,10 +117,35 @@ def annotate(text, st_analyze_results, st_entities):
|
|
| 117 |
|
| 118 |
st.set_page_config(page_title="Bitahoy demo", layout="wide")
|
| 119 |
|
| 120 |
-
# Side bar
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
# add picture with
|
| 122 |
st.sidebar.image("assets/bitahoy-logo.png", width=200)
|
| 123 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 124 |
st_entities = st.sidebar.multiselect(
|
| 125 |
label="Which entities to look for?",
|
| 126 |
options=get_supported_entities(),
|
|
@@ -134,12 +159,13 @@ st_threshold = st.sidebar.slider(
|
|
| 134 |
st_return_decision_process = st.sidebar.checkbox(
|
| 135 |
"Add analysis explanations in json")
|
| 136 |
|
| 137 |
-
st.
|
| 138 |
-
|
| 139 |
-
|
| 140 |
-
|
| 141 |
-
|
| 142 |
-
)
|
|
|
|
| 143 |
|
| 144 |
st.sidebar.info(
|
| 145 |
"Privy is an open source framework for synthetic data generation in protocol trace formats (json, sql, html etc). Presidio is an open source framework for PII detection and anonymization. "
|
|
@@ -162,13 +188,14 @@ if "visibility" not in st.session_state:
|
|
| 162 |
col1, col2 = st.columns(2)
|
| 163 |
|
| 164 |
with col1:
|
|
|
|
| 165 |
# st.radio(
|
| 166 |
# "Set selectbox label visibility 👉",
|
| 167 |
# key="visibility",
|
| 168 |
# options=["visible", "hidden", "collapsed"],
|
| 169 |
# )
|
| 170 |
st_text = st.text_area(
|
| 171 |
-
label="
|
| 172 |
value="SELECT shipping FROM users WHERE shipping = '201 Thayer St Providence RI 02912'"
|
| 173 |
"\n\n"
|
| 174 |
"{user: Willie Porter, ip: 192.168.2.80, email: willie@gmail.com}",
|
|
@@ -176,41 +203,28 @@ with col1:
|
|
| 176 |
)
|
| 177 |
|
| 178 |
with col2:
|
| 179 |
-
st.
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
# end of col
|
| 191 |
-
button = st.button("Detect PII")
|
| 192 |
|
| 193 |
if 'first_load' not in st.session_state:
|
| 194 |
st.session_state['first_load'] = True
|
| 195 |
|
| 196 |
# After
|
| 197 |
-
st.subheader("Analyzed")
|
| 198 |
-
with st.spinner("Analyzing..."):
|
| 199 |
-
if button or st.session_state.first_load:
|
| 200 |
-
st_analyze_results = analyze(
|
| 201 |
-
text=st_text,
|
| 202 |
-
entities=st_entities,
|
| 203 |
-
language="en",
|
| 204 |
-
score_threshold=st_threshold,
|
| 205 |
-
return_decision_process=st_return_decision_process,
|
| 206 |
-
)
|
| 207 |
-
annotated_tokens = annotate(st_text, st_analyze_results, st_entities)
|
| 208 |
-
# annotated_tokens
|
| 209 |
-
annotated_text(*annotated_tokens)
|
| 210 |
-
# vertical space
|
| 211 |
-
st.text("")
|
| 212 |
|
| 213 |
-
st.subheader("Anonymized")
|
| 214 |
|
| 215 |
with st.spinner("Anonymizing..."):
|
| 216 |
if button or st.session_state.first_load:
|
|
|
|
| 117 |
|
| 118 |
st.set_page_config(page_title="Bitahoy demo", layout="wide")
|
| 119 |
|
| 120 |
+
# Side bar -------------------------------------------
|
| 121 |
+
st.sidebar.markdown(
|
| 122 |
+
"""
|
| 123 |
+
Detect and anonymize PII in structured text such as protocol traces (JSON, SQL, XML etc.)
|
| 124 |
+
"""
|
| 125 |
+
)
|
| 126 |
# add picture with
|
| 127 |
st.sidebar.image("assets/bitahoy-logo.png", width=200)
|
| 128 |
|
| 129 |
+
# dropdown
|
| 130 |
+
titles, urls, jsons = load_data("assets/data_sorted.csv")
|
| 131 |
+
option_list = titles
|
| 132 |
+
option = st.selectbox(
|
| 133 |
+
'Choose an existing structured input?',
|
| 134 |
+
option_list)
|
| 135 |
+
|
| 136 |
+
st.write('You selected:', option)
|
| 137 |
+
|
| 138 |
+
#romans complex dropdown
|
| 139 |
+
# st.checkbox("Enable/Disable input of existing data", key="disabled")
|
| 140 |
+
#
|
| 141 |
+
# option = st.selectbox(
|
| 142 |
+
# "Choose an existing structured input?",
|
| 143 |
+
# option_list,
|
| 144 |
+
# # label_visibility=st.session_state.visibility,
|
| 145 |
+
# disabled=st.session_state.disabled,
|
| 146 |
+
# )
|
| 147 |
+
# st.write('You selected:', option)
|
| 148 |
+
|
| 149 |
st_entities = st.sidebar.multiselect(
|
| 150 |
label="Which entities to look for?",
|
| 151 |
options=get_supported_entities(),
|
|
|
|
| 159 |
st_return_decision_process = st.sidebar.checkbox(
|
| 160 |
"Add analysis explanations in json")
|
| 161 |
|
| 162 |
+
button = st.button("Detect PII")
|
| 163 |
+
|
| 164 |
+
# vertical space
|
| 165 |
+
st.text("")
|
| 166 |
+
# vertical space
|
| 167 |
+
st.text("")
|
| 168 |
+
|
| 169 |
|
| 170 |
st.sidebar.info(
|
| 171 |
"Privy is an open source framework for synthetic data generation in protocol trace formats (json, sql, html etc). Presidio is an open source framework for PII detection and anonymization. "
|
|
|
|
| 188 |
col1, col2 = st.columns(2)
|
| 189 |
|
| 190 |
with col1:
|
| 191 |
+
st.subheader("Input")
|
| 192 |
# st.radio(
|
| 193 |
# "Set selectbox label visibility 👉",
|
| 194 |
# key="visibility",
|
| 195 |
# options=["visible", "hidden", "collapsed"],
|
| 196 |
# )
|
| 197 |
st_text = st.text_area(
|
| 198 |
+
label="Use dropdown or type in some text",
|
| 199 |
value="SELECT shipping FROM users WHERE shipping = '201 Thayer St Providence RI 02912'"
|
| 200 |
"\n\n"
|
| 201 |
"{user: Willie Porter, ip: 192.168.2.80, email: willie@gmail.com}",
|
|
|
|
| 203 |
)
|
| 204 |
|
| 205 |
with col2:
|
| 206 |
+
st.subheader("Analyzed")
|
| 207 |
+
with st.spinner("Analyzing..."):
|
| 208 |
+
if button or st.session_state.first_load:
|
| 209 |
+
st_analyze_results = analyze(
|
| 210 |
+
text=st_text,
|
| 211 |
+
entities=st_entities,
|
| 212 |
+
language="en",
|
| 213 |
+
score_threshold=st_threshold,
|
| 214 |
+
return_decision_process=st_return_decision_process,
|
| 215 |
+
)
|
| 216 |
+
annotated_tokens = annotate(st_text, st_analyze_results, st_entities)
|
| 217 |
+
# annotated_tokens
|
| 218 |
+
annotated_text(*annotated_tokens)
|
| 219 |
|
| 220 |
# end of col
|
|
|
|
| 221 |
|
| 222 |
if 'first_load' not in st.session_state:
|
| 223 |
st.session_state['first_load'] = True
|
| 224 |
|
| 225 |
# After
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
|
| 227 |
+
st.subheader("Anonymized final results")
|
| 228 |
|
| 229 |
with st.spinner("Anonymizing..."):
|
| 230 |
if button or st.session_state.first_load:
|