beki commited on
Commit
4f6453a
·
1 Parent(s): 2c8bd66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -12
app.py CHANGED
@@ -114,27 +114,34 @@ st_text = st.text_area(
114
  height=200,
115
  )
116
 
 
 
 
 
 
117
  # After
118
  st.subheader("Analyzed")
119
  with st.spinner("Analyzing..."):
120
- st_analyze_results = analyze(
121
- text=st_text,
122
- entities=st_entities,
123
- language="en",
124
- score_threshold=st_threshold,
125
- return_decision_process=st_return_decision_process,
126
- )
127
- annotated_tokens = annotate(st_text, st_analyze_results, st_entities)
128
- # annotated_tokens
129
- annotated_text(*annotated_tokens)
 
130
  # vertical space
131
  st.text("")
132
 
133
  st.subheader("Anonymized")
134
 
135
  with st.spinner("Anonymizing..."):
136
- st_anonymize_results = anonymize(st_text, st_analyze_results)
137
- st_anonymize_results
 
138
 
139
 
140
  # table result
@@ -158,6 +165,7 @@ if st_analyze_results:
158
  else:
159
  st.text("No findings")
160
 
 
161
 
162
  # json result
163
  class ToDictListEncoder(JSONEncoder):
 
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..."):
125
+ if button or st.session_state.first_load:
126
+ st_analyze_results = analyze(
127
+ text=st_text,
128
+ entities=st_entities,
129
+ language="en",
130
+ score_threshold=st_threshold,
131
+ return_decision_process=st_return_decision_process,
132
+ )
133
+ annotated_tokens = annotate(st_text, st_analyze_results, st_entities)
134
+ # annotated_tokens
135
+ annotated_text(*annotated_tokens)
136
  # vertical space
137
  st.text("")
138
 
139
  st.subheader("Anonymized")
140
 
141
  with st.spinner("Anonymizing..."):
142
+ if button or st.session_state.first_load:
143
+ st_anonymize_results = anonymize(st_text, st_analyze_results)
144
+ st_anonymize_results
145
 
146
 
147
  # table result
 
165
  else:
166
  st.text("No findings")
167
 
168
+ st.session_state['first_load'] = True
169
 
170
  # json result
171
  class ToDictListEncoder(JSONEncoder):