Spaces:
Runtime error
Runtime error
rotaba
commited on
Commit
·
c7838e5
1
Parent(s):
eb25919
renamed folder, added csv. added 2 columns and a helper to load csv
Browse files- app.py +58 -9
- assets/bitahoy-logo.png +0 -0
- assets/integ_table_new.csv +0 -0
app.py
CHANGED
@@ -13,10 +13,33 @@ import json
|
|
13 |
import warnings
|
14 |
import streamlit as st
|
15 |
import os
|
|
|
16 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
17 |
warnings.filterwarnings('ignore')
|
18 |
# from flair_recognizer import FlairRecognizer
|
19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
# Helper methods
|
21 |
@st.cache(allow_output_mutation=True)
|
22 |
def analyzer_engine():
|
@@ -98,11 +121,11 @@ def annotate(text, st_analyze_results, st_entities):
|
|
98 |
return tokens
|
99 |
|
100 |
|
101 |
-
st.set_page_config(page_title="
|
102 |
|
103 |
# Side bar
|
104 |
# add picture with
|
105 |
-
st.sidebar.image("
|
106 |
|
107 |
st_entities = st.sidebar.multiselect(
|
108 |
label="Which entities to look for?",
|
@@ -136,15 +159,41 @@ analyzer_load_state = st.info(
|
|
136 |
engine = analyzer_engine()
|
137 |
analyzer_load_state.empty()
|
138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
|
|
|
|
|
|
147 |
|
|
|
148 |
button = st.button("Detect PII")
|
149 |
|
150 |
if 'first_load' not in st.session_state:
|
|
|
13 |
import warnings
|
14 |
import streamlit as st
|
15 |
import os
|
16 |
+
import csv
|
17 |
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
18 |
warnings.filterwarnings('ignore')
|
19 |
# from flair_recognizer import FlairRecognizer
|
20 |
|
21 |
+
# helper method to open csv and read columns
|
22 |
+
def load_data(file_location):
|
23 |
+
"""Load data from file."""
|
24 |
+
|
25 |
+
# Open the file in 'r' mode, not 'rb'
|
26 |
+
csv_file = open(file_location, 'r')
|
27 |
+
dataA = []
|
28 |
+
dataB = []
|
29 |
+
dataC = []
|
30 |
+
|
31 |
+
# Read off and discard first line, to skip headers
|
32 |
+
csv_file.readline()
|
33 |
+
|
34 |
+
# Split columns while reading
|
35 |
+
for a, b, c in csv.reader(csv_file, delimiter=','):
|
36 |
+
# Append each variable to a separate list
|
37 |
+
dataA.append(a)
|
38 |
+
dataB.append(b)
|
39 |
+
dataC.append(c)
|
40 |
+
|
41 |
+
return dataA, dataB, dataC
|
42 |
+
|
43 |
# Helper methods
|
44 |
@st.cache(allow_output_mutation=True)
|
45 |
def analyzer_engine():
|
|
|
121 |
return tokens
|
122 |
|
123 |
|
124 |
+
st.set_page_config(page_title="Bitahoy demo", layout="wide")
|
125 |
|
126 |
# Side bar
|
127 |
# add picture with
|
128 |
+
st.sidebar.image("assets/bitahoy-logo.png", width=200)
|
129 |
|
130 |
st_entities = st.sidebar.multiselect(
|
131 |
label="Which entities to look for?",
|
|
|
159 |
engine = analyzer_engine()
|
160 |
analyzer_load_state.empty()
|
161 |
|
162 |
+
# col?
|
163 |
+
# Store the initial value of widgets in session state
|
164 |
+
if "visibility" not in st.session_state:
|
165 |
+
st.session_state.visibility = "visible"
|
166 |
+
st.session_state.disabled = False
|
167 |
+
|
168 |
+
col1, col2 = st.columns(2)
|
169 |
+
|
170 |
+
with col1:
|
171 |
+
# st.radio(
|
172 |
+
# "Set selectbox label visibility 👉",
|
173 |
+
# key="visibility",
|
174 |
+
# options=["visible", "hidden", "collapsed"],
|
175 |
+
# )
|
176 |
+
st_text = st.text_area(
|
177 |
+
label="Type in some text",
|
178 |
+
value="SELECT shipping FROM users WHERE shipping = '201 Thayer St Providence RI 02912'"
|
179 |
+
"\n\n"
|
180 |
+
"{user: Willie Porter, ip: 192.168.2.80, email: [email protected]}",
|
181 |
+
height=200,
|
182 |
+
)
|
183 |
|
184 |
+
with col2:
|
185 |
+
st.checkbox("Enable/Disable selectbox widget", key="disabled")
|
186 |
+
titles, urls, jsons = load_data("assets/integ_table_new.csv")
|
187 |
+
option_list = titles
|
188 |
+
option = st.selectbox(
|
189 |
+
"How would you like to be contacted?",
|
190 |
+
option_list,
|
191 |
+
# label_visibility=st.session_state.visibility,
|
192 |
+
disabled=st.session_state.disabled,
|
193 |
+
)
|
194 |
+
st.write('You selected:', option)
|
195 |
|
196 |
+
# end of col
|
197 |
button = st.button("Detect PII")
|
198 |
|
199 |
if 'first_load' not in st.session_state:
|
assets/bitahoy-logo.png
ADDED
![]() |
assets/integ_table_new.csv
ADDED
The diff for this file is too large to render.
See raw diff
|
|