beki commited on
Commit
b1efd98
1 Parent(s): c065ffa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -6
app.py CHANGED
@@ -114,11 +114,6 @@ st_text = st.text_area(
114
  height=200,
115
  )
116
 
117
- button = st.button("Detect PII")
118
-
119
- if 'first_load' not in st.session_state:
120
- st.session_state['first_load'] = True
121
-
122
  # After
123
  st.subheader("Analyzed")
124
  with st.spinner("Analyzing..."):
@@ -142,8 +137,24 @@ 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")
 
114
  height=200,
115
  )
116
 
 
 
 
 
 
117
  # After
118
  st.subheader("Analyzed")
119
  with st.spinner("Analyzing..."):
 
137
  st_anonymize_results = anonymize(st_text, st_analyze_results)
138
  st_anonymize_results
139
 
140
+ # table result
141
+ st.subheader("Detailed Findings")
142
+ if st_analyze_results:
143
+ res_dicts = [r.to_dict() for r in st_analyze_results]
144
+ for d in res_dicts:
145
+ d['Value'] = st_text[d['start']:d['end']]
146
+ df = pd.DataFrame.from_records(res_dicts)
147
+ df = df[["entity_type", "Value", "score", "start", "end"]].rename(
148
+ {
149
+ "entity_type": "Entity type",
150
+ "start": "Start",
151
+ "end": "End",
152
+ "score": "Confidence",
153
+ },
154
+ axis=1,
155
+ )
156
 
157
+ st.dataframe(df, width=1000)
158
  # table result
159
  else:
160
  st.text("No findings")