diff --git a/anonymizer_core_refactored_onnx.py b/anonymizer_core_refactored_onnx.py index fbea58e..1bcc3ed 100644 --- a/anonymizer_core_refactored_onnx.py +++ b/anonymizer_core_refactored_onnx.py @@ -339,6 +339,8 @@ _MEDICAL_STOP_WORDS_SET = { "evolution", "évolution", "explorations", "fermeture", "allergie", "allergies", "lotissement", "cholangiographie", "cholecystectomie", "cholécystectomie", "paracetamol", "paracétamol", "unité", "unite", + # FP résiduels batch 10 OGC (termes médicaux/instructions soins) + "glyc", "glycosurie", "vider", "forte", } # Enrichissement automatique avec les ~4000 noms de médicaments d'edsnlp _MEDICAL_STOP_WORDS_SET.update(_load_edsnlp_drug_names()) @@ -1484,7 +1486,14 @@ def redact_pdf_raster(original_pdf: Path, audit: List[PiiHit], out_pdf: Path, dp img = Image.frombytes("RGB", [pix.width, pix.height], pix.samples) draw = ImageDraw.Draw(img) for r in all_rects.get(pno, []): - draw.rectangle([r.x0 * zoom, r.y0 * zoom, r.x1 * zoom, r.y1 * zoom], fill=(0, 0, 0)) + # Rétrécir légèrement les rectangles pour éviter le débordement sur le texte adjacent + shrink = 1.5 # pixels à retirer de chaque côté + x0 = r.x0 * zoom + shrink + y0 = r.y0 * zoom + x1 = r.x1 * zoom - shrink + y1 = r.y1 * zoom + if x1 > x0: + draw.rectangle([x0, y0, x1, y1], fill=(0, 0, 0)) # Incrustation OGC en haut à droite if ogc_label: from PIL import ImageFont