Spaces:
Sleeping
Sleeping
Commit ·
3b0bcd0
1
Parent(s): ffd8d4a
fix(recognition): apply fail-safe Dutch address span precision
Browse files- presidio_helpers.py +6 -1
presidio_helpers.py
CHANGED
|
@@ -27,6 +27,7 @@ from presidio_nlp_engine_config import (
|
|
| 27 |
create_nlp_engine_with_azure_ai_language,
|
| 28 |
create_nlp_engine_with_stanza,
|
| 29 |
)
|
|
|
|
| 30 |
|
| 31 |
try:
|
| 32 |
from dutch_recognizers import get_dutch_recognizers, get_dutch_entity_names
|
|
@@ -169,9 +170,13 @@ def analyze(
|
|
| 169 |
kwargs["ad_hoc_recognizers"] = [ad_hoc_recognizer] if ad_hoc_recognizer else []
|
| 170 |
del kwargs["regex_params"]
|
| 171 |
|
| 172 |
-
|
| 173 |
**kwargs
|
| 174 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
|
| 176 |
|
| 177 |
def anonymize(
|
|
|
|
| 27 |
create_nlp_engine_with_azure_ai_language,
|
| 28 |
create_nlp_engine_with_stanza,
|
| 29 |
)
|
| 30 |
+
from dutch_address_span_precision import tighten_dutch_address_results
|
| 31 |
|
| 32 |
try:
|
| 33 |
from dutch_recognizers import get_dutch_recognizers, get_dutch_entity_names
|
|
|
|
| 170 |
kwargs["ad_hoc_recognizers"] = [ad_hoc_recognizer] if ad_hoc_recognizer else []
|
| 171 |
del kwargs["regex_params"]
|
| 172 |
|
| 173 |
+
results = analyzer_engine(model_family, model_path, ta_key, ta_endpoint).analyze(
|
| 174 |
**kwargs
|
| 175 |
)
|
| 176 |
+
# The underlying NL_ADDRESS recognizer is deliberately recall-oriented.
|
| 177 |
+
# Narrow only provably over-broad address spans; ambiguous shapes stay
|
| 178 |
+
# untouched so privacy-critical recall fails safe.
|
| 179 |
+
return tighten_dutch_address_results(kwargs.get("text", ""), results)
|
| 180 |
|
| 181 |
|
| 182 |
def anonymize(
|