petrsovadina commited on
Commit
e15afd8
1 Parent(s): 677bdad

Update presidio_streamlit.py

Browse files
Files changed (1) hide show
  1. presidio_streamlit.py +36 -11
presidio_streamlit.py CHANGED
@@ -128,14 +128,39 @@ try:
128
  help="Omezte seznam detekovaných osobních údajů."
129
  )
130
 
131
- # Analýza textu
132
- st_analyze_results = analyze(
133
- *analyzer_params,
134
- text=st_text,
135
- entities=st_entities,
136
- language="cs",
137
- score_threshold=st_threshold,
138
- return_decision_process=st_return_decision_process,
139
- allow_list=st_allow_list,
140
- deny_list=st_deny_list,
141
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  help="Omezte seznam detekovaných osobních údajů."
129
  )
130
 
131
+ # Analýza textu
132
+ st_analyze_results = analyze(
133
+ *analyzer_params,
134
+ text=st_text,
135
+ entities=st_entities,
136
+ language="cs",
137
+ score_threshold=st_threshold,
138
+ return_decision_process=st_return_decision_process,
139
+ allow_list=st_allow_list,
140
+ deny_list=st_deny_list
141
+ )
142
+
143
+ # Zobrazení výsledků
144
+ with col2:
145
+ st.subheader("Výstup")
146
+ if st_operator not in ("highlight", "synthesize"):
147
+ st_anonymize_results = anonymize(
148
+ text=st_text,
149
+ operator=st_operator,
150
+ mask_char=st_mask_char,
151
+ number_of_chars=st_number_of_chars,
152
+ encrypt_key=st_encrypt_key,
153
+ analyze_results=st_analyze_results
154
+ )
155
+ st.text_area(label="Anonymizováno", value=st_anonymize_results.text, height=400)
156
+ elif st_operator == "synthesize":
157
+ fake_data = create_fake_data(st_text, st_analyze_results, open_ai_params)
158
+ st.text_area(label="Syntetická data", value=fake_data, height=400)
159
+ else:
160
+ st.subheader("Zvýrazněno")
161
+ annotated_tokens = annotate(text=st_text, analyze_results=st_analyze_results)
162
+ annotated_text(*annotated_tokens)
163
+
164
+ except Exception as e:
165
+ logger.error(f"Došlo k chybě: {str(e)}", exc_info=True)
166
+ st.error(f"Došlo k chybě při zpracování: {str(e)}")