feat(gui): câbler les 7 toggles catégories au moteur (P1-2)
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9,10 +9,36 @@ from __future__ import annotations
|
||||
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Callable, List, Optional
|
||||
from typing import Callable, FrozenSet, List, Optional
|
||||
|
||||
from gui_v6.engine_bridge import EngineSettings
|
||||
|
||||
# Mapping centralisé champ ConfigState → CATÉGORIE moteur (Plan 1b / P1-2).
|
||||
#
|
||||
# Les 7 catégories doivent matcher EXACTEMENT le set accepté par
|
||||
# ``anonymizer_core_refactored_onnx.process_pdf(disabled_kinds=...)`` :
|
||||
# {"NOM", "DATE_NAISSANCE", "ETAB", "ADRESSE", "NIR", "TEL", "ADHERENT"}.
|
||||
#
|
||||
# Sémantique des booléens ``detect_*`` : True = « détecter cette catégorie »
|
||||
# (= masquer, comportement par défaut). False = laisser en clair → la catégorie
|
||||
# entre dans ``disabled_kinds``. Note : CODE_POSTAL suit le toggle ADRESSE côté
|
||||
# moteur (décision Dom 2026-06-26), aucun toggle dédié n'est exposé.
|
||||
#
|
||||
# L'ordre suit les 7 lignes de ``tab_config._DETECTION_OPTIONS`` :
|
||||
# Noms/prénoms · Dates de naissance · Établissements · Adresses/CP ·
|
||||
# N° sécurité sociale · Téléphones/e-mails · N° adhérent mutuelle.
|
||||
CATEGORY_FIELDS = {
|
||||
"detect_nom": "NOM",
|
||||
"detect_date_naissance": "DATE_NAISSANCE",
|
||||
"detect_etab": "ETAB",
|
||||
"detect_adresse": "ADRESSE",
|
||||
"detect_nir": "NIR",
|
||||
"detect_tel": "TEL",
|
||||
"detect_adherent": "ADHERENT",
|
||||
}
|
||||
# Catégories canoniques (ordre = ordre des toggles UI).
|
||||
DETECTION_CATEGORIES = tuple(CATEGORY_FIELDS.values())
|
||||
|
||||
|
||||
@dataclass
|
||||
class ConfigState:
|
||||
@@ -33,6 +59,26 @@ class ConfigState:
|
||||
mask_margin_y: int = 1
|
||||
mask_rounded_corners: bool = False
|
||||
|
||||
# 7 toggles « Données à détecter » — tous ON par défaut (zéro changement).
|
||||
detect_nom: bool = True
|
||||
detect_date_naissance: bool = True
|
||||
detect_etab: bool = True
|
||||
detect_adresse: bool = True
|
||||
detect_nir: bool = True
|
||||
detect_tel: bool = True
|
||||
detect_adherent: bool = True
|
||||
|
||||
def disabled_kinds(self) -> FrozenSet[str]:
|
||||
"""Set des CATÉGORIES décochées (laissées en clair).
|
||||
|
||||
Défaut (tous les toggles ON) ⇒ ``frozenset()`` (no-op moteur).
|
||||
"""
|
||||
return frozenset(
|
||||
category
|
||||
for field_name, category in CATEGORY_FIELDS.items()
|
||||
if not getattr(self, field_name)
|
||||
)
|
||||
|
||||
def to_engine_settings(self, config_path: Optional[Path] = None) -> EngineSettings:
|
||||
return EngineSettings(
|
||||
make_vector_redaction=False,
|
||||
@@ -43,6 +89,7 @@ class ConfigState:
|
||||
enable_gliner=self.enable_gliner,
|
||||
ogc_label=self.ogc_label,
|
||||
profile=self.profile,
|
||||
disabled_kinds=self.disabled_kinds(),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user