Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -122,51 +122,32 @@ if 'first_load' not in st.session_state:
|
|
122 |
# After
|
123 |
st.subheader("Analyzed")
|
124 |
with st.spinner("Analyzing..."):
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
# vertical space
|
137 |
st.text("")
|
138 |
|
139 |
st.subheader("Anonymized")
|
140 |
|
141 |
with st.spinner("Anonymizing..."):
|
142 |
-
|
143 |
-
|
144 |
-
st_anonymize_results
|
145 |
|
146 |
|
147 |
-
# table result
|
148 |
-
st.subheader("Detailed Findings")
|
149 |
-
if st_analyze_results:
|
150 |
-
res_dicts = [r.to_dict() for r in st_analyze_results]
|
151 |
-
for d in res_dicts:
|
152 |
-
d['Value'] = st_text[d['start']:d['end']]
|
153 |
-
df = pd.DataFrame.from_records(res_dicts)
|
154 |
-
df = df[["entity_type", "Value", "score", "start", "end"]].rename(
|
155 |
-
{
|
156 |
-
"entity_type": "Entity type",
|
157 |
-
"start": "Start",
|
158 |
-
"end": "End",
|
159 |
-
"score": "Confidence",
|
160 |
-
},
|
161 |
-
axis=1,
|
162 |
-
)
|
163 |
|
164 |
-
|
165 |
else:
|
166 |
st.text("No findings")
|
167 |
|
168 |
-
st.session_state['first_load'] = True
|
169 |
-
|
170 |
# json result
|
171 |
class ToDictListEncoder(JSONEncoder):
|
172 |
"""Encode dict to json."""
|
|
|
122 |
# After
|
123 |
st.subheader("Analyzed")
|
124 |
with st.spinner("Analyzing..."):
|
125 |
+
st_analyze_results = analyze(
|
126 |
+
text=st_text,
|
127 |
+
entities=st_entities,
|
128 |
+
language="en",
|
129 |
+
score_threshold=st_threshold,
|
130 |
+
return_decision_process=st_return_decision_process,
|
131 |
+
)
|
132 |
+
annotated_tokens = annotate(st_text, st_analyze_results, st_entities)
|
133 |
+
# annotated_tokens
|
134 |
+
annotated_text(*annotated_tokens)
|
135 |
+
|
136 |
# vertical space
|
137 |
st.text("")
|
138 |
|
139 |
st.subheader("Anonymized")
|
140 |
|
141 |
with st.spinner("Anonymizing..."):
|
142 |
+
st_anonymize_results = anonymize(st_text, st_analyze_results)
|
143 |
+
st_anonymize_results
|
|
|
144 |
|
145 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
|
147 |
+
# table result
|
148 |
else:
|
149 |
st.text("No findings")
|
150 |
|
|
|
|
|
151 |
# json result
|
152 |
class ToDictListEncoder(JSONEncoder):
|
153 |
"""Encode dict to json."""
|