beki commited on
Commit
6e5e1da
1 Parent(s): 4ee52e2

Update flair_recognizer.py

Browse files
Files changed (1) hide show
  1. flair_recognizer.py +25 -1
flair_recognizer.py CHANGED
@@ -84,7 +84,8 @@ class FlairRecognizer(EntityRecognizer):
84
  ]
85
 
86
  MODEL_LANGUAGES = {
87
- "en": "beki/flair-pii-english",
 
88
  }
89
 
90
  PRESIDIO_EQUIVALENCES = {
@@ -219,3 +220,26 @@ class FlairRecognizer(EntityRecognizer):
219
  return any(
220
  [entity in egrp and label in lgrp for egrp, lgrp in check_label_groups]
221
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  ]
85
 
86
  MODEL_LANGUAGES = {
87
+ "en":"beki/flair-pii-english-large",
88
+ # "en":"flair-trf.pt",
89
  }
90
 
91
  PRESIDIO_EQUIVALENCES = {
 
220
  return any(
221
  [entity in egrp and label in lgrp for egrp, lgrp in check_label_groups]
222
  )
223
+
224
+
225
+ if __name__ == "__main__":
226
+
227
+ from presidio_analyzer import AnalyzerEngine, RecognizerRegistry
228
+
229
+ flair_recognizer = (
230
+ FlairRecognizer()
231
+ ) # This would download a very large (+2GB) model on the first run
232
+
233
+ registry = RecognizerRegistry()
234
+ registry.add_recognizer(flair_recognizer)
235
+
236
+ analyzer = AnalyzerEngine(registry=registry)
237
+
238
+ results = analyzer.analyze(
239
+ "{first_name: Moustafa, sale_id: 235234}",
240
+ language="en",
241
+ return_decision_process=True,
242
+ )
243
+ for result in results:
244
+ print(result)
245
+ print(result.analysis_explanation)