Download detect/tools_filter.py from 5000dev/noirci-bench: direct link, hf CLI and curl.
- Browser
- Download file 1.59 kB
-
https://huggingface.co/datasets/5000dev/noirci-bench/resolve/main/detect/tools_filter.py
- Command line
-
hf download hf://datasets/5000dev/noirci-bench/detect/tools_filter.py
-
curl -L -o tools_filter.py https://huggingface.co/datasets/5000dev/noirci-bench/resolve/main/detect/tools_filter.py
1.59 kB
| """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() | |
| 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 | |
| # "5000.dev" ou "stripe.com" : le nom de domaine d'un outil connu | |
| 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"]))] | |