arogeriogel commited on
Commit
05ffc54
1 Parent(s): 68b37b9

including metadata

Browse files
Files changed (1) hide show
  1. app.py +4 -1
app.py CHANGED
@@ -3,7 +3,7 @@ import streamlit as st
3
  import re
4
  import logging
5
  from presidio_anonymizer import AnonymizerEngine
6
- from presidio_analyzer import AnalyzerEngine, PatternRecognizer
7
 
8
  from annotated_text import annotated_text
9
  from flair_recognizer import FlairRecognizer
@@ -47,6 +47,7 @@ def analyze(**kwargs):
47
  f"type of excluded_words_recognizer: {type(st.session_state.excluded_words)}\n"
48
  )
49
  excluded_words_recognizer = PatternRecognizer(supported_entity="MANUAL ADD",
 
50
  deny_list=[st.session_state.excluded_words])
51
  analyzer_engine_instance.registry.add_recognizer(excluded_words_recognizer)
52
 
@@ -182,6 +183,8 @@ def anonymise_text():
182
  def clear_results():
183
  st.session_state.anon_results=""
184
  st.session_state.analyze_results=""
 
 
185
 
186
  #######################################
187
  #### Initialize "global" variables ####
 
3
  import re
4
  import logging
5
  from presidio_anonymizer import AnonymizerEngine
6
+ from presidio_analyzer import AnalyzerEngine, PatternRecognizer, RecognizerResult
7
 
8
  from annotated_text import annotated_text
9
  from flair_recognizer import FlairRecognizer
 
47
  f"type of excluded_words_recognizer: {type(st.session_state.excluded_words)}\n"
48
  )
49
  excluded_words_recognizer = PatternRecognizer(supported_entity="MANUAL ADD",
50
+ name="Excluded words recognizer",
51
  deny_list=[st.session_state.excluded_words])
52
  analyzer_engine_instance.registry.add_recognizer(excluded_words_recognizer)
53
 
 
183
  def clear_results():
184
  st.session_state.anon_results=""
185
  st.session_state.analyze_results=""
186
+ if not st.session_state.excluded_words:
187
+ analyzer_engine().registry.remove_recognizer("Excluded words recognizer")
188
 
189
  #######################################
190
  #### Initialize "global" variables ####