| """Outils et plateformes grand public : hors perimetre de masquage. |
| |
| Decision produit (2026-07-31, Loic) : masquer « Zoom », « Excel » ou |
| « Stripe » ne protege personne et rend le texte inutilisable. Le type |
| COMPANY est reserve aux organisations qui IDENTIFIENT quelqu'un : societe |
| cliente, fournisseur nomme, cabinet, employeur. |
| |
| Ces valeurs sortent donc du gold ET des predictions. Un client qui veut les |
| masquer quand meme le fera par politique (types= dans pseudonymize). |
| """ |
| import re |
| import unicodedata |
| from functools import lru_cache |
| from pathlib import Path |
|
|
| LISTE = Path(__file__).resolve().parents[2] / "data" / "tools_grand_public.txt" |
|
|
|
|
| def _norm(s: str) -> str: |
| s = unicodedata.normalize("NFD", s.lower()) |
| s = "".join(c for c in s if unicodedata.category(c) != "Mn") |
| return re.sub(r"[^a-z0-9]+", " ", s).strip() |
|
|
|
|
| @lru_cache(maxsize=1) |
| def _set(): |
| if not LISTE.exists(): |
| return set() |
| return {_norm(l) for l in LISTE.read_text(encoding="utf-8").splitlines() if l.strip()} |
|
|
|
|
| def est_outil(valeur: str) -> bool: |
| """Vrai si la valeur designe un outil/plateforme grand public.""" |
| v = _norm(valeur) |
| if not v: |
| return False |
| if v in _set(): |
| return True |
| |
| racine = v.split(" ")[0] |
| return racine in _set() and len(v.split()) <= 2 |
|
|
|
|
| def filtrer(spans: list[dict]) -> list[dict]: |
| """Retire les COMPANY qui sont des outils grand public.""" |
| return [s for s in spans |
| if not (s["type"] == "COMPANY" and est_outil(s["value"]))] |
|
|