From 94e5acd9fb5b7bbf2ff4b62d5a7a8e2958ba9c0f Mon Sep 17 00:00:00 2001 From: Domi31tls Date: Tue, 2 Jun 2026 14:44:59 +0200 Subject: [PATCH] =?UTF-8?q?feat(detect):=20F2=20capture=20du=20nom=20pr?= =?UTF-8?q?=C3=A9c=C3=A9dant=20le=20label=20"Nom=20usuel=20:"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Complète F3 (qui captait le nom APRÈS "Nom usuel :"). Dans certains comptes-rendus type BACTERIO, l'identité patient sous forme "NAME Prenom1 Prenom2" apparaît juste AVANT le label, sans label devant. Cas typique BACTERIO 23232115 : 10.40 SIMONET Marie lise ← cette ligne, pas attrapée par F3 Nom usuel : 14/03/1985 OYARCABAL ← capturée par F3 Ajout de RE_EXTRACT_NAME_BEFORE_NOM_USUEL qui regarde la ligne précédant directement le label "Nom usuel :" : si elle ressemble à "MAJUSCULES Prenom Prenom" (NAME ≥4 chars + 1 à 3 tokens en suite), on la capture en contexte "high" (champ DPI quasi-certain). Validation sur exemple synthétique : - F3 OYARCABAL : ['OYARCABAL'] ✅ - F2 SIMONET : ['SIMONET Marie lise'] ✅ Reste à valider sur retraitement audit_30 complet. Co-Authored-By: Claude Opus 4.7 (1M context) --- anonymizer_core_refactored_onnx.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/anonymizer_core_refactored_onnx.py b/anonymizer_core_refactored_onnx.py index 98a14a6..2214dd4 100644 --- a/anonymizer_core_refactored_onnx.py +++ b/anonymizer_core_refactored_onnx.py @@ -583,6 +583,14 @@ RE_EXTRACT_NOM_USUEL = re.compile( r"([A-ZÉÈÀÙÂÊÎÔÛÄËÏÖÜÇÑ][A-ZÉÈÀÙÂÊÎÔÛÄËÏÖÜÇÑ\-\']{3,})", re.MULTILINE, ) +# F2 — capture du nom utilisé PRÉCÉDANT le label "Nom usuel :". +# Cas typique BACTERIO : la ligne juste avant "Nom usuel :" contient +# l'identité patient sous forme "NAME Prenom1 Prenom2" sans label devant +# (ex: "SIMONET Marie lise\nNom usuel :"). On capture cette ligne entière. +RE_EXTRACT_NAME_BEFORE_NOM_USUEL = re.compile( + r"^([A-ZÉÈÀÙÂÊÎÔÛÄËÏÖÜÇÑ]{4,}(?:\s+[A-Za-zÀ-Ÿ\-\']+){1,3})\s*\n\s*Nom\s+usuel\s*:", + re.MULTILINE, +) RE_EXTRACT_PRENOM = re.compile( r"Pr[ée]nom\s+(?:de\s+naissance|utilis[ée])\s*:\s*" r"([A-ZÉÈÀÙÂÊÎÔÛÄËÏÖÜÇÑ][A-ZÉÈÀÙÂÊÎÔÛÄËÏÖÜÇÑa-zéèàùâêîôûäëïöüçñ\-\' ]+?)(?:\s*$)", @@ -2154,6 +2162,9 @@ def _extract_document_names(full_text: str, cfg: Dict[str, Any]) -> Tuple[set, s # F3 — "Nom usuel :" + ligne suivante (skip date intermédiaire) for m in RE_EXTRACT_NOM_USUEL.finditer(full_text): _add_tokens_force_all(m.group(1), "RE_EXTRACT_NOM_USUEL", "high") + # F2 — ligne "NAME Prenom Prenom" précédant directement "Nom usuel :" + for m in RE_EXTRACT_NAME_BEFORE_NOM_USUEL.finditer(full_text): + _add_tokens_force_all(m.group(1), "RE_NAME_BEFORE_NOM_USUEL", "high") for m in RE_EXTRACT_NOM_PRENOM.finditer(full_text): _add_tokens_force_all(m.group(1), "RE_EXTRACT_NOM_PRENOM", "high") for m in RE_EXTRACT_PRENOM.finditer(full_text):