Noirci Bench : benchmark PII francais, avec son outil de mesure
Browse filesNeuf jeux, 9 380 documents, 56 763 entites annotees, 20 types.
L'apport n'est pas le corpus mais la METRIQUE : une entite n'est protegee
que si 100 % de ses caracteres significatifs sont masques. Un F1 par token
compte « Jean » masque dans « Jean Dupont » comme un demi-succes ; ici c'est
un echec, le patronyme est parti chez le fournisseur du modele. Le score
produit toujours DEUX nombres, fuite et sur-masquage : un outil qui masque
tout obtient 0 % de fuite et rend le document inutilisable.
Avertissement ecrit dans la carte plutot que tu : ces jeux synthetiques sont
SATURES (0,04 % de fuite pour notre pipeline) et ne discriminent plus. Nos
progres reels ont tous ete invisibles ici. A utiliser comme garde-fou
anti-regression, pas comme preuve.
Aucune correspondance reelle. Chaque fichier a ete controle contre les 597
valeurs identifiantes de nos documents prives : aucune n'y figure. Les jeux
derives d'ai4privacy sont exclus, sa licence interdit la redistribution.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
- LICENSE +21 -0
- README.md +113 -0
- data/bench_real_bodacc.jsonl +60 -0
- data/bench_real_fictif.jsonl +20 -0
- data/bench_realvals.jsonl +0 -0
- data/bench_v0.jsonl +0 -0
- data/bench_v1.jsonl +0 -0
- data/bench_v2.jsonl +0 -0
- data/bench_v3.jsonl +0 -0
- data/bench_v6.jsonl +0 -0
- data/bench_wikiner.jsonl +0 -0
- detect/__init__.py +0 -0
- detect/casse.py +94 -0
- detect/gazetteer.py +85 -0
- detect/gazetteer_company.py +119 -0
- detect/ner_baseline.py +33 -0
- detect/ner_onnx.py +261 -0
- detect/propagation.py +222 -0
- detect/regex_layer.py +377 -0
- detect/run.py +264 -0
- detect/tools_filter.py +47 -0
- detect/typing_vote.py +56 -0
- detect/vocabulaire.py +104 -0
- harness/__init__.py +0 -0
- harness/score.py +181 -0
- pii/__init__.py +0 -0
- pii/checksums.py +144 -0
- pii/generators.py +232 -0
- pii/real_factory.py +66 -0
- synth/__init__.py +0 -0
- synth/build.py +155 -0
- synth/llm_templates.py +205 -0
- synth/noise.py +44 -0
- synth/templates.py +364 -0
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
MIT License
|
| 2 |
+
|
| 3 |
+
Copyright (c) 2026 5000.dev (Loïc Boutet)
|
| 4 |
+
|
| 5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
+
of this software and associated documentation files (the "Software"), to deal
|
| 7 |
+
in the Software without restriction, including without limitation the rights
|
| 8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
+
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
+
furnished to do so, subject to the following conditions:
|
| 11 |
+
|
| 12 |
+
The above copyright notice and this permission notice shall be included in all
|
| 13 |
+
copies or substantial portions of the Software.
|
| 14 |
+
|
| 15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
+
SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language: fr
|
| 3 |
+
license: cc-by-4.0
|
| 4 |
+
task_categories:
|
| 5 |
+
- token-classification
|
| 6 |
+
tags:
|
| 7 |
+
- pii
|
| 8 |
+
- anonymization
|
| 9 |
+
- french
|
| 10 |
+
- benchmark
|
| 11 |
+
size_categories:
|
| 12 |
+
- 1K<n<10K
|
| 13 |
+
---
|
| 14 |
+
|
| 15 |
+
# Noirci Bench, mesurer la protection des données personnelles en français
|
| 16 |
+
|
| 17 |
+
Un benchmark de pseudonymisation française, **livré avec son outil de
|
| 18 |
+
mesure**. L'intérêt n'est pas le corpus, c'est la métrique : elle change les
|
| 19 |
+
conclusions.
|
| 20 |
+
|
| 21 |
+
Publié par [5000.dev](https://5000.dev). Code du moteur :
|
| 22 |
+
[5000dev/noirci](https://huggingface.co/5000dev/noirci).
|
| 23 |
+
|
| 24 |
+
## La métrique : un nom à moitié masqué est une fuite
|
| 25 |
+
|
| 26 |
+
Les travaux publiés rapportent en général un F1 par token. Masquer « Jean »
|
| 27 |
+
dans « Jean Dupont » y compte comme un demi-succès. Nous comptons ça comme
|
| 28 |
+
un **échec** : le nom de famille est parti chez le fournisseur du modèle, et
|
| 29 |
+
la personne est identifiable.
|
| 30 |
+
|
| 31 |
+
Une entité n'est protégée que si **100 % de ses caractères significatifs**
|
| 32 |
+
sont masqués. Le score produit deux nombres, jamais un seul :
|
| 33 |
+
|
| 34 |
+
- le **taux de fuite**, la part d'entités non intégralement masquées
|
| 35 |
+
- le **taux de sur-masquage**, la part de texte masqué pour rien
|
| 36 |
+
|
| 37 |
+
Le second compte autant que le premier. Un outil qui masque tout obtient 0 %
|
| 38 |
+
de fuite et rend le document inutilisable.
|
| 39 |
+
|
| 40 |
+
```bash
|
| 41 |
+
python -m harness.score data/bench_v6.jsonl mes_predictions.jsonl
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Les jeux
|
| 45 |
+
|
| 46 |
+
| Fichier | Documents | Entités | Ce qu'il mesure |
|
| 47 |
+
|---|---|---|---|
|
| 48 |
+
| `bench_v0.jsonl` | 600 | 3 953 | premier jeu métier, 30 % bruité OCR |
|
| 49 |
+
| `bench_v1.jsonl` | 1 500 | 10 010 | gabarits jamais vus, généralisation |
|
| 50 |
+
| `bench_v2.jsonl` | 1 500 | 10 158 | formats découverts sur documents réels |
|
| 51 |
+
| `bench_v3.jsonl` | 1 500 | 10 460 | v2 étendu |
|
| 52 |
+
| `bench_v6.jsonl` | 1 500 | 11 776 | le plus complet, 20 types |
|
| 53 |
+
| `bench_realvals.jsonl` | 1 000 | 7 046 | **vraies valeurs** BODACC et INSEE dans des gabarits |
|
| 54 |
+
| `bench_real_bodacc.jsonl` | 60 | 496 | annonces commerciales authentiques |
|
| 55 |
+
| `bench_real_fictif.jsonl` | 20 | 161 | documents rédigés à la main |
|
| 56 |
+
| `bench_wikiner.jsonl` | 1 700 | 2 703 | hors domaine, contrôle de non-régression |
|
| 57 |
+
|
| 58 |
+
Format : un objet JSON par ligne.
|
| 59 |
+
|
| 60 |
+
```json
|
| 61 |
+
{"id": "...", "text": "...", "entities": [{"start": 8, "end": 21, "type": "PERSON", "value": "Claire Baudry"}]}
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
+
Vingt types : PERSON, COMPANY, ADDRESS, CITY, EMAIL, PHONE, DATE, AMOUNT,
|
| 65 |
+
IBAN, SIREN, SIRET, TVA, NIR, CARD, PLATE, URL, IP, REF, SECRET, AGE.
|
| 66 |
+
|
| 67 |
+
## Un avertissement qui vaut mieux qu'un chiffre flatteur
|
| 68 |
+
|
| 69 |
+
**Ces jeux synthétiques sont saturés.** Notre pipeline y obtient 0,04 % de
|
| 70 |
+
fuite, et ce nombre ne veut plus rien dire. Un corpus généré finit par
|
| 71 |
+
mesurer la capacité d'un modèle à reconnaître son propre générateur.
|
| 72 |
+
|
| 73 |
+
Nos progrès les plus importants ont tous été **invisibles ici** et bien
|
| 74 |
+
réels sur de la correspondance authentique. Un exemple : notre détecteur de
|
| 75 |
+
montants exigeait le symbole euro après le nombre. Il ratait donc les francs
|
| 76 |
+
suisses, les magnitudes (« 30K€ ») et les fourchettes (« 20 à 30 k€ »), soit
|
| 77 |
+
54 % de fuite sur documents réels. Le benchmark synthétique n'en montrait
|
| 78 |
+
rien, parce que son générateur écrivait toujours les montants de la même
|
| 79 |
+
façon.
|
| 80 |
+
|
| 81 |
+
Utilisez ces jeux comme garde-fou anti-régression, pas comme preuve. La
|
| 82 |
+
mesure qui compte se fait sur vos propres documents annotés.
|
| 83 |
+
|
| 84 |
+
## Ce qui n'est pas ici
|
| 85 |
+
|
| 86 |
+
**Aucune correspondance réelle.** Nos mesures de référence portent sur 479
|
| 87 |
+
documents professionnels annotés à la main, qui contiennent des données
|
| 88 |
+
personnelles de tiers et ne seront jamais publiés. Le protocole, lui, est
|
| 89 |
+
public : le scorer de ce dépôt fonctionne sur n'importe quel jeu au même
|
| 90 |
+
format.
|
| 91 |
+
|
| 92 |
+
**Rien d'ai4privacy.** Nous l'utilisons en comparaison, sa licence interdit
|
| 93 |
+
la redistribution.
|
| 94 |
+
|
| 95 |
+
## Vérification
|
| 96 |
+
|
| 97 |
+
Chaque fichier a été contrôlé contre les 597 valeurs identifiantes de nos
|
| 98 |
+
documents réels (noms complets, adresses électroniques, téléphones, IBAN,
|
| 99 |
+
URL, sociétés en plusieurs mots). Aucune n'y figure.
|
| 100 |
+
|
| 101 |
+
Des prénoms isolés comme « Antoine » ou des communes comme « Bordeaux »
|
| 102 |
+
apparaissent dans les deux, parce que les générateurs puisent dans les mêmes
|
| 103 |
+
sources publiques INSEE. Ce sont des collisions, pas des copies.
|
| 104 |
+
|
| 105 |
+
## Sources et licence
|
| 106 |
+
|
| 107 |
+
Jeux sous CC-BY-4.0, code sous MIT.
|
| 108 |
+
|
| 109 |
+
- **BODACC** (DILA / data.gouv.fr) et **INSEE** (SIRENE, prénoms, COG) :
|
| 110 |
+
Licence Ouverte v2.0
|
| 111 |
+
- **WikiNER-fr-gold** (`danrun/WikiNER-fr-gold`) : CC-BY-4.0, attribution
|
| 112 |
+
requise, y compris pour les modèles entraînés dessus
|
| 113 |
+
- **Wikidata** : CC0
|
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id": "bodacc-A20260142100", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 100 du 29/07/2026. Greffe du Tribunal de Commerce de Tours. Immatriculation au RCS. Dénomination : Easy Send - Expedition. Forme : Société par actions simplifiée. Capital : 1050 EUR. Siège social : 4 allée Paul Louis Courier, 37540 Saint-Cyr-sur-Loire. RCS 107716540. Directeur général : Baudouin, Noah Steven Aurélien.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 78, "type": "CITY", "value": "Tours"}, {"start": 119, "end": 141, "type": "COMPANY", "value": "Easy Send - Expedition"}, {"start": 193, "end": 201, "type": "AMOUNT", "value": "1050 EUR"}, {"start": 218, "end": 244, "type": "ADDRESS", "value": "4 allée Paul Louis Courier"}, {"start": 246, "end": 251, "type": "ADDRESS", "value": "37540"}, {"start": 252, "end": 271, "type": "CITY", "value": "Saint-Cyr-sur-Loire"}, {"start": 277, "end": 286, "type": "SIREN", "value": "107716540"}, {"start": 308, "end": 338, "type": "PERSON", "value": "Baudouin, Noah Steven Aurélien"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142100"}
|
| 2 |
+
{"id": "bodacc-A20260142198", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 198 du 29/07/2026. Greffe du Tribunal de Commerce de Grenoble. Immatriculation au RCS. Dénomination : LH Twin. Forme : Société par Actions Simplifiée. Capital : 10000.00 EUR. Siège social : 4 Allée De l'Atrium, 38640 Claix. RCS 107592420.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 81, "type": "CITY", "value": "Grenoble"}, {"start": 122, "end": 129, "type": "COMPANY", "value": "LH Twin"}, {"start": 181, "end": 193, "type": "AMOUNT", "value": "10000.00 EUR"}, {"start": 210, "end": 229, "type": "ADDRESS", "value": "4 Allée De l'Atrium"}, {"start": 231, "end": 236, "type": "ADDRESS", "value": "38640"}, {"start": 237, "end": 242, "type": "CITY", "value": "Claix"}, {"start": 248, "end": 257, "type": "SIREN", "value": "107592420"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142198"}
|
| 3 |
+
{"id": "bodacc-A20260142207", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 207 du 29/07/2026. Greffe du Tribunal de Commerce de Grenoble. Immatriculation au RCS. Dénomination : SCI GA INVEST. Forme : Société Civile Immobilière. Capital : 1000.00 EUR. Siège social : 128 Chemin Des Dominicains, 38500 Coublevie. RCS 107597692.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 81, "type": "CITY", "value": "Grenoble"}, {"start": 122, "end": 135, "type": "COMPANY", "value": "SCI GA INVEST"}, {"start": 183, "end": 194, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 211, "end": 237, "type": "ADDRESS", "value": "128 Chemin Des Dominicains"}, {"start": 239, "end": 244, "type": "ADDRESS", "value": "38500"}, {"start": 245, "end": 254, "type": "CITY", "value": "Coublevie"}, {"start": 260, "end": 269, "type": "SIREN", "value": "107597692"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142207"}
|
| 4 |
+
{"id": "bodacc-A20260142213", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 213 du 29/07/2026. Greffe du Tribunal de Commerce de Grenoble. Immatriculation au RCS. Dénomination : TESS. Forme : Société Civile Immobilière. Capital : 1500.00 EUR. Siège social : 530 Route De la Blachette, 38680 Auberives-en-Royans. RCS 107592503.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 81, "type": "CITY", "value": "Grenoble"}, {"start": 122, "end": 126, "type": "COMPANY", "value": "TESS"}, {"start": 174, "end": 185, "type": "AMOUNT", "value": "1500.00 EUR"}, {"start": 202, "end": 227, "type": "ADDRESS", "value": "530 Route De la Blachette"}, {"start": 229, "end": 234, "type": "ADDRESS", "value": "38680"}, {"start": 235, "end": 254, "type": "CITY", "value": "Auberives-en-Royans"}, {"start": 260, "end": 269, "type": "SIREN", "value": "107592503"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142213"}
|
| 5 |
+
{"id": "bodacc-A20260142261", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 261 du 29/07/2026. Greffe du Tribunal de Commerce de St-Nazaire. Immatriculation au RCS. Dénomination : Les Gourdes. Forme : Société civile immobilière. Capital : 100 EUR. Siège social : 1 impasse de Kergourdin, 44350 Guérande. RCS 107480824.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 83, "type": "CITY", "value": "St-Nazaire"}, {"start": 124, "end": 135, "type": "COMPANY", "value": "Les Gourdes"}, {"start": 183, "end": 190, "type": "AMOUNT", "value": "100 EUR"}, {"start": 207, "end": 230, "type": "ADDRESS", "value": "1 impasse de Kergourdin"}, {"start": 232, "end": 237, "type": "ADDRESS", "value": "44350"}, {"start": 238, "end": 246, "type": "CITY", "value": "Guérande"}, {"start": 252, "end": 261, "type": "SIREN", "value": "107480824"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142261"}
|
| 6 |
+
{"id": "bodacc-A20260142286", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 286 du 29/07/2026. Greffe du Tribunal de Commerce d'Orléans. Immatriculation au RCS. Dénomination : JU DE FRUITS. Forme : Société à responsabilité limitée. Capital : 5000 EUR. Siège social : 85 route d'Orléans, 45110 Châteauneuf-sur-Loire. RCS 107706616. Gérant : Bergeron, Lucien Léandre.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 79, "type": "CITY", "value": "Orléans"}, {"start": 120, "end": 132, "type": "COMPANY", "value": "JU DE FRUITS"}, {"start": 186, "end": 194, "type": "AMOUNT", "value": "5000 EUR"}, {"start": 211, "end": 229, "type": "ADDRESS", "value": "85 route d'Orléans"}, {"start": 231, "end": 236, "type": "ADDRESS", "value": "45110"}, {"start": 237, "end": 258, "type": "CITY", "value": "Châteauneuf-sur-Loire"}, {"start": 264, "end": 273, "type": "SIREN", "value": "107706616"}, {"start": 284, "end": 308, "type": "PERSON", "value": "Bergeron, Lucien Léandre"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142286"}
|
| 7 |
+
{"id": "bodacc-A20260142300", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 300 du 29/07/2026. Greffe du Tribunal de Commerce de Châlon-en-Champagne. Immatriculation au RCS. Dénomination : T'OP MARKET. Forme : Société par actions simplifiée. Capital : 5000 EUR. Siège social : 5 allée des Roses, 51470 Saint-Memmie. RCS 105651772. Directeur général : Nazari, Mostafa.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 92, "type": "CITY", "value": "Châlon-en-Champagne"}, {"start": 133, "end": 144, "type": "COMPANY", "value": "T'OP MARKET"}, {"start": 196, "end": 204, "type": "AMOUNT", "value": "5000 EUR"}, {"start": 221, "end": 238, "type": "ADDRESS", "value": "5 allée des Roses"}, {"start": 240, "end": 245, "type": "ADDRESS", "value": "51470"}, {"start": 246, "end": 258, "type": "CITY", "value": "Saint-Memmie"}, {"start": 264, "end": 273, "type": "SIREN", "value": "105651772"}, {"start": 295, "end": 310, "type": "PERSON", "value": "Nazari, Mostafa"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142300"}
|
| 8 |
+
{"id": "bodacc-A20260142301", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 301 du 29/07/2026. Greffe du Tribunal de Commerce de Châlon-en-Champagne. Immatriculation au RCS. Dénomination : VBH2. Forme : Société civile immobilière. Capital : 1000 EUR. Siège social : 26 rue du Châtelet, 51000 Châlons-en-Champagne. RCS 107438459.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 92, "type": "CITY", "value": "Châlon-en-Champagne"}, {"start": 133, "end": 137, "type": "COMPANY", "value": "VBH2"}, {"start": 185, "end": 193, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 210, "end": 228, "type": "ADDRESS", "value": "26 rue du Châtelet"}, {"start": 230, "end": 235, "type": "ADDRESS", "value": "51000"}, {"start": 236, "end": 256, "type": "CITY", "value": "Châlons-en-Champagne"}, {"start": 262, "end": 271, "type": "SIREN", "value": "107438459"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142301"}
|
| 9 |
+
{"id": "bodacc-A20260142458", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 458 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : BASSU. Forme : Société civile immobilière. Capital : 100.00 EUR. Siège social : 91 Chemin de Petripaule, 64200 Bassussarry. RCS 107761330.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 126, "type": "COMPANY", "value": "BASSU"}, {"start": 174, "end": 184, "type": "AMOUNT", "value": "100.00 EUR"}, {"start": 201, "end": 224, "type": "ADDRESS", "value": "91 Chemin de Petripaule"}, {"start": 226, "end": 231, "type": "ADDRESS", "value": "64200"}, {"start": 232, "end": 243, "type": "CITY", "value": "Bassussarry"}, {"start": 249, "end": 258, "type": "SIREN", "value": "107761330"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142458"}
|
| 10 |
+
{"id": "bodacc-A20260142469", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 469 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : J.C. CARRELAGES. Forme : Société par actions simplifiée. Capital : 100.00 EUR. Siège social : 13 Allée des Mimosas, 64990 Saint-Pierre-d'Irube. RCS 107794117.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 136, "type": "COMPANY", "value": "J.C. CARRELAGES"}, {"start": 188, "end": 198, "type": "AMOUNT", "value": "100.00 EUR"}, {"start": 215, "end": 235, "type": "ADDRESS", "value": "13 Allée des Mimosas"}, {"start": 237, "end": 242, "type": "ADDRESS", "value": "64990"}, {"start": 243, "end": 263, "type": "CITY", "value": "Saint-Pierre-d'Irube"}, {"start": 269, "end": 278, "type": "SIREN", "value": "107794117"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142469"}
|
| 11 |
+
{"id": "bodacc-A20260142473", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 473 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : La Circoncellionne CK. Forme : Société par actions simplifiée. Capital : 50.00 EUR. Siège social : 6 Rue Lisboa, 64200 Biarritz. RCS 107898579. Président : KAMTCHUENG Modjo, Carine.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 142, "type": "COMPANY", "value": "La Circoncellionne CK"}, {"start": 194, "end": 203, "type": "AMOUNT", "value": "50.00 EUR"}, {"start": 220, "end": 232, "type": "ADDRESS", "value": "6 Rue Lisboa"}, {"start": 234, "end": 239, "type": "ADDRESS", "value": "64200"}, {"start": 240, "end": 248, "type": "CITY", "value": "Biarritz"}, {"start": 254, "end": 263, "type": "SIREN", "value": "107898579"}, {"start": 277, "end": 301, "type": "PERSON", "value": "KAMTCHUENG Modjo, Carine"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142473"}
|
| 12 |
+
{"id": "bodacc-A20260142479", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 479 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : PT PONSOMBY. Forme : Société civile immobilière. Capital : 1000.00 EUR. Siège social : 68 Avenue d'Anglet, 64200 Biarritz. RCS 107684219.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 132, "type": "COMPANY", "value": "PT PONSOMBY"}, {"start": 180, "end": 191, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 208, "end": 226, "type": "ADDRESS", "value": "68 Avenue d'Anglet"}, {"start": 228, "end": 233, "type": "ADDRESS", "value": "64200"}, {"start": 234, "end": 242, "type": "CITY", "value": "Biarritz"}, {"start": 248, "end": 257, "type": "SIREN", "value": "107684219"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142479"}
|
| 13 |
+
{"id": "bodacc-A20260142543", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 543 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Lyon. Immatriculation au RCS. Dénomination : FORKO NUCLEAIRE. Forme : Société par Actions Simplifiée. Capital : 40000.00 EUR. Siège social : 55 Avenue René Cassin, 69009 Lyon. RCS 107980856.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 91, "type": "CITY", "value": "Lyon"}, {"start": 132, "end": 147, "type": "COMPANY", "value": "FORKO NUCLEAIRE"}, {"start": 199, "end": 211, "type": "AMOUNT", "value": "40000.00 EUR"}, {"start": 228, "end": 249, "type": "ADDRESS", "value": "55 Avenue René Cassin"}, {"start": 251, "end": 256, "type": "ADDRESS", "value": "69009"}, {"start": 257, "end": 261, "type": "CITY", "value": "Lyon"}, {"start": 267, "end": 276, "type": "SIREN", "value": "107980856"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142543"}
|
| 14 |
+
{"id": "bodacc-A20260142553", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 553 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Lyon. Immatriculation au RCS. Dénomination : MON TERROIR TRAITEUR. Forme : Société par Actions Simplifiée. Capital : 2000.00 EUR. Siège social : 16 Ter Rue Neuve, 69330 Jonage. RCS 107982258.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 91, "type": "CITY", "value": "Lyon"}, {"start": 132, "end": 152, "type": "COMPANY", "value": "MON TERROIR TRAITEUR"}, {"start": 204, "end": 215, "type": "AMOUNT", "value": "2000.00 EUR"}, {"start": 232, "end": 248, "type": "ADDRESS", "value": "16 Ter Rue Neuve"}, {"start": 250, "end": 255, "type": "ADDRESS", "value": "69330"}, {"start": 256, "end": 262, "type": "CITY", "value": "Jonage"}, {"start": 268, "end": 277, "type": "SIREN", "value": "107982258"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142553"}
|
| 15 |
+
{"id": "bodacc-A20260142612", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 612 du 29/07/2026. Greffe du Tribunal de Commerce de Villefranche-Tarare. Immatriculation au RCS. Dénomination : LBG2 HOLDING. Forme : Société par Actions Simplifiée. Capital : 1067538.00 EUR. Siège social : 251 Impasse Du Pré Rond, 69490 Saint-Romain-de-Popey. RCS 107947566.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 92, "type": "CITY", "value": "Villefranche-Tarare"}, {"start": 133, "end": 145, "type": "COMPANY", "value": "LBG2 HOLDING"}, {"start": 197, "end": 211, "type": "AMOUNT", "value": "1067538.00 EUR"}, {"start": 228, "end": 251, "type": "ADDRESS", "value": "251 Impasse Du Pré Rond"}, {"start": 253, "end": 258, "type": "ADDRESS", "value": "69490"}, {"start": 259, "end": 280, "type": "CITY", "value": "Saint-Romain-de-Popey"}, {"start": 286, "end": 295, "type": "SIREN", "value": "107947566"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142612"}
|
| 16 |
+
{"id": "bodacc-A20260142666", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 666 du 29/07/2026. Greffe du Tribunal de Commerce d'Annecy. Immatriculation au RCS. Dénomination : ARCALFIA LYON. Forme : Société par Actions Simplifiée. Capital : 1000.00 EUR. Siège social : 20 Chemin Des Poses, 74330 Poisy. RCS 107422685.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 78, "type": "CITY", "value": "Annecy"}, {"start": 119, "end": 132, "type": "COMPANY", "value": "ARCALFIA LYON"}, {"start": 184, "end": 195, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 212, "end": 231, "type": "ADDRESS", "value": "20 Chemin Des Poses"}, {"start": 233, "end": 238, "type": "ADDRESS", "value": "74330"}, {"start": 239, "end": 244, "type": "CITY", "value": "Poisy"}, {"start": 250, "end": 259, "type": "SIREN", "value": "107422685"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142666"}
|
| 17 |
+
{"id": "bodacc-A20260142667", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 667 du 29/07/2026. Greffe du Tribunal de Commerce d'Annecy. Immatriculation au RCS. Dénomination : ATELIER MAGNIFICAT. Forme : Société par Actions Simplifiée. Capital : 10000.00 EUR. Siège social : 11 Avenue De la Visitation, 74000 Annecy. RCS 107407686.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 78, "type": "CITY", "value": "Annecy"}, {"start": 119, "end": 137, "type": "COMPANY", "value": "ATELIER MAGNIFICAT"}, {"start": 189, "end": 201, "type": "AMOUNT", "value": "10000.00 EUR"}, {"start": 218, "end": 244, "type": "ADDRESS", "value": "11 Avenue De la Visitation"}, {"start": 246, "end": 251, "type": "ADDRESS", "value": "74000"}, {"start": 252, "end": 258, "type": "CITY", "value": "Annecy"}, {"start": 264, "end": 273, "type": "SIREN", "value": "107407686"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142667"}
|
| 18 |
+
{"id": "bodacc-A20260142674", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 674 du 29/07/2026. Greffe du Tribunal de Commerce d'Annecy. Immatriculation au RCS. Dénomination : BYRON. Forme : Société Civile. Capital : 2000.00 EUR. Siège social : 41 Rue Charles Feige, 74120 Megève. RCS 107403560.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 78, "type": "CITY", "value": "Annecy"}, {"start": 119, "end": 124, "type": "COMPANY", "value": "BYRON"}, {"start": 160, "end": 171, "type": "AMOUNT", "value": "2000.00 EUR"}, {"start": 188, "end": 208, "type": "ADDRESS", "value": "41 Rue Charles Feige"}, {"start": 210, "end": 215, "type": "ADDRESS", "value": "74120"}, {"start": 216, "end": 222, "type": "CITY", "value": "Megève"}, {"start": 228, "end": 237, "type": "SIREN", "value": "107403560"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142674"}
|
| 19 |
+
{"id": "bodacc-A20260142809", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 809 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : ADÉ CAPITAL. Forme : Société par actions simplifiée. Capital : 3000 EUR. Siège social : 66 avenue des Champs-Élysées, 75008 Paris. RCS 107572828. Président : Adelaide, Hortense Marie Grace.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 144, "type": "COMPANY", "value": "ADÉ CAPITAL"}, {"start": 196, "end": 204, "type": "AMOUNT", "value": "3000 EUR"}, {"start": 221, "end": 249, "type": "ADDRESS", "value": "66 avenue des Champs-Élysées"}, {"start": 251, "end": 256, "type": "ADDRESS", "value": "75008"}, {"start": 257, "end": 262, "type": "CITY", "value": "Paris"}, {"start": 268, "end": 277, "type": "SIREN", "value": "107572828"}, {"start": 291, "end": 321, "type": "PERSON", "value": "Adelaide, Hortense Marie Grace"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142809"}
|
| 20 |
+
{"id": "bodacc-A20260142819", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 819 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : Braun Devoti. Forme : Société civile immobilière. Capital : 100 EUR. Siège social : 1 rue d'Arsonval, 75015 Paris. RCS 107694622.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 145, "type": "COMPANY", "value": "Braun Devoti"}, {"start": 193, "end": 200, "type": "AMOUNT", "value": "100 EUR"}, {"start": 217, "end": 233, "type": "ADDRESS", "value": "1 rue d'Arsonval"}, {"start": 235, "end": 240, "type": "ADDRESS", "value": "75015"}, {"start": 241, "end": 246, "type": "CITY", "value": "Paris"}, {"start": 252, "end": 261, "type": "SIREN", "value": "107694622"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142819"}
|
| 21 |
+
{"id": "bodacc-A20260142836", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 836 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : EURL JULIEN MALENGO. Forme : Société à responsabilité limitée (à associé unique). Capital : 100 EUR. Siège social : 47 rue Vivienne, 75002 Paris. RCS 107722506. Gérant : Malengo, Julien Joel.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 152, "type": "COMPANY", "value": "EURL JULIEN MALENGO"}, {"start": 225, "end": 232, "type": "AMOUNT", "value": "100 EUR"}, {"start": 249, "end": 264, "type": "ADDRESS", "value": "47 rue Vivienne"}, {"start": 266, "end": 271, "type": "ADDRESS", "value": "75002"}, {"start": 272, "end": 277, "type": "CITY", "value": "Paris"}, {"start": 283, "end": 292, "type": "SIREN", "value": "107722506"}, {"start": 303, "end": 323, "type": "PERSON", "value": "Malengo, Julien Joel"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142836"}
|
| 22 |
+
{"id": "bodacc-A20260142841", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 841 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : HEYLIA. Forme : Société par actions simplifiée (à associé unique). Capital : 10000 EUR. Siège social : 5 rue Saint-Victor, 75005 Paris. RCS 107629263.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 139, "type": "COMPANY", "value": "HEYLIA"}, {"start": 210, "end": 219, "type": "AMOUNT", "value": "10000 EUR"}, {"start": 236, "end": 254, "type": "ADDRESS", "value": "5 rue Saint-Victor"}, {"start": 256, "end": 261, "type": "ADDRESS", "value": "75005"}, {"start": 262, "end": 267, "type": "CITY", "value": "Paris"}, {"start": 273, "end": 282, "type": "SIREN", "value": "107629263"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142841"}
|
| 23 |
+
{"id": "bodacc-A20260142843", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 843 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : HUBET. Forme : Société par actions simplifiée. Capital : 100 EUR. Siège social : 39 avenue Rapp, 75007 Paris. RCS 107702763. Président : Le Bourhis, Hubert.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 138, "type": "COMPANY", "value": "HUBET"}, {"start": 190, "end": 197, "type": "AMOUNT", "value": "100 EUR"}, {"start": 214, "end": 228, "type": "ADDRESS", "value": "39 avenue Rapp"}, {"start": 230, "end": 235, "type": "ADDRESS", "value": "75007"}, {"start": 236, "end": 241, "type": "CITY", "value": "Paris"}, {"start": 247, "end": 256, "type": "SIREN", "value": "107702763"}, {"start": 270, "end": 288, "type": "PERSON", "value": "Le Bourhis, Hubert"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142843"}
|
| 24 |
+
{"id": "bodacc-A20260142880", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 880 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : SC Gatoux-Aouad. Forme : Société civile immobilière. Capital : 500200 EUR. Siège social : 16 rue de la Folie-Regnault, 75011 Paris. RCS 107663957.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 148, "type": "COMPANY", "value": "SC Gatoux-Aouad"}, {"start": 196, "end": 206, "type": "AMOUNT", "value": "500200 EUR"}, {"start": 223, "end": 250, "type": "ADDRESS", "value": "16 rue de la Folie-Regnault"}, {"start": 252, "end": 257, "type": "ADDRESS", "value": "75011"}, {"start": 258, "end": 263, "type": "CITY", "value": "Paris"}, {"start": 269, "end": 278, "type": "SIREN", "value": "107663957"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142880"}
|
| 25 |
+
{"id": "bodacc-A20260142896", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 896 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : Sparktacus. Forme : Société par actions simplifiée. Capital : 100 EUR. Siège social : 47 rue Vivienne, 75002 Paris. RCS 107704942. Président : Toussaint, Rodolphe Mario.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 143, "type": "COMPANY", "value": "Sparktacus"}, {"start": 195, "end": 202, "type": "AMOUNT", "value": "100 EUR"}, {"start": 219, "end": 234, "type": "ADDRESS", "value": "47 rue Vivienne"}, {"start": 236, "end": 241, "type": "ADDRESS", "value": "75002"}, {"start": 242, "end": 247, "type": "CITY", "value": "Paris"}, {"start": 253, "end": 262, "type": "SIREN", "value": "107704942"}, {"start": 276, "end": 301, "type": "PERSON", "value": "Toussaint, Rodolphe Mario"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142896"}
|
| 26 |
+
{"id": "bodacc-A20260142900", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 900 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : Talys location. Forme : Société par actions simplifiée. Capital : 3 EUR. Siège social : 47 rue Vivienne, 75002 Paris. RCS 107697963. Président : Edwards, Keyran David.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 147, "type": "COMPANY", "value": "Talys location"}, {"start": 199, "end": 204, "type": "AMOUNT", "value": "3 EUR"}, {"start": 221, "end": 236, "type": "ADDRESS", "value": "47 rue Vivienne"}, {"start": 238, "end": 243, "type": "ADDRESS", "value": "75002"}, {"start": 244, "end": 249, "type": "CITY", "value": "Paris"}, {"start": 255, "end": 264, "type": "SIREN", "value": "107697963"}, {"start": 278, "end": 299, "type": "PERSON", "value": "Edwards, Keyran David"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142900"}
|
| 27 |
+
{"id": "bodacc-A202601421114", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1114 du 29/07/2026. Greffe du Tribunal de Commerce de la Roche-sur-Yon. Immatriculation au RCS. Dénomination : SCI SGIMMO. Forme : Société civile immobilière. Capital : 100 EUR. Siège social : 4 rue des vallées, 85710 Bois-de-Céné. RCS 107093486.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 74, "end": 90, "type": "CITY", "value": "la Roche-sur-Yon"}, {"start": 131, "end": 141, "type": "COMPANY", "value": "SCI SGIMMO"}, {"start": 189, "end": 196, "type": "AMOUNT", "value": "100 EUR"}, {"start": 213, "end": 230, "type": "ADDRESS", "value": "4 rue des vallées"}, {"start": 232, "end": 237, "type": "ADDRESS", "value": "85710"}, {"start": 238, "end": 250, "type": "CITY", "value": "Bois-de-Céné"}, {"start": 256, "end": 265, "type": "SIREN", "value": "107093486"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421114"}
|
| 28 |
+
{"id": "bodacc-A202601421068", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1068 du 29/07/2026. Greffe du Tribunal de Commerce d'Amiens. Immatriculation au RCS. Dénomination : AMIREST657. Forme : Société par Actions Simplifiée. Capital : 2000.00 EUR. Siège social : 4 Rue Rose Bertin, 80100 Abbeville. RCS 107941437.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 79, "type": "CITY", "value": "Amiens"}, {"start": 120, "end": 130, "type": "COMPANY", "value": "AMIREST657"}, {"start": 182, "end": 193, "type": "AMOUNT", "value": "2000.00 EUR"}, {"start": 210, "end": 227, "type": "ADDRESS", "value": "4 Rue Rose Bertin"}, {"start": 229, "end": 234, "type": "ADDRESS", "value": "80100"}, {"start": 235, "end": 244, "type": "CITY", "value": "Abbeville"}, {"start": 250, "end": 259, "type": "SIREN", "value": "107941437"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421068"}
|
| 29 |
+
{"id": "bodacc-A202601421076", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1076 du 29/07/2026. Greffe du Tribunal de Commerce d'Amiens. Immatriculation au RCS. Dénomination : MBAR AUDITION. Forme : Société par Actions Simplifiée. Capital : 10000.00 EUR. Siège social : 12 Rue Paul Gamant, 80200 Doingt. RCS 107972069.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 79, "type": "CITY", "value": "Amiens"}, {"start": 120, "end": 133, "type": "COMPANY", "value": "MBAR AUDITION"}, {"start": 185, "end": 197, "type": "AMOUNT", "value": "10000.00 EUR"}, {"start": 214, "end": 232, "type": "ADDRESS", "value": "12 Rue Paul Gamant"}, {"start": 234, "end": 239, "type": "ADDRESS", "value": "80200"}, {"start": 240, "end": 246, "type": "CITY", "value": "Doingt"}, {"start": 252, "end": 261, "type": "SIREN", "value": "107972069"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421076"}
|
| 30 |
+
{"id": "bodacc-A202601421226", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1226 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Pointe-à-Pitre. Immatriculation au RCS. Dénomination : FLEURS DE SOFAIA. Forme : Société Civile Immobilière. Capital : 1000.00 EUR. Siège social : Pont Canal, 97115 Sainte-Rose. RCS 107518557.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 94, "type": "CITY", "value": "Pointe-à-Pitre"}, {"start": 135, "end": 151, "type": "COMPANY", "value": "FLEURS DE SOFAIA"}, {"start": 199, "end": 210, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 227, "end": 237, "type": "ADDRESS", "value": "Pont Canal"}, {"start": 239, "end": 244, "type": "ADDRESS", "value": "97115"}, {"start": 245, "end": 256, "type": "CITY", "value": "Sainte-Rose"}, {"start": 262, "end": 271, "type": "SIREN", "value": "107518557"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421226"}
|
| 31 |
+
{"id": "bodacc-A202601421252", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1252 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Pointe-à-Pitre. Immatriculation au RCS. Dénomination : SNC INVEST-GP 4. Forme : Société en Nom Collectif. Capital : 153.00 EUR. Siège social : 405 Fonds Boisneuf ZAC de Houelbourg III ZI Jarry, 97122 Baie-Mahault. RCS 107673410.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 94, "type": "CITY", "value": "Pointe-à-Pitre"}, {"start": 135, "end": 150, "type": "COMPANY", "value": "SNC INVEST-GP 4"}, {"start": 196, "end": 206, "type": "AMOUNT", "value": "153.00 EUR"}, {"start": 223, "end": 272, "type": "ADDRESS", "value": "405 Fonds Boisneuf ZAC de Houelbourg III ZI Jarry"}, {"start": 274, "end": 279, "type": "ADDRESS", "value": "97122"}, {"start": 280, "end": 292, "type": "CITY", "value": "Baie-Mahault"}, {"start": 298, "end": 307, "type": "SIREN", "value": "107673410"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421252"}
|
| 32 |
+
{"id": "bodacc-A202601421266", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1266 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Pointe-à-Pitre. Immatriculation au RCS. Dénomination : VK DEVELOPPEMENT. Forme : Société par Actions Simplifiée. Capital : 1008.00 EUR. Siège social : 218 App Toumalacaï, 97112 Grand-Bourg. RCS 107397119.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 94, "type": "CITY", "value": "Pointe-à-Pitre"}, {"start": 135, "end": 151, "type": "COMPANY", "value": "VK DEVELOPPEMENT"}, {"start": 203, "end": 214, "type": "AMOUNT", "value": "1008.00 EUR"}, {"start": 231, "end": 249, "type": "ADDRESS", "value": "218 App Toumalacaï"}, {"start": 251, "end": 256, "type": "ADDRESS", "value": "97112"}, {"start": 257, "end": 268, "type": "CITY", "value": "Grand-Bourg"}, {"start": 274, "end": 283, "type": "SIREN", "value": "107397119"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421266"}
|
| 33 |
+
{"id": "bodacc-A20260142102", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 102 du 29/07/2026. Greffe du Tribunal de Commerce de Tours. Immatriculation au RCS. Dénomination : KAPITAL. Forme : Société civile. Capital : 100 EUR. Siège social : 7 rue de la Feuille dOr, 37270 Azay-sur-Cher. RCS 107656050.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 78, "type": "CITY", "value": "Tours"}, {"start": 119, "end": 126, "type": "COMPANY", "value": "KAPITAL"}, {"start": 162, "end": 169, "type": "AMOUNT", "value": "100 EUR"}, {"start": 186, "end": 209, "type": "ADDRESS", "value": "7 rue de la Feuille dOr"}, {"start": 211, "end": 216, "type": "ADDRESS", "value": "37270"}, {"start": 217, "end": 230, "type": "CITY", "value": "Azay-sur-Cher"}, {"start": 236, "end": 245, "type": "SIREN", "value": "107656050"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142102"}
|
| 34 |
+
{"id": "bodacc-A20260142240", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 240 du 29/07/2026. Greffe du Tribunal de Commerce de Nantes. Immatriculation au RCS. Dénomination : ALYC. Forme : Société civile immobilière. Capital : 1000 EUR. Siège social : 13 rue de la Baudinière, 44470 Thouaré-sur-Loire. RCS 107716532.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 79, "type": "CITY", "value": "Nantes"}, {"start": 120, "end": 124, "type": "COMPANY", "value": "ALYC"}, {"start": 172, "end": 180, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 197, "end": 220, "type": "ADDRESS", "value": "13 rue de la Baudinière"}, {"start": 222, "end": 227, "type": "ADDRESS", "value": "44470"}, {"start": 228, "end": 245, "type": "CITY", "value": "Thouaré-sur-Loire"}, {"start": 251, "end": 260, "type": "SIREN", "value": "107716532"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142240"}
|
| 35 |
+
{"id": "bodacc-A20260142262", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 262 du 29/07/2026. Greffe du Tribunal de Commerce de St-Nazaire. Immatriculation au RCS. Dénomination : SCCV JEAN BROCHARD. Forme : Société civile de construction vente. Capital : 1000 EUR. Siège social : rue de Nantes, 44320 Saint-Père-en-Retz. RCS 107637720.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 83, "type": "CITY", "value": "St-Nazaire"}, {"start": 124, "end": 142, "type": "COMPANY", "value": "SCCV JEAN BROCHARD"}, {"start": 200, "end": 208, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 225, "end": 238, "type": "ADDRESS", "value": "rue de Nantes"}, {"start": 240, "end": 245, "type": "ADDRESS", "value": "44320"}, {"start": 246, "end": 264, "type": "CITY", "value": "Saint-Père-en-Retz"}, {"start": 270, "end": 279, "type": "SIREN", "value": "107637720"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142262"}
|
| 36 |
+
{"id": "bodacc-A20260142289", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 289 du 29/07/2026. Greffe du Tribunal de Commerce d'Orléans. Immatriculation au RCS. Dénomination : Maia & Coulon. Forme : Société à responsabilité limitée. Capital : 1000 EUR. Siège social : 12 rue de Chailleuse, 45150 Férolles. RCS 107462996. Gérant : Pereira Da Silva Maia Carvalho, Antonio Manuel.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 79, "type": "CITY", "value": "Orléans"}, {"start": 120, "end": 133, "type": "COMPANY", "value": "Maia & Coulon"}, {"start": 187, "end": 195, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 212, "end": 232, "type": "ADDRESS", "value": "12 rue de Chailleuse"}, {"start": 234, "end": 239, "type": "ADDRESS", "value": "45150"}, {"start": 240, "end": 248, "type": "CITY", "value": "Férolles"}, {"start": 254, "end": 263, "type": "SIREN", "value": "107462996"}, {"start": 274, "end": 320, "type": "PERSON", "value": "Pereira Da Silva Maia Carvalho, Antonio Manuel"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142289"}
|
| 37 |
+
{"id": "bodacc-A20260142337", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 337 du 29/07/2026. Greffe du Tribunal de Commerce de Valenciennes. Immatriculation au RCS. Dénomination : MIKAKU. Forme : Société par actions simplifiée. Capital : 3000 EUR. Siège social : 402 avenue Jean Jaurès, 59174 La Sentinelle. RCS 107209272.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 85, "type": "CITY", "value": "Valenciennes"}, {"start": 126, "end": 132, "type": "COMPANY", "value": "MIKAKU"}, {"start": 184, "end": 192, "type": "AMOUNT", "value": "3000 EUR"}, {"start": 209, "end": 231, "type": "ADDRESS", "value": "402 avenue Jean Jaurès"}, {"start": 233, "end": 238, "type": "ADDRESS", "value": "59174"}, {"start": 239, "end": 252, "type": "CITY", "value": "La Sentinelle"}, {"start": 258, "end": 267, "type": "SIREN", "value": "107209272"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142337"}
|
| 38 |
+
{"id": "bodacc-A20260142464", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 464 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : FMG. Forme : Société par actions simplifiée. Capital : 1059407.00 EUR. Siège social : lieu-dit Souhara, 64122 Urrugne. RCS 107654857. Président : GRAVAUD Patrick, Jean-Jacques.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 124, "type": "COMPANY", "value": "FMG"}, {"start": 176, "end": 190, "type": "AMOUNT", "value": "1059407.00 EUR"}, {"start": 207, "end": 223, "type": "ADDRESS", "value": "lieu-dit Souhara"}, {"start": 225, "end": 230, "type": "ADDRESS", "value": "64122"}, {"start": 231, "end": 238, "type": "CITY", "value": "Urrugne"}, {"start": 244, "end": 253, "type": "SIREN", "value": "107654857"}, {"start": 267, "end": 296, "type": "PERSON", "value": "GRAVAUD Patrick, Jean-Jacques"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142464"}
|
| 39 |
+
{"id": "bodacc-A20260142607", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 607 du 29/07/2026. Greffe du Tribunal de Commerce de Villefranche-Tarare. Immatriculation au RCS. Dénomination : HMLDSJ. Forme : Société Civile Immobilière. Capital : 120000.00 EUR. Siège social : 70 Allée Du Coteau d'Anse, 69480 Anse. RCS 107798332.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 92, "type": "CITY", "value": "Villefranche-Tarare"}, {"start": 133, "end": 139, "type": "COMPANY", "value": "HMLDSJ"}, {"start": 187, "end": 200, "type": "AMOUNT", "value": "120000.00 EUR"}, {"start": 217, "end": 242, "type": "ADDRESS", "value": "70 Allée Du Coteau d'Anse"}, {"start": 244, "end": 249, "type": "ADDRESS", "value": "69480"}, {"start": 250, "end": 254, "type": "CITY", "value": "Anse"}, {"start": 260, "end": 269, "type": "SIREN", "value": "107798332"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142607"}
|
| 40 |
+
{"id": "bodacc-A20260142700", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 700 du 29/07/2026. Greffe du Tribunal de Commerce d'Annecy. Immatriculation au RCS. Dénomination : SCI DE L'ALPAGE. Forme : Société Civile Immobilière. Capital : 1000.00 EUR. Siège social : Chemin De la Tournette, 74290 Talloires-Montmin. RCS 107478232.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 78, "type": "CITY", "value": "Annecy"}, {"start": 119, "end": 134, "type": "COMPANY", "value": "SCI DE L'ALPAGE"}, {"start": 182, "end": 193, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 210, "end": 232, "type": "ADDRESS", "value": "Chemin De la Tournette"}, {"start": 234, "end": 239, "type": "ADDRESS", "value": "74290"}, {"start": 240, "end": 257, "type": "CITY", "value": "Talloires-Montmin"}, {"start": 263, "end": 272, "type": "SIREN", "value": "107478232"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142700"}
|
| 41 |
+
{"id": "bodacc-A20260142705", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 705 du 29/07/2026. Greffe du Tribunal de Commerce d'Annecy. Immatriculation au RCS. Dénomination : VICTHOM IMMO. Forme : Société Civile Immobilière. Capital : 2000.00 EUR. Siège social : 78 Rue Du Clos Fleuri, 74170 Saint-Gervais-les-Bains. RCS 107425696.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 78, "type": "CITY", "value": "Annecy"}, {"start": 119, "end": 131, "type": "COMPANY", "value": "VICTHOM IMMO"}, {"start": 179, "end": 190, "type": "AMOUNT", "value": "2000.00 EUR"}, {"start": 207, "end": 228, "type": "ADDRESS", "value": "78 Rue Du Clos Fleuri"}, {"start": 230, "end": 235, "type": "ADDRESS", "value": "74170"}, {"start": 236, "end": 259, "type": "CITY", "value": "Saint-Gervais-les-Bains"}, {"start": 265, "end": 274, "type": "SIREN", "value": "107425696"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142705"}
|
| 42 |
+
{"id": "bodacc-A20260142846", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 846 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : IMMOSURE PAYS BASQUE. Forme : Société par actions simplifiée. Capital : 500 EUR. Siège social : 47 rue Vivienne, 75002 Paris. RCS 107699803. Président : Belhumeur, Jean-Claude Désiré.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 153, "type": "COMPANY", "value": "IMMOSURE PAYS BASQUE"}, {"start": 205, "end": 212, "type": "AMOUNT", "value": "500 EUR"}, {"start": 229, "end": 244, "type": "ADDRESS", "value": "47 rue Vivienne"}, {"start": 246, "end": 251, "type": "ADDRESS", "value": "75002"}, {"start": 252, "end": 257, "type": "CITY", "value": "Paris"}, {"start": 263, "end": 272, "type": "SIREN", "value": "107699803"}, {"start": 286, "end": 315, "type": "PERSON", "value": "Belhumeur, Jean-Claude Désiré"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142846"}
|
| 43 |
+
{"id": "bodacc-A20260142848", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 848 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : J & T Immobilier. Forme : Société civile immobilière. Capital : 1000 EUR. Siège social : 54 bis rue Michel-Ange, 75016 Paris. RCS 107674780.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 149, "type": "COMPANY", "value": "J & T Immobilier"}, {"start": 197, "end": 205, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 222, "end": 244, "type": "ADDRESS", "value": "54 bis rue Michel-Ange"}, {"start": 246, "end": 251, "type": "ADDRESS", "value": "75016"}, {"start": 252, "end": 257, "type": "CITY", "value": "Paris"}, {"start": 263, "end": 272, "type": "SIREN", "value": "107674780"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142848"}
|
| 44 |
+
{"id": "bodacc-A20260142855", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 855 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : LES BELLES FLEURS. Forme : Société à responsabilité limitée. Capital : 6000 EUR. Siège social : 12 rue Parrot, 75012 Paris. RCS 107525446.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 150, "type": "COMPANY", "value": "LES BELLES FLEURS"}, {"start": 204, "end": 212, "type": "AMOUNT", "value": "6000 EUR"}, {"start": 229, "end": 242, "type": "ADDRESS", "value": "12 rue Parrot"}, {"start": 244, "end": 249, "type": "ADDRESS", "value": "75012"}, {"start": 250, "end": 255, "type": "CITY", "value": "Paris"}, {"start": 261, "end": 270, "type": "SIREN", "value": "107525446"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142855"}
|
| 45 |
+
{"id": "bodacc-A20260142878", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 878 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : RoomPage. Forme : Société par actions simplifiée. Capital : 1000 EUR. Siège social : 47 rue Vivienne, 75002 Paris. RCS 107701856. Directeur général : Bayeul, Sylvain Olivier.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 141, "type": "COMPANY", "value": "RoomPage"}, {"start": 193, "end": 201, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 218, "end": 233, "type": "ADDRESS", "value": "47 rue Vivienne"}, {"start": 235, "end": 240, "type": "ADDRESS", "value": "75002"}, {"start": 241, "end": 246, "type": "CITY", "value": "Paris"}, {"start": 252, "end": 261, "type": "SIREN", "value": "107701856"}, {"start": 283, "end": 306, "type": "PERSON", "value": "Bayeul, Sylvain Olivier"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142878"}
|
| 46 |
+
{"id": "bodacc-A20260142879", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 879 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : SAER GLOBAL SERVICES. Forme : Société par actions simplifiée. Capital : 10000 EUR. Siège social : 6 rue d'Armaillé, 75017 Paris. RCS 107423642. Président : Konate Traore, Aissatou.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 153, "type": "COMPANY", "value": "SAER GLOBAL SERVICES"}, {"start": 205, "end": 214, "type": "AMOUNT", "value": "10000 EUR"}, {"start": 231, "end": 247, "type": "ADDRESS", "value": "6 rue d'Armaillé"}, {"start": 249, "end": 254, "type": "ADDRESS", "value": "75017"}, {"start": 255, "end": 260, "type": "CITY", "value": "Paris"}, {"start": 266, "end": 275, "type": "SIREN", "value": "107423642"}, {"start": 289, "end": 312, "type": "PERSON", "value": "Konate Traore, Aissatou"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142879"}
|
| 47 |
+
{"id": "bodacc-A20260142906", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 906 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Paris. Immatriculation au RCS. Dénomination : Wumbo. Forme : Société par actions simplifiée. Capital : 1000 EUR. Siège social : 173 rue de Courcelles, 75017 Paris. RCS 107718124. Directeur général : Sam, Kompheak.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 92, "type": "CITY", "value": "Paris"}, {"start": 133, "end": 138, "type": "COMPANY", "value": "Wumbo"}, {"start": 190, "end": 198, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 215, "end": 236, "type": "ADDRESS", "value": "173 rue de Courcelles"}, {"start": 238, "end": 243, "type": "ADDRESS", "value": "75017"}, {"start": 244, "end": 249, "type": "CITY", "value": "Paris"}, {"start": 255, "end": 264, "type": "SIREN", "value": "107718124"}, {"start": 286, "end": 299, "type": "PERSON", "value": "Sam, Kompheak"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142906"}
|
| 48 |
+
{"id": "bodacc-A202601421157", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1157 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Basse-Terre. Immatriculation au RCS. Dénomination : GROUPE 222. Forme : Société par Actions Simplifiée. Capital : 500.00 EUR. Siège social : 5000 Chemin Du Château Do, 97126 Deshaies. RCS 107681991.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 91, "type": "CITY", "value": "Basse-Terre"}, {"start": 132, "end": 142, "type": "COMPANY", "value": "GROUPE 222"}, {"start": 194, "end": 204, "type": "AMOUNT", "value": "500.00 EUR"}, {"start": 221, "end": 246, "type": "ADDRESS", "value": "5000 Chemin Du Château Do"}, {"start": 248, "end": 253, "type": "ADDRESS", "value": "97126"}, {"start": 254, "end": 262, "type": "CITY", "value": "Deshaies"}, {"start": 268, "end": 277, "type": "SIREN", "value": "107681991"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421157"}
|
| 49 |
+
{"id": "bodacc-A202601421171", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1171 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Basse-Terre. Immatriculation au RCS. Dénomination : SAS GEORGIA. Forme : Société par Actions Simplifiée. Capital : 10000.00 EUR. Siège social : 74 Rue De Low Town, 97150 Saint-Martin. RCS 107800146.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 91, "type": "CITY", "value": "Basse-Terre"}, {"start": 132, "end": 143, "type": "COMPANY", "value": "SAS GEORGIA"}, {"start": 195, "end": 207, "type": "AMOUNT", "value": "10000.00 EUR"}, {"start": 224, "end": 242, "type": "ADDRESS", "value": "74 Rue De Low Town"}, {"start": 244, "end": 249, "type": "ADDRESS", "value": "97150"}, {"start": 250, "end": 262, "type": "CITY", "value": "Saint-Martin"}, {"start": 268, "end": 277, "type": "SIREN", "value": "107800146"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421171"}
|
| 50 |
+
{"id": "bodacc-A202601421172", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1172 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Basse-Terre. Immatriculation au RCS. Dénomination : SCI MAJESTIA. Forme : Société Civile Immobilière. Capital : 400.00 EUR. Siège social : 175 Allee Dumanoir, 97130 Capesterre-Belle-Eau. RCS 107746026.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 91, "type": "CITY", "value": "Basse-Terre"}, {"start": 132, "end": 144, "type": "COMPANY", "value": "SCI MAJESTIA"}, {"start": 192, "end": 202, "type": "AMOUNT", "value": "400.00 EUR"}, {"start": 219, "end": 237, "type": "ADDRESS", "value": "175 Allee Dumanoir"}, {"start": 239, "end": 244, "type": "ADDRESS", "value": "97130"}, {"start": 245, "end": 265, "type": "CITY", "value": "Capesterre-Belle-Eau"}, {"start": 271, "end": 280, "type": "SIREN", "value": "107746026"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421172"}
|
| 51 |
+
{"id": "bodacc-A202601421223", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1223 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Pointe-à-Pitre. Immatriculation au RCS. Dénomination : EK Conseil. Forme : Société par Actions Simplifiée. Capital : 1000.00 EUR. Siège social : Z.A.C. Houelbourg, 97122 Baie-Mahault. RCS 107810186.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 94, "type": "CITY", "value": "Pointe-à-Pitre"}, {"start": 135, "end": 145, "type": "COMPANY", "value": "EK Conseil"}, {"start": 197, "end": 208, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 225, "end": 242, "type": "ADDRESS", "value": "Z.A.C. Houelbourg"}, {"start": 244, "end": 249, "type": "ADDRESS", "value": "97122"}, {"start": 250, "end": 262, "type": "CITY", "value": "Baie-Mahault"}, {"start": 268, "end": 277, "type": "SIREN", "value": "107810186"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421223"}
|
| 52 |
+
{"id": "bodacc-A202601421228", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 1228 du 29/07/2026. Greffe du Tribunal Mixte de Commerce de Pointe-à-Pitre. Immatriculation au RCS. Dénomination : GLS REMORQUAGE. Forme : Société par Actions Simplifiée. Capital : 1000.00 EUR. Siège social : Méthivier, 97160 Le Moule. RCS 107800963.", "entities": [{"start": 28, "end": 38, "type": "DATE", "value": "29/07/2026"}, {"start": 80, "end": 94, "type": "CITY", "value": "Pointe-à-Pitre"}, {"start": 135, "end": 149, "type": "COMPANY", "value": "GLS REMORQUAGE"}, {"start": 201, "end": 212, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 229, "end": 238, "type": "ADDRESS", "value": "Méthivier"}, {"start": 240, "end": 245, "type": "ADDRESS", "value": "97160"}, {"start": 246, "end": 254, "type": "CITY", "value": "Le Moule"}, {"start": 260, "end": 269, "type": "SIREN", "value": "107800963"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A202601421228"}
|
| 53 |
+
{"id": "bodacc-A20260142288", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 288 du 29/07/2026. Greffe du Tribunal de Commerce d'Orléans. Immatriculation au RCS. Dénomination : MONOLYT CAPITAL. Forme : Société par actions simplifiée. Capital : 1000 EUR. Siège social : 41 rue du Martineau, 45320 Courtenay. RCS 107120784. Président : Cornu-Thenard, Raphaël André Laurent Marie.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 72, "end": 79, "type": "CITY", "value": "Orléans"}, {"start": 120, "end": 135, "type": "COMPANY", "value": "MONOLYT CAPITAL"}, {"start": 187, "end": 195, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 212, "end": 231, "type": "ADDRESS", "value": "41 rue du Martineau"}, {"start": 233, "end": 238, "type": "ADDRESS", "value": "45320"}, {"start": 239, "end": 248, "type": "CITY", "value": "Courtenay"}, {"start": 254, "end": 263, "type": "SIREN", "value": "107120784"}, {"start": 277, "end": 319, "type": "PERSON", "value": "Cornu-Thenard, Raphaël André Laurent Marie"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142288"}
|
| 54 |
+
{"id": "bodacc-A20260142377", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 377 du 29/07/2026. Greffe du Tribunal de Commerce de Beauvais. Immatriculation au RCS. Dénomination : NIP LOCATION. Forme : Société par actions simplifiée. Capital : 1000 EUR. Siège social : 301 allée des Artisans, Z.I. de Pont / Bre, 60870 Brenouille. RCS 106981525.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 81, "type": "CITY", "value": "Beauvais"}, {"start": 122, "end": 134, "type": "COMPANY", "value": "NIP LOCATION"}, {"start": 186, "end": 194, "type": "AMOUNT", "value": "1000 EUR"}, {"start": 211, "end": 253, "type": "ADDRESS", "value": "301 allée des Artisans, Z.I. de Pont / Bre"}, {"start": 255, "end": 260, "type": "ADDRESS", "value": "60870"}, {"start": 261, "end": 271, "type": "CITY", "value": "Brenouille"}, {"start": 277, "end": 286, "type": "SIREN", "value": "106981525"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142377"}
|
| 55 |
+
{"id": "bodacc-A20260142472", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 472 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : LORENA. Forme : Société civile immobilière. Capital : 1000.00 EUR. Siège social : 4 Rue des Oliviers, 64700 Hendaye. RCS 107818718.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 127, "type": "COMPANY", "value": "LORENA"}, {"start": 175, "end": 186, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 203, "end": 221, "type": "ADDRESS", "value": "4 Rue des Oliviers"}, {"start": 223, "end": 228, "type": "ADDRESS", "value": "64700"}, {"start": 229, "end": 236, "type": "CITY", "value": "Hendaye"}, {"start": 242, "end": 251, "type": "SIREN", "value": "107818718"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142472"}
|
| 56 |
+
{"id": "bodacc-A20260142480", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 480 du 29/07/2026. Greffe du Tribunal de Commerce de Bayonne. Immatriculation au RCS. Dénomination : Paris 18. Forme : Société civile immobilière. Capital : 1000.00 EUR. Siège social : 114 Impasse de Serres, 64310 Saint-Pée-sur-Nivelle. RCS 107635963.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 80, "type": "CITY", "value": "Bayonne"}, {"start": 121, "end": 129, "type": "COMPANY", "value": "Paris 18"}, {"start": 177, "end": 188, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 205, "end": 226, "type": "ADDRESS", "value": "114 Impasse de Serres"}, {"start": 228, "end": 233, "type": "ADDRESS", "value": "64310"}, {"start": 234, "end": 255, "type": "CITY", "value": "Saint-Pée-sur-Nivelle"}, {"start": 261, "end": 270, "type": "SIREN", "value": "107635963"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142480"}
|
| 57 |
+
{"id": "bodacc-A20260142541", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 541 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Lyon. Immatriculation au RCS. Dénomination : BYKS. Forme : Société par Actions Simplifiée. Capital : 1000.00 EUR. Siège social : 13 Rue Louis Fort, 69100 Villeurbanne. RCS 108016791.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 91, "type": "CITY", "value": "Lyon"}, {"start": 132, "end": 136, "type": "COMPANY", "value": "BYKS"}, {"start": 188, "end": 199, "type": "AMOUNT", "value": "1000.00 EUR"}, {"start": 216, "end": 233, "type": "ADDRESS", "value": "13 Rue Louis Fort"}, {"start": 235, "end": 240, "type": "ADDRESS", "value": "69100"}, {"start": 241, "end": 253, "type": "CITY", "value": "Villeurbanne"}, {"start": 259, "end": 268, "type": "SIREN", "value": "108016791"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142541"}
|
| 58 |
+
{"id": "bodacc-A20260142550", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 550 du 29/07/2026. Greffe du Tribunal des Activités Economiques de Lyon. Immatriculation au RCS. Dénomination : MAISON YOU. Forme : Société par Actions Simplifiée. Capital : 20000.00 EUR. Siège social : 6 Rue Du Collovrier, 69130 Écully. RCS 108003997.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 87, "end": 91, "type": "CITY", "value": "Lyon"}, {"start": 132, "end": 142, "type": "COMPANY", "value": "MAISON YOU"}, {"start": 194, "end": 206, "type": "AMOUNT", "value": "20000.00 EUR"}, {"start": 223, "end": 242, "type": "ADDRESS", "value": "6 Rue Du Collovrier"}, {"start": 244, "end": 249, "type": "ADDRESS", "value": "69130"}, {"start": 250, "end": 256, "type": "CITY", "value": "Écully"}, {"start": 262, "end": 271, "type": "SIREN", "value": "108003997"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142550"}
|
| 59 |
+
{"id": "bodacc-A20260142608", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 608 du 29/07/2026. Greffe du Tribunal de Commerce de Villefranche-Tarare. Immatriculation au RCS. Dénomination : Ji&Jo Restaurants. Forme : Société à Responsabilité Limitée. Capital : 7500.00 EUR. Siège social : 161 Place Bernigal Guillermin, 69620 Val-d'Oingt. RCS 107900060.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 92, "type": "CITY", "value": "Villefranche-Tarare"}, {"start": 133, "end": 150, "type": "COMPANY", "value": "Ji&Jo Restaurants"}, {"start": 204, "end": 215, "type": "AMOUNT", "value": "7500.00 EUR"}, {"start": 232, "end": 261, "type": "ADDRESS", "value": "161 Place Bernigal Guillermin"}, {"start": 263, "end": 268, "type": "ADDRESS", "value": "69620"}, {"start": 269, "end": 280, "type": "CITY", "value": "Val-d'Oingt"}, {"start": 286, "end": 295, "type": "SIREN", "value": "107900060"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142608"}
|
| 60 |
+
{"id": "bodacc-A20260142621", "domain": "bodacc-reel", "noise": false, "text": "BODACC — Annonce n° 621 du 29/07/2026. Greffe du Tribunal de Commerce de Villefranche-Tarare. Immatriculation au RCS. Dénomination : SPFPL DR CHRETIEN DR LACQUEMANNE DR LEBOFFE. Forme : Société de participations financières de professions libérales à forme de S.A.S.. Capital : 3000.00 EUR. Siège social : 120 Ancienne Route de Beaujeu, 69400 Arnas. RCS 106649254.", "entities": [{"start": 27, "end": 37, "type": "DATE", "value": "29/07/2026"}, {"start": 73, "end": 92, "type": "CITY", "value": "Villefranche-Tarare"}, {"start": 133, "end": 176, "type": "COMPANY", "value": "SPFPL DR CHRETIEN DR LACQUEMANNE DR LEBOFFE"}, {"start": 278, "end": 289, "type": "AMOUNT", "value": "3000.00 EUR"}, {"start": 306, "end": 335, "type": "ADDRESS", "value": "120 Ancienne Route de Beaujeu"}, {"start": 337, "end": 342, "type": "ADDRESS", "value": "69400"}, {"start": 343, "end": 348, "type": "CITY", "value": "Arnas"}, {"start": 354, "end": 363, "type": "SIREN", "value": "106649254"}], "source": "https://www.bodacc.fr/pages/annonces-commerciales-detail/?q.id=id:A20260142621"}
|
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"id": "fictif-000", "domain": "fictif-main", "noise": false, "text": "Cabinet Isaac Fernandes\nAvocat au barreau de GillesVille\n\nMadame, Monsieur,\n\nJe vous informe que le tribunal a rendu sa décision dans l'affaire qui vous oppose à votre ancien employeur. Le jugement du 16 octobre 2023 vous alloue 7 174,68 € au titre des salaires impayés, outre 8413.27 EUR pour licenciement sans cause réelle et sérieuse.\n\nL'exécution interviendra par virement sur votre compte FR7650596505025145556151040. Je reste joignable au 01 79 26 63 87.\n\nBien à vous,\nMe Fernandes, Isaac", "entities": [{"start": 8, "end": 23, "type": "PERSON", "value": "Isaac Fernandes"}, {"start": 45, "end": 56, "type": "CITY", "value": "GillesVille"}, {"start": 201, "end": 216, "type": "DATE", "value": "16 octobre 2023"}, {"start": 229, "end": 239, "type": "AMOUNT", "value": "7 174,68 €"}, {"start": 277, "end": 288, "type": "AMOUNT", "value": "8413.27 EUR"}, {"start": 394, "end": 421, "type": "IBAN", "value": "FR7650596505025145556151040"}, {"start": 445, "end": 459, "type": "PHONE", "value": "01 79 26 63 87"}, {"start": 478, "end": 494, "type": "PERSON", "value": "Fernandes, Isaac"}]}
|
| 2 |
+
{"id": "fictif-001", "domain": "fictif-main", "noise": false, "text": "EXTRAIT DES MINUTES DU GREFFE\n\nAudience publique du 7 mars 2025\n\nLa société Guillon SAS, prise en la personne de son représentant légal, a formé opposition à l'ordonnance d'injonction de payer n° 23/39292 signifiée le 30/09/2023. Claude Benoit, huissier de justice à Saint Bernadette, a dressé procès-verbal de signification. Le montant en principal s'élève à 74 407,67 €.", "entities": [{"start": 52, "end": 63, "type": "DATE", "value": "7 mars 2025"}, {"start": 76, "end": 87, "type": "COMPANY", "value": "Guillon SAS"}, {"start": 196, "end": 204, "type": "RG", "value": "23/39292"}, {"start": 218, "end": 228, "type": "DATE", "value": "30/09/2023"}, {"start": 230, "end": 243, "type": "PERSON", "value": "Claude Benoit"}, {"start": 267, "end": 283, "type": "CITY", "value": "Saint Bernadette"}, {"start": 360, "end": 371, "type": "AMOUNT", "value": "74 407,67 €"}]}
|
| 3 |
+
{"id": "fictif-002", "domain": "fictif-main", "noise": false, "text": "De : pmuller@example.org\nÀ : klopez@example.org\nObjet : TVA T2\n\nBonjour F. Lombard,\n\nPeux-tu vérifier la déclaration de TVA du trimestre ? Le numéro intracommunautaire de notre nouveau fournisseur est FR50 605139492 et son SIRET 57833470802600. Leur RIB pour le règlement : FR76 3564 7839 3642 2739 4142 189.\n\nMerci d'avance,\nThomas Guillon", "entities": [{"start": 5, "end": 24, "type": "EMAIL", "value": "pmuller@example.org"}, {"start": 29, "end": 47, "type": "EMAIL", "value": "klopez@example.org"}, {"start": 72, "end": 82, "type": "PERSON", "value": "F. Lombard"}, {"start": 201, "end": 215, "type": "TVA", "value": "FR50 605139492"}, {"start": 229, "end": 243, "type": "SIRET", "value": "57833470802600"}, {"start": 274, "end": 307, "type": "IBAN", "value": "FR76 3564 7839 3642 2739 4142 189"}, {"start": 326, "end": 340, "type": "PERSON", "value": "Thomas Guillon"}]}
|
| 4 |
+
{"id": "fictif-003", "domain": "fictif-main", "noise": false, "text": "CONSTAT AMIABLE — accident du 1 juin 2026\n\nVéhicule A : 799 WZD 23, conduit par Nicole Girard, assuré police n° 30503.\nVéhicule B : BV-951-ZH, conduit par Frédéric Lambert, demeurant 74, boulevard Lemaire à Le Gall-sur-Vaillant.\nCroquis joint. Blessés : non. Dégâts matériels estimés à 69 478,78 €.\nTémoin : Zacharie Arnaud, joignable au 09 99 87 71 50.", "entities": [{"start": 30, "end": 41, "type": "DATE", "value": "1 juin 2026"}, {"start": 56, "end": 66, "type": "PLATE", "value": "799 WZD 23"}, {"start": 80, "end": 93, "type": "PERSON", "value": "Nicole Girard"}, {"start": 112, "end": 117, "type": "REF", "value": "30503"}, {"start": 132, "end": 141, "type": "PLATE", "value": "BV-951-ZH"}, {"start": 155, "end": 171, "type": "PERSON", "value": "Frédéric Lambert"}, {"start": 183, "end": 204, "type": "ADDRESS", "value": "74, boulevard Lemaire"}, {"start": 207, "end": 227, "type": "CITY", "value": "Le Gall-sur-Vaillant"}, {"start": 286, "end": 297, "type": "AMOUNT", "value": "69 478,78 €"}, {"start": 308, "end": 323, "type": "PERSON", "value": "Zacharie Arnaud"}, {"start": 338, "end": 352, "type": "PHONE", "value": "09 99 87 71 50"}]}
|
| 5 |
+
{"id": "fictif-004", "domain": "fictif-main", "noise": false, "text": "Ma chère Madame Dr Bernard BLIN,\n\nComme convenu lors de notre rendez-vous du 15/04/2025, je vous confirme que la succession de votre père, Étienne Guichard, né le 07/09/1942 à Saint Laure-sur-Mer, comprend le bien cadastré section K n° 113 ainsi qu'un portefeuille de titres.\n\nLes droits à régler s'élèvent à 5671,76 €. Mon étude reste à votre disposition.\n\nMe Paul Bazin, notaire", "entities": [{"start": 16, "end": 31, "type": "PERSON", "value": "Dr Bernard BLIN"}, {"start": 77, "end": 87, "type": "DATE", "value": "15/04/2025"}, {"start": 139, "end": 155, "type": "PERSON", "value": "Étienne Guichard"}, {"start": 163, "end": 173, "type": "DATE_BIRTH", "value": "07/09/1942"}, {"start": 176, "end": 195, "type": "CITY", "value": "Saint Laure-sur-Mer"}, {"start": 223, "end": 239, "type": "CADASTRE", "value": "section K n° 113"}, {"start": 309, "end": 318, "type": "AMOUNT", "value": "5671,76 €"}, {"start": 361, "end": 371, "type": "PERSON", "value": "Paul Bazin"}]}
|
| 6 |
+
{"id": "fictif-005", "domain": "fictif-main", "noise": false, "text": "FICHE DE RENSEIGNEMENTS — Inscription école de musique\n\nÉlève : René Launay, né le 24/04/1992\nResponsable légal : Suzanne Mary\nAdresse : 20-26 chemin Théophile Menard, Rocher\nTéléphone : +33 5 44 77 46 60\nEmail : edouardbruneau@example.com\nCotisation annuelle : 45409.94 EUR, réglée par carte 5246529369726089.\nAutorisation de sortie : oui.", "entities": [{"start": 64, "end": 75, "type": "PERSON", "value": "René Launay"}, {"start": 83, "end": 93, "type": "DATE_BIRTH", "value": "24/04/1992"}, {"start": 114, "end": 126, "type": "PERSON", "value": "Suzanne Mary"}, {"start": 137, "end": 166, "type": "ADDRESS", "value": "20-26 chemin Théophile Menard"}, {"start": 168, "end": 174, "type": "CITY", "value": "Rocher"}, {"start": 187, "end": 204, "type": "PHONE", "value": "+33 5 44 77 46 60"}, {"start": 213, "end": 239, "type": "EMAIL", "value": "edouardbruneau@example.com"}, {"start": 262, "end": 274, "type": "AMOUNT", "value": "45409.94 EUR"}, {"start": 293, "end": 309, "type": "CARD", "value": "5246529369726089"}]}
|
| 7 |
+
{"id": "fictif-006", "domain": "fictif-main", "noise": false, "text": "wesh tu peux me faire le virement stp\nc'est urgent, le proprio menace\nFR76 9325 5667 7124 8147 9741 639\nau nom de Rémy Costa\nje te rembourse à la paie promis\nmon 06 a changé c'est le 06 10 28 13 29", "entities": [{"start": 70, "end": 103, "type": "IBAN", "value": "FR76 9325 5667 7124 8147 9741 639"}, {"start": 114, "end": 124, "type": "PERSON", "value": "Rémy Costa"}, {"start": 183, "end": 197, "type": "PHONE", "value": "06 10 28 13 29"}]}
|
| 8 |
+
{"id": "fictif-007", "domain": "fictif-main", "noise": false, "text": "PROCÈS-VERBAL D'ASSEMBLÉE GÉNÉRALE EXTRAORDINAIRE\n\nLe 14/03/2026, les associés de Hervé SA (SIREN 846706976), réunis au siège sis 2, avenue de Gaillard à Fernandes, ont décidé :\n1. La révocation de Victoire De Oliveira de ses fonctions de gérant ;\n2. La nomination de Alphonse Laroche, demeurant 22 Garnier, en qualité de nouveau gérant ;\n3. Le transfert du siège social.\n\nPour extrait certifié conforme, Dr Laroche.", "entities": [{"start": 54, "end": 64, "type": "DATE", "value": "14/03/2026"}, {"start": 82, "end": 90, "type": "COMPANY", "value": "Hervé SA"}, {"start": 98, "end": 107, "type": "SIREN", "value": "846706976"}, {"start": 130, "end": 151, "type": "ADDRESS", "value": "2, avenue de Gaillard"}, {"start": 154, "end": 163, "type": "CITY", "value": "Fernandes"}, {"start": 198, "end": 218, "type": "PERSON", "value": "Victoire De Oliveira"}, {"start": 268, "end": 284, "type": "PERSON", "value": "Alphonse Laroche"}, {"start": 296, "end": 306, "type": "ADDRESS", "value": "22 Garnier"}, {"start": 405, "end": 415, "type": "PERSON", "value": "Dr Laroche"}]}
|
| 9 |
+
{"id": "fictif-008", "domain": "fictif-main", "noise": false, "text": "Objet : votre dossier de surendettement n° 11470\n\nMadame R. Baudry,\n\nLa commission a déclaré votre dossier recevable le 09/12/2025. Vos créances déclarées s'élèvent à 1491,92 €, dont 3935 € au titre du crédit renouvelable souscrit auprès de Leblanc SA.\n\nVotre référence NIR pour la CAF : 102019466610639. Merci de ne communiquer ce numéro à aucun tiers.\n\nLe secrétariat de la commission, Valentin", "entities": [{"start": 43, "end": 48, "type": "REF", "value": "11470"}, {"start": 57, "end": 66, "type": "PERSON", "value": "R. Baudry"}, {"start": 120, "end": 130, "type": "DATE", "value": "09/12/2025"}, {"start": 167, "end": 176, "type": "AMOUNT", "value": "1491,92 €"}, {"start": 183, "end": 189, "type": "AMOUNT", "value": "3935 €"}, {"start": 241, "end": 251, "type": "COMPANY", "value": "Leblanc SA"}, {"start": 288, "end": 303, "type": "NIR", "value": "102019466610639"}, {"start": 388, "end": 396, "type": "CITY", "value": "Valentin"}]}
|
| 10 |
+
{"id": "fictif-009", "domain": "fictif-main", "noise": false, "text": "ORDONNANCE DE ROULEMENT — Copropriété « Les Terrasses »\n\nSuite au dégât des eaux du 23 janvier 2025 affectant le lot 12, l'expert Michel Muller (cabinet DUPUY S.A.R.L.) passera le 30/08/2025 entre 9 h et 12 h. Contact syndic : 04 03 32 27 37 ou bonnetnath@example.net. Les travaux, chiffrés à 9708,41 €, seront votés à la prochaine AG.", "entities": [{"start": 84, "end": 99, "type": "DATE", "value": "23 janvier 2025"}, {"start": 130, "end": 143, "type": "PERSON", "value": "Michel Muller"}, {"start": 153, "end": 167, "type": "COMPANY", "value": "DUPUY S.A.R.L."}, {"start": 180, "end": 190, "type": "DATE", "value": "30/08/2025"}, {"start": 227, "end": 241, "type": "PHONE", "value": "04 03 32 27 37"}, {"start": 245, "end": 267, "type": "EMAIL", "value": "bonnetnath@example.net"}, {"start": 293, "end": 302, "type": "AMOUNT", "value": "9708,41 ��"}]}
|
| 11 |
+
{"id": "fictif-010", "domain": "fictif-main", "noise": false, "text": "RECU POUR SOLDE DE TOUT COMPTE\n\nJe soussigné(e) Honoré Jourdan, demeurant 43 Grande Rue à Bazin-sur-Cohen, reconnais avoir reçu de la société JACQUET IMMO la somme de 58188.99 EUR pour solde de tout compte.\n\nFait à Bazin-sur-Cohen, le 21/09/2025, en deux exemplaires.\n\nSignature précédée de la mention « bon pour solde de tout compte »\nH. Jourdan", "entities": [{"start": 48, "end": 62, "type": "PERSON", "value": "Honoré Jourdan"}, {"start": 74, "end": 87, "type": "ADDRESS", "value": "43 Grande Rue"}, {"start": 90, "end": 105, "type": "CITY", "value": "Bazin-sur-Cohen"}, {"start": 142, "end": 154, "type": "COMPANY", "value": "JACQUET IMMO"}, {"start": 167, "end": 179, "type": "AMOUNT", "value": "58188.99 EUR"}, {"start": 215, "end": 230, "type": "CITY", "value": "Bazin-sur-Cohen"}, {"start": 235, "end": 245, "type": "DATE", "value": "21/09/2025"}, {"start": 336, "end": 346, "type": "PERSON", "value": "H. Jourdan"}]}
|
| 12 |
+
{"id": "fictif-011", "domain": "fictif-main", "noise": false, "text": "Docteur Xavier Perrot\nMédecine générale — conventionné secteur 1\n\nCertificat médical\n\nJe certifie avoir examiné ce jour Aimée Pinto, né le 10/07/1961, et constaté que son état de santé nécessite un arrêt de travail de 10 jours à compter du 28/05/2025.\n\nCertificat établi à la demande de l'intéressé pour faire valoir ce que de droit.\nFait à Lopez-sur-Mer, le 28/05/2025.", "entities": [{"start": 8, "end": 21, "type": "PERSON", "value": "Xavier Perrot"}, {"start": 120, "end": 131, "type": "PERSON", "value": "Aimée Pinto"}, {"start": 139, "end": 149, "type": "DATE_BIRTH", "value": "10/07/1961"}, {"start": 240, "end": 250, "type": "DATE", "value": "28/05/2025"}, {"start": 341, "end": 354, "type": "CITY", "value": "Lopez-sur-Mer"}, {"start": 359, "end": 369, "type": "DATE", "value": "28/05/2025"}]}
|
| 13 |
+
{"id": "fictif-012", "domain": "fictif-main", "noise": false, "text": "AVIS D'ÉCHÉANCE — Assurance habitation\n\nContrat : 95152\nAssuré : Guy Dumont, 42-48 rue de Chauvin, MaheBourg\nPériode : du 27 janvier 2024 au 11 octobre 2024\nPrime annuelle : 1838,71 €\n\nSans opposition de votre part, le prélèvement sera effectué sur le compte FR76 5579 4655 6454 9689 2598 110 le 5 du mois prochain. Service client : 09 40 09 85 30.", "entities": [{"start": 50, "end": 55, "type": "REF", "value": "95152"}, {"start": 65, "end": 75, "type": "PERSON", "value": "Guy Dumont"}, {"start": 77, "end": 97, "type": "ADDRESS", "value": "42-48 rue de Chauvin"}, {"start": 99, "end": 108, "type": "CITY", "value": "MaheBourg"}, {"start": 122, "end": 137, "type": "DATE", "value": "27 janvier 2024"}, {"start": 141, "end": 156, "type": "DATE", "value": "11 octobre 2024"}, {"start": 174, "end": 183, "type": "AMOUNT", "value": "1838,71 €"}, {"start": 259, "end": 292, "type": "IBAN", "value": "FR76 5579 4655 6454 9689 2598 110"}, {"start": 333, "end": 347, "type": "PHONE", "value": "09 40 09 85 30"}]}
|
| 14 |
+
{"id": "fictif-013", "domain": "fictif-main", "noise": false, "text": "Monsieur le Président du tribunal judiciaire de Dos Santos,\n\nJ'ai l'honneur de solliciter l'aide juridictionnelle totale dans le litige m'opposant à Dias SARL. Mes ressources mensuelles s'élèvent à 2104,99 euros. Je suis né le 24/11/1955 à Pelletiernec et demeure 31, rue Delmas.\n\nDans l'attente, je vous prie d'agréer l'expression de ma considération distinguée.\n\nGabriel Richard\nNIR : 2 62 03 87 853 230 72", "entities": [{"start": 48, "end": 58, "type": "CITY", "value": "Dos Santos"}, {"start": 149, "end": 158, "type": "COMPANY", "value": "Dias SARL"}, {"start": 198, "end": 211, "type": "AMOUNT", "value": "2104,99 euros"}, {"start": 227, "end": 237, "type": "DATE_BIRTH", "value": "24/11/1955"}, {"start": 240, "end": 252, "type": "CITY", "value": "Pelletiernec"}, {"start": 264, "end": 278, "type": "ADDRESS", "value": "31, rue Delmas"}, {"start": 365, "end": 380, "type": "PERSON", "value": "Gabriel Richard"}, {"start": 387, "end": 408, "type": "NIR", "value": "2 62 03 87 853 230 72"}]}
|
| 15 |
+
{"id": "fictif-014", "domain": "fictif-main", "noise": false, "text": "== Note interne — confidentiel ==\nSujet : anomalie paie de P. Pruvost\n\nLe virement du salaire de Patrick Pruvost (matricule 67681) est parti deux fois le 13/02/2024 : 7002,25 euros au lieu de 2765 €. L'IBAN concerné finit par les chiffres de FR7650979120721498219570032. Voir avec la banque pour le rappel de fonds ; le salarié a été prévenu au +33 7 09 34 02 81.", "entities": [{"start": 59, "end": 69, "type": "PERSON", "value": "P. Pruvost"}, {"start": 97, "end": 112, "type": "PERSON", "value": "Patrick Pruvost"}, {"start": 124, "end": 129, "type": "REF", "value": "67681"}, {"start": 154, "end": 164, "type": "DATE", "value": "13/02/2024"}, {"start": 167, "end": 180, "type": "AMOUNT", "value": "7002,25 euros"}, {"start": 192, "end": 198, "type": "AMOUNT", "value": "2765 €"}, {"start": 242, "end": 269, "type": "IBAN", "value": "FR7650979120721498219570032"}, {"start": 345, "end": 362, "type": "PHONE", "value": "+33 7 09 34 02 81"}]}
|
| 16 |
+
{"id": "fictif-015", "domain": "fictif-main", "noise": false, "text": "CONTRAT DE LOCATION SAISONNIÈRE\n\nEntre Guy Thomas, propriétaire du gîte « Les Oliviers » situé 68, boulevard de Julien à Blot, et Anastasie Pineau, domicilié 766, rue Christine Couturier, il est convenu la location du 9 octobre 2024 au 22/02/2024 pour 5656,70 €, arrhes de 4006,14 € versées ce jour par carte 5537251302075148.\n\nLe solde sera réglé à l'arrivée. Remise des clés par G. Thomas (02 84 83 55 84).", "entities": [{"start": 39, "end": 49, "type": "PERSON", "value": "Guy Thomas"}, {"start": 95, "end": 118, "type": "ADDRESS", "value": "68, boulevard de Julien"}, {"start": 121, "end": 125, "type": "CITY", "value": "Blot"}, {"start": 130, "end": 146, "type": "PERSON", "value": "Anastasie Pineau"}, {"start": 158, "end": 186, "type": "ADDRESS", "value": "766, rue Christine Couturier"}, {"start": 218, "end": 232, "type": "DATE", "value": "9 octobre 2024"}, {"start": 236, "end": 246, "type": "DATE", "value": "22/02/2024"}, {"start": 252, "end": 261, "type": "AMOUNT", "value": "5656,70 €"}, {"start": 273, "end": 282, "type": "AMOUNT", "value": "4006,14 €"}, {"start": 309, "end": 325, "type": "CARD", "value": "5537251302075148"}, {"start": 381, "end": 390, "type": "PERSON", "value": "G. Thomas"}, {"start": 392, "end": 406, "type": "PHONE", "value": "02 84 83 55 84"}]}
|
| 17 |
+
{"id": "fictif-016", "domain": "fictif-main", "noise": false, "text": "Relevé de décisions — comité d'entreprise du 12 juillet 2026\n\nPrésents : Matthieu Goncalves, Bertrand Leblanc, Anastasie Henry.\nExcusé : Adélaïde Duhamel.\n\nLe budget des œuvres sociales est fixé à 91 846,81 €. Les chèques-vacances seront commandés auprès de REGNIER ROUSSEL SARL avant le 31 mai 2025. Contact fournisseur : guillaumelaetitia@example.com.", "entities": [{"start": 45, "end": 60, "type": "DATE", "value": "12 juillet 2026"}, {"start": 73, "end": 91, "type": "PERSON", "value": "Matthieu Goncalves"}, {"start": 93, "end": 109, "type": "PERSON", "value": "Bertrand Leblanc"}, {"start": 111, "end": 126, "type": "PERSON", "value": "Anastasie Henry"}, {"start": 137, "end": 153, "type": "PERSON", "value": "Adélaïde Duhamel"}, {"start": 197, "end": 208, "type": "AMOUNT", "value": "91 846,81 €"}, {"start": 258, "end": 278, "type": "COMPANY", "value": "REGNIER ROUSSEL SARL"}, {"start": 288, "end": 299, "type": "DATE", "value": "31 mai 2025"}, {"start": 323, "end": 352, "type": "EMAIL", "value": "guillaumelaetitia@example.com"}]}
|
| 18 |
+
{"id": "fictif-017", "domain": "fictif-main", "noise": false, "text": "AVIS DE PASSAGE\n\nNous sommes passés ce jour 07/01/2024 pour la relève du compteur au 113-117 chemin Josette Marchal, en votre absence.\n\nMerci de transmettre votre index avant le 29/12/2024 sur votre espace client ou au 01.10.85.48.64. Référence client : 37053. À défaut, votre facture sera estimée sur la base de 9910.31 EUR.", "entities": [{"start": 44, "end": 54, "type": "DATE", "value": "07/01/2024"}, {"start": 85, "end": 115, "type": "ADDRESS", "value": "113-117 chemin Josette Marchal"}, {"start": 178, "end": 188, "type": "DATE", "value": "29/12/2024"}, {"start": 219, "end": 233, "type": "PHONE", "value": "01.10.85.48.64"}, {"start": 254, "end": 259, "type": "REF", "value": "37053"}, {"start": 313, "end": 324, "type": "AMOUNT", "value": "9910.31 EUR"}]}
|
| 19 |
+
{"id": "fictif-018", "domain": "fictif-main", "noise": false, "text": "Maître,\n\nJe fais suite à la mise en demeure reçue de votre cabinet au nom de Coulon S.A.R.L. SARL. Je conteste formellement la créance de 71431.31 EUR : la facture visée a été réglée par virement du compte FR7613026270815326098187540 le 5 janvier 2025, ainsi qu'en atteste le relevé joint.\n\nSans régularisation de votre part sous quinzaine, je saisirai le médiateur.\n\nHonoré Clément\n6, chemin de Voisin, Blondel\nleclerceleonore@example.com", "entities": [{"start": 77, "end": 97, "type": "COMPANY", "value": "Coulon S.A.R.L. SARL"}, {"start": 138, "end": 150, "type": "AMOUNT", "value": "71431.31 EUR"}, {"start": 206, "end": 233, "type": "IBAN", "value": "FR7613026270815326098187540"}, {"start": 237, "end": 251, "type": "DATE", "value": "5 janvier 2025"}, {"start": 368, "end": 382, "type": "PERSON", "value": "Honoré Clément"}, {"start": 383, "end": 402, "type": "ADDRESS", "value": "6, chemin de Voisin"}, {"start": 404, "end": 411, "type": "CITY", "value": "Blondel"}, {"start": 412, "end": 439, "type": "EMAIL", "value": "leclerceleonore@example.com"}]}
|
| 20 |
+
{"id": "fictif-019", "domain": "fictif-main", "noise": false, "text": "FICHE NAVETTE — Mutation intra-groupe\n\nAgent : Claudine Blot, NIR 191098244075233\nAffectation actuelle : site de Michel-la-Forêt\nNouvelle affectation : WEISS IMMO, Sainte Dianeboeuf, à compter du 19 avril 2026\nVéhicule de fonction : 116 VPW 88\nIndemnité de mobilité : 3867,10 €\nContact RH : LELEU, elisabethallard@example.net", "entities": [{"start": 47, "end": 60, "type": "PERSON", "value": "Claudine Blot"}, {"start": 66, "end": 81, "type": "NIR", "value": "191098244075233"}, {"start": 113, "end": 128, "type": "CITY", "value": "Michel-la-Forêt"}, {"start": 152, "end": 162, "type": "COMPANY", "value": "WEISS IMMO"}, {"start": 164, "end": 181, "type": "CITY", "value": "Sainte Dianeboeuf"}, {"start": 196, "end": 209, "type": "DATE", "value": "19 avril 2026"}, {"start": 233, "end": 243, "type": "PLATE", "value": "116 VPW 88"}, {"start": 268, "end": 277, "type": "AMOUNT", "value": "3867,10 €"}, {"start": 291, "end": 296, "type": "PERSON", "value": "LELEU"}, {"start": 298, "end": 325, "type": "EMAIL", "value": "elisabethallard@example.net"}]}
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
The diff for this file is too large to render.
See raw diff
|
|
|
|
File without changes
|
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Seconde passe en majuscules ciblees : reveiller ce que le modele sait deja.
|
| 2 |
+
|
| 3 |
+
Mesure du 31/07/2026. En presentant au modele le MEME texte mis en
|
| 4 |
+
capitales, la fuite sur les societes tombait de 15,8 % a 7,2 %. Autrement
|
| 5 |
+
dit, une societe sur trois que le modele « rate » lui est en fait
|
| 6 |
+
familiere : il ne la reconnait pas ecrite « Pennylane » alors qu'il la
|
| 7 |
+
reconnait ecrite « PENNYLANE ». Cause : les pools BODACC et SIRENE qui ont
|
| 8 |
+
servi a fabriquer le corpus stockent les raisons sociales en capitales,
|
| 9 |
+
d'ou un corpus a 65 % de majuscules contre 17 % dans la vraie
|
| 10 |
+
correspondance.
|
| 11 |
+
|
| 12 |
+
Mettre tout le texte en capitales n'est pas exploitable : le modele voit
|
| 13 |
+
alors des societes partout et le sur-masquage monte a 57 %. On ne
|
| 14 |
+
majuscule donc que les mots capitalises qu'aucune de nos trois listes ne
|
| 15 |
+
connait (lexique francais, patronymes SIRENE, prenoms INSEE) : un mot
|
| 16 |
+
capitalise absent des trois est un candidat marque. Le sur-masquage reste a
|
| 17 |
+
14 % et la fuite societes tombe a 10,3 %.
|
| 18 |
+
|
| 19 |
+
Cout : une inference de plus par document. Le module est donc optionnel,
|
| 20 |
+
active par le detecteur qui en veut.
|
| 21 |
+
|
| 22 |
+
La transformation preserve la LONGUEUR du texte, donc les offsets trouves
|
| 23 |
+
sur la variante sont valables sur l'original. Les rares caracteres dont la
|
| 24 |
+
majuscule occupe plusieurs codets (« ß ») sont laisses tels quels.
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
import gzip
|
| 28 |
+
import re
|
| 29 |
+
import unicodedata
|
| 30 |
+
from functools import lru_cache
|
| 31 |
+
from pathlib import Path
|
| 32 |
+
|
| 33 |
+
FORMES = Path(__file__).resolve().parents[2] / "data" / "formes_connues.txt.gz"
|
| 34 |
+
|
| 35 |
+
# mot capitalise d'au moins trois caracteres : « Pennylane », « Sage »,
|
| 36 |
+
# « GoCardless ». On exclut les mots d'une ou deux lettres, trop ambigus.
|
| 37 |
+
_MOT = re.compile(r"\b[A-ZÀ-Þ][a-zà-ÿ][\wÀ-ÿ.-]{1,}\b")
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def _norm(s: str) -> str:
|
| 41 |
+
s = unicodedata.normalize("NFD", s.upper())
|
| 42 |
+
return "".join(c for c in s if unicodedata.category(c) != "Mn")
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
@lru_cache(maxsize=1)
|
| 46 |
+
def _connues() -> frozenset:
|
| 47 |
+
if not FORMES.exists():
|
| 48 |
+
return frozenset()
|
| 49 |
+
with gzip.open(FORMES, "rt", encoding="utf-8") as f:
|
| 50 |
+
return frozenset(l.strip() for l in f if l.strip())
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def variante(text: str) -> str:
|
| 54 |
+
"""Le texte avec les mots capitalises inconnus passes en capitales."""
|
| 55 |
+
connues = _connues()
|
| 56 |
+
if not connues:
|
| 57 |
+
return text
|
| 58 |
+
out = list(text)
|
| 59 |
+
for m in _MOT.finditer(text):
|
| 60 |
+
mot = m.group(0)
|
| 61 |
+
if _norm(mot) in connues:
|
| 62 |
+
continue
|
| 63 |
+
for i, c in enumerate(mot.upper()):
|
| 64 |
+
if len(c) == 1:
|
| 65 |
+
out[m.start() + i] = c
|
| 66 |
+
return "".join(out)
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def seconde_passe(text: str, spans: list[dict], detecteur,
|
| 70 |
+
types=("COMPANY",)) -> list[dict]:
|
| 71 |
+
"""Spans supplementaires trouves sur la variante en capitales.
|
| 72 |
+
|
| 73 |
+
`detecteur` est la fonction de detection a rejouer. On ne retient que
|
| 74 |
+
les types demandes, et jamais un span qui empiete sur un span deja
|
| 75 |
+
trouve : la premiere passe, faite sur le texte authentique, fait foi.
|
| 76 |
+
"""
|
| 77 |
+
var = variante(text)
|
| 78 |
+
if var == text or len(var) != len(text):
|
| 79 |
+
return []
|
| 80 |
+
|
| 81 |
+
occupe = set()
|
| 82 |
+
for s in spans:
|
| 83 |
+
occupe.update(range(s["start"], s["end"]))
|
| 84 |
+
|
| 85 |
+
extra = []
|
| 86 |
+
for s in detecteur(var):
|
| 87 |
+
if s["type"] not in types:
|
| 88 |
+
continue
|
| 89 |
+
r = set(range(s["start"], s["end"]))
|
| 90 |
+
if r & occupe:
|
| 91 |
+
continue
|
| 92 |
+
occupe |= r
|
| 93 |
+
extra.append({**s, "value": text[s["start"]:s["end"]]})
|
| 94 |
+
return extra
|
|
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Gazetteer des communes francaises (geo.api.gouv.fr / COG INSEE).
|
| 2 |
+
|
| 3 |
+
Contre-mesure CITY prevue des la matrice v0 : les ~32 700 communes en couche
|
| 4 |
+
deterministe. Regle de decision :
|
| 5 |
+
- nom MULTI-token ou avec trait d'union ("Saint-Denis", "Œuf-en-Ternois") :
|
| 6 |
+
decide seul (collision improbable avec un mot commun) ;
|
| 7 |
+
- nom MONO-token ("Paris", mais aussi "Baron" ou "Aubin" qui sont des
|
| 8 |
+
patronymes) : contexte requis a proximite (a, de, commune, ville, greffe,
|
| 9 |
+
tribunal, code postal a 5 chiffres...).
|
| 10 |
+
Les variantes "St-"/"Ste-" sont indexees comme "Saint-"/"Sainte-".
|
| 11 |
+
|
| 12 |
+
Donnees : data/gazetteer_communes.txt (regenerer :
|
| 13 |
+
curl 'https://geo.api.gouv.fr/communes?fields=nom&format=json').
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
import re
|
| 17 |
+
import unicodedata
|
| 18 |
+
from functools import lru_cache
|
| 19 |
+
from pathlib import Path
|
| 20 |
+
|
| 21 |
+
DATA = Path(__file__).resolve().parents[2] / "data" / "gazetteer_communes.txt"
|
| 22 |
+
|
| 23 |
+
# contexte cherche UNIQUEMENT avant le nom : "M. Baron habite à Paris" ne
|
| 24 |
+
# doit pas valider "Baron" parce qu'un "à" traine apres
|
| 25 |
+
_CONTEXT = re.compile(
|
| 26 |
+
r"(?:\bà\b|\bde\b|\bsur\b|commune|ville|mairie|greffe|tribunal|"
|
| 27 |
+
r"domicili|demeurant|\b\d{5}\b)\s*$", re.IGNORECASE)
|
| 28 |
+
_WINDOW = 25
|
| 29 |
+
|
| 30 |
+
# mots capitalises ; continuation en minuscules autorisee UNIQUEMENT par
|
| 31 |
+
# trait d'union ("Œuf-en-Ternois" oui, "Le tribunal de..." non)
|
| 32 |
+
_CANDIDATE = re.compile(
|
| 33 |
+
r"\b[A-ZÀ-ÖØ-ÞŒ][\wÀ-ÿœŒ']*"
|
| 34 |
+
r"(?:-[\wÀ-ÿœŒ']+|[ ][A-ZÀ-ÖØ-ÞŒ][\wÀ-ÿœŒ']*){0,5}")
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
def _norm(s: str) -> str:
|
| 38 |
+
s = s.replace("St-", "Saint-").replace("Ste-", "Sainte-")
|
| 39 |
+
s = s.replace("St ", "Saint ").replace("Ste ", "Sainte ")
|
| 40 |
+
s = unicodedata.normalize("NFD", s)
|
| 41 |
+
s = "".join(c for c in s if unicodedata.category(c) != "Mn")
|
| 42 |
+
return re.sub(r"[- ']+", " ", s).lower().strip()
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
@lru_cache(maxsize=1)
|
| 46 |
+
def _index() -> tuple[set, set, int]:
|
| 47 |
+
"""(noms multi-token, noms mono-token, longueur max en mots)."""
|
| 48 |
+
multi, mono = set(), set()
|
| 49 |
+
max_words = 1
|
| 50 |
+
for name in DATA.read_text(encoding="utf-8").splitlines():
|
| 51 |
+
key = _norm(name)
|
| 52 |
+
words = key.split()
|
| 53 |
+
max_words = max(max_words, len(words))
|
| 54 |
+
(multi if len(words) > 1 else mono).add(key)
|
| 55 |
+
return multi, mono, max_words
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def detect(text: str) -> list[dict]:
|
| 59 |
+
multi, mono, max_words = _index()
|
| 60 |
+
spans = []
|
| 61 |
+
for m in _CANDIDATE.finditer(text):
|
| 62 |
+
words = re.split(r"([- ])", m.group(0))
|
| 63 |
+
# essaie du plus long prefixe de mots au plus court
|
| 64 |
+
tokens = [w for w in words if w not in ("-", " ", "")]
|
| 65 |
+
for n in range(min(len(tokens), max_words), 0, -1):
|
| 66 |
+
# reconstruit la surface du prefixe de n mots
|
| 67 |
+
count, end = 0, m.start()
|
| 68 |
+
for part in re.finditer(r"[\wÀ-ÿœŒ']+", m.group(0)):
|
| 69 |
+
count += 1
|
| 70 |
+
if count == n:
|
| 71 |
+
end = m.start() + part.end()
|
| 72 |
+
break
|
| 73 |
+
surface = text[m.start():end]
|
| 74 |
+
key = _norm(surface)
|
| 75 |
+
if key in multi:
|
| 76 |
+
spans.append({"start": m.start(), "end": end,
|
| 77 |
+
"type": "CITY", "value": surface})
|
| 78 |
+
break
|
| 79 |
+
if key in mono:
|
| 80 |
+
before = text[max(0, m.start() - _WINDOW):m.start()]
|
| 81 |
+
if _CONTEXT.search(before):
|
| 82 |
+
spans.append({"start": m.start(), "end": end,
|
| 83 |
+
"type": "CITY", "value": surface})
|
| 84 |
+
break
|
| 85 |
+
return spans
|
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Gazetteer des denominations d'entreprises (SIRENE, licence ouverte).
|
| 2 |
+
|
| 3 |
+
Reponse au dernier mur mesure : COMPANY ~52 % de fuite sur correspondance
|
| 4 |
+
reelle (audit 2026-07-29), essentiellement des societes tierces citees en
|
| 5 |
+
prose, sans forme juridique ni declencheur.
|
| 6 |
+
|
| 7 |
+
Source : base SIRENE StockUniteLegale (INSEE via data.gouv.fr), unites
|
| 8 |
+
ACTIVES uniquement : 6,3 M de denominations multi-mots + 970 k mono-mots
|
| 9 |
+
distinctifs (frequence <= 3 dans la base : un mono-mot porte par des
|
| 10 |
+
milliers d'entreprises est un mot commun, pas un nom propre).
|
| 11 |
+
|
| 12 |
+
Stockage SQLite (423 Mo, index primaire) : lookup O(log n) sans charger en
|
| 13 |
+
memoire, et directement deployable dans une app Rails 8. Les candidats sont
|
| 14 |
+
extraits du texte (sequences capitalisees), donc le cout est proportionnel
|
| 15 |
+
au document, pas au gazetteer.
|
| 16 |
+
|
| 17 |
+
Regle de decision, calquee sur le gazetteer communes :
|
| 18 |
+
- denomination MULTI-mots trouvee dans SIRENE -> decide seule
|
| 19 |
+
- MONO-mot -> exige un declencheur de contexte (societe, agence, chez,
|
| 20 |
+
editeur, prestataire, client, fournisseur, partenaire, plateforme...)
|
| 21 |
+
"""
|
| 22 |
+
|
| 23 |
+
import re
|
| 24 |
+
import sqlite3
|
| 25 |
+
import unicodedata
|
| 26 |
+
from functools import lru_cache
|
| 27 |
+
from pathlib import Path
|
| 28 |
+
|
| 29 |
+
DB = Path(__file__).resolve().parents[2] / "data" / "gazetteer_sirene.db"
|
| 30 |
+
|
| 31 |
+
_CONTEXT = re.compile(
|
| 32 |
+
r"(?:soci[eé]t[eé]|agence|entreprise|[eé]tablissement|cabinet|\bchez\b|"
|
| 33 |
+
r"[eé]diteur|prestataire|fournisseur|partenaire|client|plateforme|"
|
| 34 |
+
r"outil|logiciel|solution|groupe|filiale|concurrent|via|avec)\s*$",
|
| 35 |
+
re.IGNORECASE)
|
| 36 |
+
_WINDOW = 40
|
| 37 |
+
|
| 38 |
+
# sequences de mots capitalises ou tout-majuscules (2 a 5 mots)
|
| 39 |
+
_CANDIDATE = re.compile(
|
| 40 |
+
r"\b[A-ZÀ-ÖØ-Þ][\wÀ-ÿ&'’.-]*(?:[ -][A-ZÀ-ÖØ-Þ0-9][\wÀ-ÿ&'’.-]*){0,4}")
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
# mots communs francais : une denomination faite UNIQUEMENT de ces mots
|
| 44 |
+
# ("LE PETIT CHAT" est une vraie societe au RCS) ne decide pas seule.
|
| 45 |
+
_COMMON = set("""LE LA LES UN UNE DES DU DE AU AUX ET OU EN PAR POUR AVEC SANS
|
| 46 |
+
SOUS SUR DANS CHEZ NOUS VOUS ILS ELLE CE CETTE CES MON MA MES TON TA SON SA
|
| 47 |
+
NOTRE VOTRE LEUR TOUT TOUS TOUTE PETIT PETITE GRAND GRANDE BON BONNE BEAU
|
| 48 |
+
BELLE NOUVEAU NOUVELLE VIEUX JEUNE PREMIER DERNIER MAISON JARDIN CHAT CHIEN
|
| 49 |
+
FLEUR SOLEIL LUNE ETOILE MER MONT VILLE VILLAGE RUE PLACE PONT PORTE MOULIN
|
| 50 |
+
FERME CHATEAU EGLISE ECOLE MARCHE CAFE BAR RESTAURANT HOTEL BOUTIQUE ATELIER
|
| 51 |
+
GARAGE TAXI PLOMBERIE PEINTURE COIFFURE BOULANGERIE PHARMACIE PRESSING PIZZA
|
| 52 |
+
PIZZERIA PROJET SERVICE SERVICES CONSEIL CONSEILS SOCIETE ENTREPRISE AGENCE
|
| 53 |
+
CABINET GROUPE FRANCE PARIS BONJOUR MERCI SUITE POINT REUNION EQUIPE CLIENT
|
| 54 |
+
FACTURE DEVIS CONTRAT MAIL SITE WEB TEST PROD JOUR SEMAINE MOIS ANNEE""".split())
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def _distinctive(candidate: str) -> bool:
|
| 58 |
+
"""Vrai si le nom contient au moins un mot qui n'est pas un mot commun."""
|
| 59 |
+
return any(w not in _COMMON for w in _norm(candidate).split())
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
def _norm(s: str) -> str:
|
| 63 |
+
s = unicodedata.normalize("NFD", s.upper())
|
| 64 |
+
s = "".join(c for c in s if unicodedata.category(c) != "Mn")
|
| 65 |
+
return re.sub(r"[^A-Z0-9]+", " ", s).strip()
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@lru_cache(maxsize=1)
|
| 69 |
+
def _con():
|
| 70 |
+
if not DB.exists():
|
| 71 |
+
return None
|
| 72 |
+
con = sqlite3.connect(f"file:{DB}?mode=ro", uri=True, check_same_thread=False)
|
| 73 |
+
return con
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@lru_cache(maxsize=20000)
|
| 77 |
+
def _lookup(name: str):
|
| 78 |
+
con = _con()
|
| 79 |
+
if con is None:
|
| 80 |
+
return None
|
| 81 |
+
row = con.execute("SELECT mono FROM co WHERE name = ?", (name,)).fetchone()
|
| 82 |
+
return row[0] if row else None
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
# ESSAI ECARTE (2026-07-30) : une passe sur les tokens en minuscules
|
| 86 |
+
# rattrapait 1 point de rappel COMPANY mais faisait chuter la precision
|
| 87 |
+
# de 0,72 a 0,58 et doublait le sur-masquage. Le modele est la bonne
|
| 88 |
+
# reponse pour les marques en prose, pas le gazetteer.
|
| 89 |
+
|
| 90 |
+
def detect(text: str) -> list[dict]:
|
| 91 |
+
spans = []
|
| 92 |
+
for m in _CANDIDATE.finditer(text):
|
| 93 |
+
surface = m.group(0).rstrip(".,;:!?)")
|
| 94 |
+
words = surface.split()
|
| 95 |
+
# essaie du plus long au plus court prefixe de mots
|
| 96 |
+
for n in range(min(len(words), 5), 0, -1):
|
| 97 |
+
candidate = " ".join(words[:n])
|
| 98 |
+
if len(candidate) < 4:
|
| 99 |
+
break
|
| 100 |
+
mono = _lookup(_norm(candidate))
|
| 101 |
+
if mono is None:
|
| 102 |
+
continue
|
| 103 |
+
# mono=2 : marque tech (Wikidata) ; mono=3 : mono-mot SIRENE qui
|
| 104 |
+
# n'est NI un mot du dictionnaire NI un prenom (QONTO, IMMOSQUARE)
|
| 105 |
+
# -> tous deux decident seuls des 5 caracteres.
|
| 106 |
+
# mono=1 : mot commun ou prenom -> contexte requis.
|
| 107 |
+
if mono in (2, 3) and len(candidate) >= 5 and _distinctive(candidate):
|
| 108 |
+
pass
|
| 109 |
+
elif mono in (1, 2, 3) or not _distinctive(candidate):
|
| 110 |
+
before = text[max(0, m.start() - _WINDOW):m.start()]
|
| 111 |
+
if not _CONTEXT.search(before):
|
| 112 |
+
break
|
| 113 |
+
candidate = candidate.rstrip(".,;:!?)")
|
| 114 |
+
end = m.start() + len(candidate)
|
| 115 |
+
spans.append({"start": m.start(), "end": end,
|
| 116 |
+
"type": "COMPANY", "value": text[m.start():end]})
|
| 117 |
+
break
|
| 118 |
+
|
| 119 |
+
return spans
|
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Baseline : Jean-Baptiste/camembert-ner (generique PER/ORG/LOC/MISC).
|
| 2 |
+
|
| 3 |
+
Sert de point de comparaison dans la matrice (§5.3) : que vaut un NER FR
|
| 4 |
+
generique la ou Anonym-IA V2 est specialise PII ? Torch CPU via transformers,
|
| 5 |
+
pas d'export ONNX : c'est un candidat de matrice, pas un module produit.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from functools import lru_cache
|
| 9 |
+
|
| 10 |
+
LABEL_MAP = {"PER": "PERSON", "ORG": "COMPANY", "LOC": "CITY", "MISC": "MISC"}
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
@lru_cache(maxsize=1)
|
| 14 |
+
def _pipe():
|
| 15 |
+
from transformers import pipeline
|
| 16 |
+
|
| 17 |
+
return pipeline("ner", model="Jean-Baptiste/camembert-ner",
|
| 18 |
+
aggregation_strategy="simple", device=-1)
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
def detect(text: str) -> list[dict]:
|
| 22 |
+
spans = []
|
| 23 |
+
for e in _pipe()(text):
|
| 24 |
+
etype = LABEL_MAP.get(e["entity_group"], e["entity_group"])
|
| 25 |
+
start, end = int(e["start"]), int(e["end"])
|
| 26 |
+
# recalage frontieres de mots (meme raison que ner_onnx)
|
| 27 |
+
while start > 0 and text[start].isalnum() and text[start - 1].isalnum():
|
| 28 |
+
start -= 1
|
| 29 |
+
while end < len(text) and text[end - 1].isalnum() and text[end].isalnum():
|
| 30 |
+
end += 1
|
| 31 |
+
spans.append({"start": start, "end": end, "type": etype,
|
| 32 |
+
"value": text[start:end]})
|
| 33 |
+
return spans
|
|
@@ -0,0 +1,261 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Couche B candidate : Anonym-IA/V2-camembert-ner-pii, NOTRE export ONNX int8.
|
| 2 |
+
|
| 3 |
+
Meme interface que la couche regex : detect(text) -> spans harness.
|
| 4 |
+
|
| 5 |
+
⚠️ Constat 2026-07-28 : les exports ONNX publies par Anonym-IA (fp32 ET int8)
|
| 6 |
+
sont casses/obsoletes — ils ratent l'adresse, l'email et la ville de l'exemple
|
| 7 |
+
de leur propre carte modele, la ou le safetensors original les trouve a 99 %.
|
| 8 |
+
On exporte donc nous-memes depuis le modele source (MIT) :
|
| 9 |
+
|
| 10 |
+
optimum-cli export onnx --model Anonym-IA/V2-camembert-ner-pii-french \
|
| 11 |
+
--task token-classification models/camembert-pii/
|
| 12 |
+
python -c "from onnxruntime.quantization import quantize_dynamic, QuantType; \
|
| 13 |
+
quantize_dynamic('models/camembert-pii/model.onnx', \
|
| 14 |
+
'models/camembert-pii/model_int8.onnx', weight_type=QuantType.QUInt8, \
|
| 15 |
+
per_channel=True, op_types_to_quantize=['MatMul'])"
|
| 16 |
+
|
| 17 |
+
⚠️ Recette de quantization : la config naive (QInt8 par tenseur, tous ops)
|
| 18 |
+
detruit le rappel du modele (ne trouve plus que les entites les plus fortes).
|
| 19 |
+
QUInt8 + per_channel + MatMul uniquement = sortie identique au fp32 sur les
|
| 20 |
+
tests, 191 Mo, ~30 ms/segment CPU. `models/` est hors git.
|
| 21 |
+
|
| 22 |
+
Fenetrage : 512 tokens max (camembert), fenetres avec chevauchement, coupe
|
| 23 |
+
au milieu de la zone de recouvrement. Decodage BIO tolerant (I- apres O =
|
| 24 |
+
debut d'entite). Les spans adjacents de meme type (PRENOM + NOM -> PERSON)
|
| 25 |
+
sont fusionnes s'ils ne sont separes que par espaces/ponctuation legere.
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
import json
|
| 29 |
+
import os
|
| 30 |
+
import re
|
| 31 |
+
from functools import lru_cache
|
| 32 |
+
from pathlib import Path
|
| 33 |
+
|
| 34 |
+
import numpy as np
|
| 35 |
+
|
| 36 |
+
MODELS = Path(__file__).resolve().parents[2] / "models"
|
| 37 |
+
MODEL_DIR = MODELS / "camembert-pii"
|
| 38 |
+
MODEL_FILE = os.environ.get("NER_ONNX_FILE", "model_int8.onnx")
|
| 39 |
+
|
| 40 |
+
# labels du camembert-ner generique (Jean-Baptiste), exporte pareil
|
| 41 |
+
LABEL_MAP_GENERIC = {"PER": "PERSON", "ORG": "COMPANY", "LOC": "CITY"}
|
| 42 |
+
|
| 43 |
+
# labels modele -> types benchmark ; None = garde le label brut (la metrique
|
| 44 |
+
# de couverture compte tous les spans, quel que soit le type)
|
| 45 |
+
LABEL_MAP = {
|
| 46 |
+
"NOM_PERSONNE": "PERSON", "PRENOM_PERSONNE": "PERSON",
|
| 47 |
+
"NOM_SOCIETE": "COMPANY",
|
| 48 |
+
"NOM_VOIE": "ADDRESS", "NUMERO_VOIE": "ADDRESS",
|
| 49 |
+
"SECONDARYADDRESS": "ADDRESS", "CODE_POSTAL": "ADDRESS",
|
| 50 |
+
"VILLE": "CITY",
|
| 51 |
+
"EMAIL": "EMAIL", "TELEPHONE": "PHONE",
|
| 52 |
+
"DATE": "DATE", "DOB": "DATE_BIRTH",
|
| 53 |
+
"IBAN": "IBAN", "CREDITCARD": "CARD",
|
| 54 |
+
"NUM_SECURITE_SOCIALE": "NIR",
|
| 55 |
+
"REF_CADASTRALE": "CADASTRE", "NUM_DOSSIER": "RG",
|
| 56 |
+
"VEHICLEVRM": "PLATE", "IP": "IP",
|
| 57 |
+
"AMOUNT": "AMOUNT", "CURRENCY": "AMOUNT",
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
_MAX_TOKENS = 510 # 512 - <s> - </s>
|
| 61 |
+
_OVERLAP = 64
|
| 62 |
+
# nos fine-tunes sont entraines en sequences de 192 tokens : au-dela, les
|
| 63 |
+
# positions n'ont jamais ete vues et le rappel s'effondre (bug 'signatures
|
| 64 |
+
# en fin de mail long', audit 2026-07-29). Fenetrage par modele.
|
| 65 |
+
_MODEL_MAX = {"pii-noirci": 190, "pii-noirci-v2": 190, "pii-noirci-v6": 380, "pii-noirci-v7": 380, "pii-noirci-v8": 380}
|
| 66 |
+
_JOIN_CHARS = set(" .,-'’/")
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
@lru_cache(maxsize=4)
|
| 70 |
+
def _load(model_dir: Path = MODEL_DIR):
|
| 71 |
+
import onnxruntime as ort
|
| 72 |
+
from tokenizers import Tokenizer
|
| 73 |
+
|
| 74 |
+
if not model_dir.exists():
|
| 75 |
+
raise FileNotFoundError(
|
| 76 |
+
f"{model_dir} absent : exporter le modele (voir docstring du module)"
|
| 77 |
+
)
|
| 78 |
+
tokenizer = Tokenizer.from_file(str(model_dir / "tokenizer.json"))
|
| 79 |
+
# le tokenizer.json sauve apres un entrainement peut embarquer une
|
| 80 |
+
# troncature (192 tokens) appliquee silencieusement -> les fins de
|
| 81 |
+
# documents longs n'etaient PAS tokenisees (bug signatures, 2026-07-29)
|
| 82 |
+
tokenizer.no_truncation()
|
| 83 |
+
tokenizer.no_padding()
|
| 84 |
+
cfg = json.load(open(model_dir / "config.json"))
|
| 85 |
+
id2label = {int(k): v for k, v in cfg["id2label"].items()}
|
| 86 |
+
session = ort.InferenceSession(
|
| 87 |
+
str(model_dir / MODEL_FILE), providers=["CPUExecutionProvider"]
|
| 88 |
+
)
|
| 89 |
+
bos = tokenizer.token_to_id("<s>")
|
| 90 |
+
eos = tokenizer.token_to_id("</s>")
|
| 91 |
+
return tokenizer, session, id2label, bos, eos
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
def _windows(n_tokens: int, max_tokens: int = _MAX_TOKENS):
|
| 95 |
+
"""[(debut, fin, garde_debut, garde_fin)] : la zone gardee coupe le
|
| 96 |
+
chevauchement en son milieu."""
|
| 97 |
+
if n_tokens <= max_tokens:
|
| 98 |
+
return [(0, n_tokens, 0, n_tokens)]
|
| 99 |
+
step = max_tokens - _OVERLAP
|
| 100 |
+
wins = []
|
| 101 |
+
start = 0
|
| 102 |
+
while start < n_tokens:
|
| 103 |
+
end = min(start + max_tokens, n_tokens)
|
| 104 |
+
keep_from = start if start == 0 else start + _OVERLAP // 2
|
| 105 |
+
keep_to = end if end == n_tokens else end - _OVERLAP // 2
|
| 106 |
+
wins.append((start, end, keep_from, keep_to))
|
| 107 |
+
if end == n_tokens:
|
| 108 |
+
break
|
| 109 |
+
start += step
|
| 110 |
+
return wins
|
| 111 |
+
|
| 112 |
+
|
| 113 |
+
def _token_labels(text: str, model_dir: Path = MODEL_DIR):
|
| 114 |
+
tokenizer, session, id2label, bos, eos = _load(model_dir)
|
| 115 |
+
enc = tokenizer.encode(text, add_special_tokens=False)
|
| 116 |
+
ids, offsets = enc.ids, enc.offsets
|
| 117 |
+
labels = [None] * len(ids)
|
| 118 |
+
|
| 119 |
+
max_tokens = _MODEL_MAX.get(model_dir.name, _MAX_TOKENS)
|
| 120 |
+
for start, end, keep_from, keep_to in _windows(len(ids), max_tokens):
|
| 121 |
+
chunk = [bos] + ids[start:end] + [eos]
|
| 122 |
+
input_ids = np.array([chunk], dtype=np.int64)
|
| 123 |
+
attention = np.ones_like(input_ids)
|
| 124 |
+
(logits,) = session.run(
|
| 125 |
+
None, {"input_ids": input_ids, "attention_mask": attention}
|
| 126 |
+
)
|
| 127 |
+
pred = logits[0].argmax(axis=-1) # (len(chunk),)
|
| 128 |
+
for i in range(keep_from, keep_to):
|
| 129 |
+
labels[i] = id2label[int(pred[i - start + 1])]
|
| 130 |
+
return offsets, labels
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def detect_raw(text: str, model_dir: Path = MODEL_DIR,
|
| 134 |
+
label_map: dict | None = None) -> list[dict]:
|
| 135 |
+
"""Spans BIO decodes, labels modele mappes vers les types benchmark."""
|
| 136 |
+
label_map = LABEL_MAP if label_map is None else label_map
|
| 137 |
+
offsets, labels = _token_labels(text, model_dir)
|
| 138 |
+
spans = []
|
| 139 |
+
cur = None # [start, end, type]
|
| 140 |
+
for (tok_s, tok_e), label in zip(offsets, labels):
|
| 141 |
+
if label is None or label == "O" or tok_s == tok_e:
|
| 142 |
+
cur = None
|
| 143 |
+
continue
|
| 144 |
+
prefix, _, etype = label.partition("-")
|
| 145 |
+
etype = label_map.get(etype, etype)
|
| 146 |
+
if cur is not None and etype == cur[2] and prefix == "I":
|
| 147 |
+
cur[1] = tok_e
|
| 148 |
+
else:
|
| 149 |
+
cur = [tok_s, tok_e, etype]
|
| 150 |
+
spans.append(cur)
|
| 151 |
+
|
| 152 |
+
# recalage sur les frontieres de mots : le modele coupe parfois en plein
|
| 153 |
+
# sous-token ("Arthur Sam|son") et un nom a moitie masque est une fuite
|
| 154 |
+
for s in spans:
|
| 155 |
+
while s[0] > 0 and text[s[0]].isalnum() and text[s[0] - 1].isalnum():
|
| 156 |
+
s[0] -= 1
|
| 157 |
+
while s[1] < len(text) and text[s[1] - 1].isalnum() and text[s[1]].isalnum():
|
| 158 |
+
s[1] += 1
|
| 159 |
+
|
| 160 |
+
# fusion des spans adjacents de meme type (Prenom + Nom, montant + devise)
|
| 161 |
+
merged: list[list] = []
|
| 162 |
+
for s in spans:
|
| 163 |
+
if (merged and merged[-1][2] == s[2]
|
| 164 |
+
and merged[-1][1] >= s[0] - len(text[merged[-1][1]:s[0]])
|
| 165 |
+
and set(text[merged[-1][1]:s[0]]) <= _JOIN_CHARS):
|
| 166 |
+
merged[-1][1] = max(merged[-1][1], s[1])
|
| 167 |
+
else:
|
| 168 |
+
merged.append(s)
|
| 169 |
+
|
| 170 |
+
return [
|
| 171 |
+
{"start": s, "end": e, "type": t, "value": text[s:e]}
|
| 172 |
+
for s, e, t in merged
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
_MIXED_CASE = re.compile(r"\b[^\W\d_]+\b")
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def repair_case(text: str) -> str:
|
| 180 |
+
"""Normalise les tokens a casse suspecte ("ArtHur", "FerRand", "MARÉChAL"
|
| 181 |
+
-> "Arthur", "Ferrand", "Maréchal"), longueur conservee. Les formes
|
| 182 |
+
legitimes (minuscules, MAJUSCULES, Capitalise) ne sont pas touchees."""
|
| 183 |
+
out = list(text)
|
| 184 |
+
for m in _MIXED_CASE.finditer(text):
|
| 185 |
+
tok = m.group(0)
|
| 186 |
+
if len(tok) < 3 or tok.islower() or tok.isupper() or tok.istitle():
|
| 187 |
+
continue
|
| 188 |
+
out[m.start():m.end()] = tok[0].upper() + tok[1:].lower()
|
| 189 |
+
return "".join(out)
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
def detect(text: str, model_dir: Path = MODEL_DIR,
|
| 193 |
+
label_map: dict | None = None) -> list[dict]:
|
| 194 |
+
"""detect_raw + seconde passe sur le texte a casse reparee (bruit OCR).
|
| 195 |
+
|
| 196 |
+
La reparation conserve la longueur : les offsets sont communs. Les spans
|
| 197 |
+
de la seconde passe ne sont ajoutes que s'ils ne chevauchent rien, avec
|
| 198 |
+
la surface du texte d'origine.
|
| 199 |
+
"""
|
| 200 |
+
spans = detect_raw(text, model_dir, label_map)
|
| 201 |
+
repaired = repair_case(text)
|
| 202 |
+
if repaired != text:
|
| 203 |
+
occupied = set()
|
| 204 |
+
for s in spans:
|
| 205 |
+
occupied.update(range(s["start"], s["end"]))
|
| 206 |
+
for s in detect_raw(repaired, model_dir, label_map):
|
| 207 |
+
rng = set(range(s["start"], s["end"]))
|
| 208 |
+
if rng & occupied:
|
| 209 |
+
continue
|
| 210 |
+
occupied |= rng
|
| 211 |
+
s["value"] = text[s["start"]:s["end"]]
|
| 212 |
+
spans.append(s)
|
| 213 |
+
spans.sort(key=lambda s: s["start"])
|
| 214 |
+
return spans
|
| 215 |
+
|
| 216 |
+
|
| 217 |
+
def detect_generic(text: str) -> list[dict]:
|
| 218 |
+
"""camembert-ner generique (Jean-Baptiste), notre export ONNX int8.
|
| 219 |
+
|
| 220 |
+
Mesure bench_v0 : PERSON 0,5 % de fuite (vs 20 % pour Anonym-IA V2),
|
| 221 |
+
CITY 0,25 %, robuste OCR. C'est le meilleur moteur PERSON/CITY connu.
|
| 222 |
+
"""
|
| 223 |
+
return detect(text, MODELS / "camembert-ner", LABEL_MAP_GENERIC)
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
# types conserves du fine-tune metier : ceux ou il apporte quelque chose.
|
| 227 |
+
# Les types a format sont le territoire de la regex (~0 % de fuite) ; le
|
| 228 |
+
# modele y produit des faux positifs de biais de distribution ("3 000
|
| 229 |
+
# mètres" -> AMOUNT, "1975" -> DATE_BIRTH : dans son corpus, tous les
|
| 230 |
+
# nombres etaient des PII). MAIS il rattrape des formats bruites OCR que la
|
| 231 |
+
# regex rate : on garde donc ses spans de format AVEC une confirmation
|
| 232 |
+
# faible (un indice minimal du format, tolerant au bruit).
|
| 233 |
+
NOIRCI_TYPES = {"COMPANY", "ADDRESS", "PERSON", "CITY", "CADASTRE"}
|
| 234 |
+
NOIRCI_CONFIRM = {
|
| 235 |
+
"AMOUNT": re.compile(r"€|eur", re.IGNORECASE),
|
| 236 |
+
"DATE": re.compile(r"\d[/.]\d|janv|f[ée]vr|mars|avril|mai|juin|juil|ao[uû]|sept|oct|nov|d[ée]c", re.IGNORECASE),
|
| 237 |
+
"DATE_BIRTH": re.compile(r"\d[/.]\d|janv|f[ée]vr|mars|avril|mai|juin|juil|ao[uû]|sept|oct|nov|d[ée]c", re.IGNORECASE),
|
| 238 |
+
"PLATE": re.compile(r"[A-Za-z]{2}.?\d{3}.?[A-Za-z]{2}|\d{3} ?[A-Za-z]{3}"),
|
| 239 |
+
"TVA": re.compile(r"^[\sF]*[FR]", re.IGNORECASE),
|
| 240 |
+
"PHONE": re.compile(r"^\D*(?:\+33|0[0-9lO])"),
|
| 241 |
+
"IBAN": re.compile(r"[A-Za-z]{2}\d{2}"),
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
|
| 245 |
+
def detect_noirci(text: str) -> list[dict]:
|
| 246 |
+
"""NOTRE fine-tune (DistilCamemBERT, corpus 100k v3, labels = nos types).
|
| 247 |
+
|
| 248 |
+
Mesure 2026-07-29 : COMPANY 7,7 % de fuite sur bench_realvals (44,6 %
|
| 249 |
+
pour le pipeline sans lui), 0 % sur bench_real_v0. Faible hors documents
|
| 250 |
+
metier (wikiner) : il joue le role de moteur COMPANY + filet metier,
|
| 251 |
+
JAMAIS seul — camembert-ner garde PERSON/CITY, la regex garde les
|
| 252 |
+
formats (voir NOIRCI_TYPES).
|
| 253 |
+
"""
|
| 254 |
+
spans = detect(text, MODELS / "onnx-pii-v14-base", label_map={})
|
| 255 |
+
kept = []
|
| 256 |
+
for s in spans:
|
| 257 |
+
if s["type"] in NOIRCI_TYPES:
|
| 258 |
+
kept.append(s)
|
| 259 |
+
elif s["type"] in NOIRCI_CONFIRM and NOIRCI_CONFIRM[s["type"]].search(s["value"]):
|
| 260 |
+
kept.append(s)
|
| 261 |
+
return kept
|
|
@@ -0,0 +1,222 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Propagation document-entier des personnes detectees (analyse §3.1).
|
| 2 |
+
|
| 3 |
+
Le piege n°1 du juridique : le NER trouve "Jean Dupont" phrase 1, mais rate
|
| 4 |
+
"DUPONT", "M. Dupont" ou "J. Dupont" phrase 12 — et un nom seul qui passe en
|
| 5 |
+
clair est une fuite. Cette passe deterministe prend les PERSON deja detectees
|
| 6 |
+
et cherche leurs variantes de surface dans tout le document.
|
| 7 |
+
|
| 8 |
+
Garde-fou : beaucoup de patronymes francais sont des mots communs (Petit,
|
| 9 |
+
Blanc, Roy). On ne matche JAMAIS en minuscules : uniquement la forme
|
| 10 |
+
capitalisee exacte ("Dupont"), le tout-majuscules ("DUPONT"), leurs versions
|
| 11 |
+
sans accents, precedees ou non d'un titre et/ou d'une initiale. Un faux
|
| 12 |
+
positif sur "M. Petit" en tete de phrase reste du sur-masquage benin.
|
| 13 |
+
|
| 14 |
+
Cette normalisation est le socle du moteur de reversibilite (meme valeur ->
|
| 15 |
+
meme jeton) : les variantes propagees ici partageront le jeton PERSON_n.
|
| 16 |
+
"""
|
| 17 |
+
|
| 18 |
+
import re
|
| 19 |
+
import unicodedata
|
| 20 |
+
|
| 21 |
+
_TITLES = r"(?:M\.|Mme|Mlle|Me|Dr|Monsieur|Madame|Maître|Maitre)"
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
def _strip_accents(s: str) -> str:
|
| 25 |
+
return "".join(c for c in unicodedata.normalize("NFD", s)
|
| 26 |
+
if unicodedata.category(c) != "Mn")
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _name_parts(value: str) -> tuple[str | None, str | None]:
|
| 30 |
+
"""(prenom, nom) depuis la surface d'un span PERSON, titres exclus."""
|
| 31 |
+
tokens = [t for t in re.split(r"[\s]+", value.strip())
|
| 32 |
+
if t and not re.fullmatch(_TITLES, t)]
|
| 33 |
+
tokens = [t for t in tokens if re.fullmatch(r"[^\W\d_].*", t)]
|
| 34 |
+
if not tokens:
|
| 35 |
+
return None, None
|
| 36 |
+
if len(tokens) == 1:
|
| 37 |
+
return None, tokens[0]
|
| 38 |
+
return tokens[0], tokens[-1]
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
def _variant_pattern(first: str | None, last: str) -> str:
|
| 42 |
+
"""Regex des variantes plausibles d'une personne, jamais en minuscules."""
|
| 43 |
+
last_forms = {re.escape(last), re.escape(last.upper())}
|
| 44 |
+
stripped = _strip_accents(last)
|
| 45 |
+
last_forms |= {re.escape(stripped), re.escape(stripped.upper())}
|
| 46 |
+
lasts = "|".join(sorted(last_forms, key=len, reverse=True))
|
| 47 |
+
|
| 48 |
+
initial = ""
|
| 49 |
+
if first:
|
| 50 |
+
initial = rf"(?:{re.escape(first[0].upper())}\.\s*)?"
|
| 51 |
+
first_forms = {re.escape(first), re.escape(first.upper())}
|
| 52 |
+
firsts = "|".join(sorted(first_forms, key=len, reverse=True))
|
| 53 |
+
initial = rf"(?:(?:{firsts})\s+|{re.escape(first[0].upper())}\.\s*)?"
|
| 54 |
+
|
| 55 |
+
return rf"(?:{_TITLES}\s+)?{initial}(?:{lasts})\b"
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
def _fold(s: str) -> str:
|
| 59 |
+
"""Repli casse + accents en preservant la LONGUEUR : indispensable pour
|
| 60 |
+
que les offsets trouves dans la version repliee soient valables dans le
|
| 61 |
+
texte d'origine."""
|
| 62 |
+
out = []
|
| 63 |
+
for ch in s:
|
| 64 |
+
d = unicodedata.normalize("NFD", ch)
|
| 65 |
+
base = "".join(c for c in d if unicodedata.category(c) != "Mn")
|
| 66 |
+
out.append((base[0] if base else ch).lower())
|
| 67 |
+
return "".join(out)
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def propagate_exact(text: str, spans: list[dict],
|
| 71 |
+
types=("COMPANY", "CITY", "ADDRESS")) -> list[dict]:
|
| 72 |
+
"""Coherence intra-document : toute mention d'une valeur deja detectee
|
| 73 |
+
ailleurs dans le document est masquee aussi.
|
| 74 |
+
|
| 75 |
+
Audit emails reels 2026-07-29 : la meme societe etait prise a sa 1re
|
| 76 |
+
occurrence et ratee aux suivantes (ou l'inverse) — ~15 fuites COMPANY
|
| 77 |
+
recuperables sans modele.
|
| 78 |
+
|
| 79 |
+
Residu 2026-07-31 : une meme societe ecrite « Vegetalents » a la ligne 3
|
| 80 |
+
et « VEGETALENTS » dans la signature echappait au match exact. On replie
|
| 81 |
+
donc casse et accents. Garde-fou contre le sur-masquage : la mention
|
| 82 |
+
retrouvee doit porter au moins une majuscule, sinon un nom propre
|
| 83 |
+
homographe d'un mot commun ferait masquer le mot commun.
|
| 84 |
+
"""
|
| 85 |
+
occupied = set()
|
| 86 |
+
for s in spans:
|
| 87 |
+
occupied.update(range(s["start"], s["end"]))
|
| 88 |
+
|
| 89 |
+
values = {}
|
| 90 |
+
for s in spans:
|
| 91 |
+
v = s["value"].strip()
|
| 92 |
+
if s["type"] in types and len(v) >= 4 and not v.isdigit():
|
| 93 |
+
values.setdefault(v, s["type"])
|
| 94 |
+
|
| 95 |
+
folded_text = _fold(text)
|
| 96 |
+
extra = []
|
| 97 |
+
for value, etype in values.items():
|
| 98 |
+
needle = _fold(value)
|
| 99 |
+
start = 0
|
| 100 |
+
while True:
|
| 101 |
+
i = folded_text.find(needle, start)
|
| 102 |
+
if i < 0:
|
| 103 |
+
break
|
| 104 |
+
start = i + 1
|
| 105 |
+
j = i + len(value)
|
| 106 |
+
rng = set(range(i, j))
|
| 107 |
+
if rng & occupied:
|
| 108 |
+
continue
|
| 109 |
+
# frontieres de mot
|
| 110 |
+
if i > 0 and text[i - 1].isalnum():
|
| 111 |
+
continue
|
| 112 |
+
if j < len(text) and text[j].isalnum():
|
| 113 |
+
continue
|
| 114 |
+
surface = text[i:j]
|
| 115 |
+
if surface != value and not any(c.isupper() for c in surface):
|
| 116 |
+
continue
|
| 117 |
+
occupied |= rng
|
| 118 |
+
extra.append({"start": i, "end": j, "type": etype,
|
| 119 |
+
"value": surface})
|
| 120 |
+
return extra
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def propagate(text: str, spans: list[dict]) -> list[dict]:
|
| 124 |
+
"""Retourne les mentions supplementaires de personnes deja detectees."""
|
| 125 |
+
persons = [s for s in spans if s["type"] == "PERSON"]
|
| 126 |
+
if not persons:
|
| 127 |
+
return []
|
| 128 |
+
|
| 129 |
+
occupied = set()
|
| 130 |
+
for s in spans:
|
| 131 |
+
occupied.update(range(s["start"], s["end"]))
|
| 132 |
+
|
| 133 |
+
extra = []
|
| 134 |
+
seen_patterns = set()
|
| 135 |
+
for p in persons:
|
| 136 |
+
first, last = _name_parts(p["value"])
|
| 137 |
+
if last is None or len(last) < 3:
|
| 138 |
+
continue
|
| 139 |
+
pattern = _variant_pattern(first, last)
|
| 140 |
+
if pattern in seen_patterns:
|
| 141 |
+
continue
|
| 142 |
+
seen_patterns.add(pattern)
|
| 143 |
+
for m in re.finditer(pattern, text):
|
| 144 |
+
rng = set(range(m.start(), m.end()))
|
| 145 |
+
if rng & occupied:
|
| 146 |
+
continue
|
| 147 |
+
occupied |= rng
|
| 148 |
+
extra.append({"start": m.start(), "end": m.end(),
|
| 149 |
+
"type": "PERSON", "value": m.group(0)})
|
| 150 |
+
return extra
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
# --- Enumerations ---------------------------------------------------------
|
| 154 |
+
# Residu 2026-07-31 : les societes ratees sont des mots uniques sans forme
|
| 155 |
+
# juridique ni declencheur (EBP, Sage, Pennylane, GoCardless). Le modele en
|
| 156 |
+
# attrape une sur trois dans « on a compare EBP, Pennylane et Sage » : les
|
| 157 |
+
# voisins d'une liste partagent le type de leur ancre.
|
| 158 |
+
|
| 159 |
+
_ITEM = r"[A-ZÀ-ÖØ-Þ][\wÀ-ÿ&'’.-]*(?:[ -][A-ZÀ-ÖØ-Þ0-9][\wÀ-ÿ&'’.-]*){0,2}"
|
| 160 |
+
_LISTE = re.compile(
|
| 161 |
+
rf"{_ITEM}(?:\s*,\s*{_ITEM})*(?:\s*,\s*|\s+(?:et|ou)\s+){_ITEM}")
|
| 162 |
+
_SEP = re.compile(r"\s*,\s*|\s+(?:et|ou)\s+")
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def propagate_enumerations(text: str, spans: list[dict],
|
| 166 |
+
types=("COMPANY",)) -> list[dict]:
|
| 167 |
+
"""Dans une liste d'elements capitalises, si un element est deja typé,
|
| 168 |
+
les autres heritent du meme type.
|
| 169 |
+
|
| 170 |
+
Garde-fous : la liste doit compter au moins trois elements (deux suffit
|
| 171 |
+
a produire des faux positifs sur « Bonjour Marc, Pennylane »), l'ancre
|
| 172 |
+
doit couvrir un element entier, et un element deja detecte sous un autre
|
| 173 |
+
type bloque toute la liste (une enumeration de personnes ne doit jamais
|
| 174 |
+
basculer en societes).
|
| 175 |
+
"""
|
| 176 |
+
if not any(s["type"] in types for s in spans):
|
| 177 |
+
return []
|
| 178 |
+
|
| 179 |
+
par_pos = {}
|
| 180 |
+
for s in spans:
|
| 181 |
+
for k in range(s["start"], s["end"]):
|
| 182 |
+
par_pos[k] = s["type"]
|
| 183 |
+
|
| 184 |
+
extra = []
|
| 185 |
+
for m in _LISTE.finditer(text):
|
| 186 |
+
items, pos = [], m.start()
|
| 187 |
+
for part in _SEP.split(m.group(0)):
|
| 188 |
+
i = text.find(part, pos)
|
| 189 |
+
if i < 0:
|
| 190 |
+
continue
|
| 191 |
+
items.append((i, i + len(part), part))
|
| 192 |
+
pos = i + len(part)
|
| 193 |
+
if len(items) < 3:
|
| 194 |
+
continue
|
| 195 |
+
|
| 196 |
+
vus = {par_pos.get(k) for i, j, _ in items for k in range(i, j)}
|
| 197 |
+
ancres = vus & set(types)
|
| 198 |
+
if not ancres or (vus - {None} - set(types)):
|
| 199 |
+
continue
|
| 200 |
+
etype = sorted(ancres)[0]
|
| 201 |
+
|
| 202 |
+
for i, j, part in items:
|
| 203 |
+
if any(k in par_pos for k in range(i, j)):
|
| 204 |
+
continue
|
| 205 |
+
if len(part) < 3 or _norm_common(part):
|
| 206 |
+
continue
|
| 207 |
+
for k in range(i, j):
|
| 208 |
+
par_pos[k] = etype
|
| 209 |
+
extra.append({"start": i, "end": j, "type": etype, "value": part})
|
| 210 |
+
return extra
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
_MOTS_LISTE = {
|
| 214 |
+
"bonjour", "bonsoir", "merci", "cordialement", "salut", "madame",
|
| 215 |
+
"monsieur", "oui", "non", "ok", "bien", "donc", "mais", "puis",
|
| 216 |
+
"ensuite", "enfin", "voila", "aussi", "encore", "toujours", "jamais",
|
| 217 |
+
}
|
| 218 |
+
|
| 219 |
+
|
| 220 |
+
def _norm_common(part: str) -> bool:
|
| 221 |
+
base = _strip_accents(part).lower().strip(".,;:!?)")
|
| 222 |
+
return base in _MOTS_LISTE
|
|
@@ -0,0 +1,377 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Couche A : detection deterministe regex + checksums (analyse §2.A).
|
| 2 |
+
|
| 3 |
+
Regle de decision (2026-07-28) :
|
| 4 |
+
- Les patterns AVEC checksum (IBAN, NIR, SIREN/SIRET, TVA, CB) decident seuls :
|
| 5 |
+
un match syntaxique dont le checksum est valide est retenu, point.
|
| 6 |
+
- Email, IP (octets valides), plaque SIV (AA-123-BC), cadastre ("section X
|
| 7 |
+
n° N" porte son contexte) decident seuls aussi : formats assez distinctifs.
|
| 8 |
+
- Les patterns SANS checksum ni format fort (telephone compact 10 chiffres,
|
| 9 |
+
n° RG, ancienne plaque 123 ABC 75) exigent un mot de contexte dans les
|
| 10 |
+
30 caracteres precedents. Un telephone +33 ou avec separateurs decide seul.
|
| 11 |
+
|
| 12 |
+
Resolution de chevauchements : le span le plus long gagne (un CB 4x4 matche
|
| 13 |
+
dans un IBAN groupe par 4 ; le SIREN vit dans le SIRET et la TVA).
|
| 14 |
+
|
| 15 |
+
Pre-normalisation OCR : les confusions classiques (O/0, l/1, S/5, B/8) sont
|
| 16 |
+
corrigees token par token selon la dominante du token (lettres ou chiffres),
|
| 17 |
+
puis la detection tourne sur le texte d'origine ET sur la forme normalisee
|
| 18 |
+
(meme longueur, memes offsets). Le checksum reste le juge : un token corrige
|
| 19 |
+
qui ne valide pas n'est pas retenu. Voir doc/memory/matrice_comparaison.md.
|
| 20 |
+
|
| 21 |
+
Sortie : liste de spans au format du harness. Ce module servira tel quel de
|
| 22 |
+
couche A du produit ; ici il est branche sur le benchmark comme premier
|
| 23 |
+
candidat de la matrice de comparaison (§5.3).
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
import re
|
| 27 |
+
|
| 28 |
+
from bench.pii import checksums as ck
|
| 29 |
+
|
| 30 |
+
_CONTEXT_WINDOW = 30
|
| 31 |
+
|
| 32 |
+
_PATTERNS: list[tuple[str, re.Pattern, str | None]] = []
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def _p(etype: str, pattern: str, context: str | None = None, flags: int = 0):
|
| 36 |
+
_PATTERNS.append((etype, re.compile(pattern, flags), context))
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
# --- checksum : decident seuls -------------------------------------------
|
| 40 |
+
_p("IBAN", r"\b[A-Z]{2}\d{2}(?: ?[A-Z0-9]{4}){2,7}(?: ?[A-Z0-9]{1,3})?\b")
|
| 41 |
+
_p("NIR", r"\b[12](?: ?\d{2}){2} ?(?:\d{2}|2A|2B)(?: ?\d{3}){2} ?\d{2}\b")
|
| 42 |
+
_p("SIRET", r"\b\d{3} ?\d{3} ?\d{3} ?\d{5}\b")
|
| 43 |
+
_p("TVA", r"\bFR ?\d{2} ?\d{3} ?\d{3} ?\d{3}\b")
|
| 44 |
+
_p("SIREN", r"\b\d{3} ?\d{3} ?\d{3}\b")
|
| 45 |
+
_p("CARD", r"\b\d{4}(?: ?\d{4}){3}\b")
|
| 46 |
+
|
| 47 |
+
_VALIDATORS = {
|
| 48 |
+
"IBAN": ck.iban_valid,
|
| 49 |
+
"NIR": ck.nir_valid,
|
| 50 |
+
"SIRET": lambda s: ck.siret_valid(s.replace(" ", "")),
|
| 51 |
+
"TVA": ck.tva_fr_valid,
|
| 52 |
+
"SIREN": lambda s: ck.siren_valid(s.replace(" ", "")),
|
| 53 |
+
"CARD": lambda s: ck.luhn_valid(s.replace(" ", "")),
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
# --- format fort : decident seuls ----------------------------------------
|
| 57 |
+
_p("EMAIL", r"\b[\w.+-]+@[\w-]+\.[\w.]{1,10}\b")
|
| 58 |
+
_p("PLATE", r"\b[A-Z]{2}-\d{3}-[A-Z]{2}\b", flags=re.IGNORECASE)
|
| 59 |
+
_p("CADASTRE", r"\bsection [A-Z]{1,2} n° ?\d{1,3}\b", flags=re.IGNORECASE)
|
| 60 |
+
_p("ADDRESS", r"\b(?:CS|BP|TSA|CEDEX) ?\d{2,6}\b")
|
| 61 |
+
_p("IP", r"\b(?:\d{1,3}\.){3}\d{1,3}\b")
|
| 62 |
+
_p("PHONE", r"(?:\+33|0033) ?[1-9](?:[ .]?\d{2}){4}\b")
|
| 63 |
+
_p("PHONE", r"\b0[1-9](?:[ .]\d{2}){4}\b")
|
| 64 |
+
# formats internationaux reels (audit emails 2026-07-29) : "+33(0)1 23...",
|
| 65 |
+
# "+ 33 6...", numeros belges/lux/suisses, groupements irreguliers
|
| 66 |
+
_p("PHONE", r"\+ ?\d{2,3} ?\(0\) ?\d(?:[ .]?\d{2,3}){3,5}\b")
|
| 67 |
+
_p("PHONE", r"\+ ?\d{2,3}(?:[ .]?\d{2,3}){4,6}\b")
|
| 68 |
+
_p("PHONE", r"\+ ?\d{2,3} ?\d(?:[ .]?\d{2}){4}\b")
|
| 69 |
+
# formats etrangers a groupes irreguliers (+32 471 12 34 56, +41 79 123 45 67)
|
| 70 |
+
_p("PHONE", r"\+ ?\d{2,3}(?:[ .]\d{2,4}){3,5}\b")
|
| 71 |
+
|
| 72 |
+
# URLs : angle mort releve par l'audit emails (3 liens porteurs de jetons
|
| 73 |
+
# jamais captures). Type URL, maskable par politique ; les liens avec longs
|
| 74 |
+
# segments aleatoires (jetons) sont le vrai danger.
|
| 75 |
+
_p("URL", r"\bhttps?://[^\s<>\"')\]]+")
|
| 76 |
+
_p("URL", r"\bwww\.[\w.-]+\.[a-z]{2,6}\b", flags=re.IGNORECASE)
|
| 77 |
+
# Domaines nus, sans schema ni www : « app.easywage.fr », « console.mistral.ai ».
|
| 78 |
+
# Audit du 31/07 : 16 des 21 URL non protegees etaient de cette forme. La
|
| 79 |
+
# liste de TLD evite d'avaler « document.pdf » ou « fichier.tar.gz ».
|
| 80 |
+
_TLD = (r"fr|com|net|org|io|dev|app|eu|be|ch|lu|ca|ai|co|me|tech|cloud|"
|
| 81 |
+
r"info|biz|shop|store|agency|studio|solutions|consulting")
|
| 82 |
+
_p("URL", rf"\b(?<![@\w.])[a-z0-9][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*"
|
| 83 |
+
rf"\.(?:{_TLD})\b(?:/[^\s<>\"')\]]*[^\s<>\"')\].,;:!?])?", flags=re.IGNORECASE)
|
| 84 |
+
|
| 85 |
+
# Telephones internationaux espaces et format nord-americain.
|
| 86 |
+
_p("PHONE", r"\(\+ ?\d{1,3}\) ?\d(?:[ .]?\d{2,3}){3,5}\b")
|
| 87 |
+
_p("PHONE", r"\b\d{3}-\d{3}-\d{4}\b")
|
| 88 |
+
# indicatif puis groupes de longueur libre : « + 32 2 808 66 05 »
|
| 89 |
+
_p("PHONE", r"\+ ?\d{2,3}(?: \d{1,4}){3,6}\b")
|
| 90 |
+
|
| 91 |
+
# Identifiants techniques : un UUID est toujours une reference opaque.
|
| 92 |
+
_p("REF", r"\b[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\b",
|
| 93 |
+
flags=re.IGNORECASE)
|
| 94 |
+
|
| 95 |
+
# --- formats etendus (pas des identifiants, mais deterministes) ----------
|
| 96 |
+
# Le NER (Anonym-IA V2) ignore quasi totalement dates et montants sur notre
|
| 97 |
+
# benchmark (~98 % de fuite) : on les prend en regex. Sur-masquage assume :
|
| 98 |
+
# masquer une date non personnelle est benin, la rater ne l'est pas.
|
| 99 |
+
_MOIS = ("janvier|février|fevrier|mars|avril|mai|juin|juillet|août|aout|"
|
| 100 |
+
"septembre|octobre|novembre|décembre|decembre")
|
| 101 |
+
_p("DATE", r"\b\d{1,2}[/.]\d{1,2}[/.]\d{2,4}\b")
|
| 102 |
+
# dates sans annee "12/07" (contexte le/du/au) et mois anglais (titres de
|
| 103 |
+
# reunions exportees) — audit emails 2026-07-29
|
| 104 |
+
_p("DATE", r"\b\d{1,2}/\d{1,2}\b")
|
| 105 |
+
_p("DATE", r"\b\d{1,2}\.\d{1,2}\b", context=r"\ble\b|\bdu\b|\bau\b|\bdès\b|avant|depuis|jusqu")
|
| 106 |
+
_MOIS_EN = "January|February|March|April|May|June|July|August|September|October|November|December"
|
| 107 |
+
_p("DATE", rf"\b\d{{1,2}} (?:{_MOIS_EN}) \d{{4}}\b", flags=re.IGNORECASE)
|
| 108 |
+
_p("DATE", rf"\b(?:{_MOIS}) \d{{4}}\b", flags=re.IGNORECASE)
|
| 109 |
+
_JOURS = "lundi|mardi|mercredi|jeudi|vendredi|samedi|dimanche"
|
| 110 |
+
_p("DATE", rf"\b(?:{_JOURS}) \d{{1,2}}(?: (?:{_MOIS}))?\b", flags=re.IGNORECASE)
|
| 111 |
+
_p("DATE", rf"\b\d{{1,2}}(?:er)? (?:{_MOIS}) \d{{4}}\b", flags=re.IGNORECASE)
|
| 112 |
+
# Dates sans annee et mois seuls. Audit du 31/07 : DATE fuyait a 42,9 % sur
|
| 113 |
+
# la correspondance reelle, uniquement sur ces formes-la. « le 17 juin »,
|
| 114 |
+
# « courant juillet », « en 2025 » sont des dates aux yeux de l'annotation.
|
| 115 |
+
_p("DATE", rf"\b\d{{1,2}}(?:er)? (?:{_MOIS})\b", flags=re.IGNORECASE)
|
| 116 |
+
_p("DATE", rf"\b\d{{1,2}} ?[-–—] ?\d{{1,2}} (?:{_MOIS})\b", flags=re.IGNORECASE)
|
| 117 |
+
_p("DATE", rf"\b(?:{_MOIS})\b", flags=re.IGNORECASE)
|
| 118 |
+
_p("DATE", r"(?<![-/\w])(?:19|20)\d{2}(?![-/\d])")
|
| 119 |
+
|
| 120 |
+
# Montants. Le motif d'origine exigeait un symbole euro APRES le nombre, d'ou
|
| 121 |
+
# 54 % de fuite : il ratait les francs suisses (« CHF 49.- », « CHF 8'450 »),
|
| 122 |
+
# les magnitudes (« 30K€ », « 847 M€ ») et les fourchettes (« 20 a 30 k€ »).
|
| 123 |
+
_DEVISE = r"€|euros?\b|EUR\b|CHF\b|\$|USD\b|£|GBP\b"
|
| 124 |
+
_NOMBRE = r"\d{1,3}(?:[ .' ]\d{3})+|\d+"
|
| 125 |
+
_ECHELLE = r"\s?(?:[kKmM]|[Mm]illions?|[Mm]illiards?)"
|
| 126 |
+
|
| 127 |
+
# devise en tete : « CHF 8'450 », « CHF 49.- », « CHF - 6.00 », « $ 1 200 »
|
| 128 |
+
_p("AMOUNT", rf"(?:{_DEVISE})\s?-?\s?(?:{_NOMBRE}|X)(?:[.,]\d{{1,3}}|\.-{{1,2}})?"
|
| 129 |
+
rf"(?:{_ECHELLE})?", flags=re.IGNORECASE)
|
| 130 |
+
# devise en queue, avec echelle optionnelle : « 30K€ », « 847 M€ », « 1 200 € »
|
| 131 |
+
_p("AMOUNT", rf"\b(?:{_NOMBRE})(?:[.,]\d{{1,3}})?(?:{_ECHELLE})?\s?(?:{_DEVISE})",
|
| 132 |
+
flags=re.IGNORECASE)
|
| 133 |
+
# fourchettes : « 20 a 30 k€ », « 200-250 € », « 1 600–1 700 € »
|
| 134 |
+
_p("AMOUNT", rf"\b(?:{_NOMBRE})(?:[.,]\d{{1,2}})?(?:{_ECHELLE})?\s?"
|
| 135 |
+
rf"(?:a|à|-|–|—|et)\s?(?:{_NOMBRE})(?:[.,]\d{{1,2}})?"
|
| 136 |
+
rf"(?:{_ECHELLE})?\s?(?:{_DEVISE})", flags=re.IGNORECASE)
|
| 137 |
+
# periodicite collee au montant : « CHF 49/mois », « 1 200 € par an »
|
| 138 |
+
_p("AMOUNT", rf"(?:{_DEVISE})\s?(?:{_NOMBRE})(?:[.,]\d{{1,3}})?\s?/\s?"
|
| 139 |
+
rf"(?:mois|an|jour|semaine|h|heure|utilisateur|poste)\b", flags=re.IGNORECASE)
|
| 140 |
+
# echelle ecrite en toutes lettres sans devise : « 6,4 Millions »
|
| 141 |
+
_p("AMOUNT", r"\b\d{1,3}(?:[.,]\d{1,3})? ?(?:[Mm]illions?|[Mm]illiards?)\b")
|
| 142 |
+
|
| 143 |
+
# nombre a deux decimales dans un contexte comptable : lignes de facture
|
| 144 |
+
_p("AMOUNT", r"\b\d{1,3}(?:[ .']\d{3})*[.,]\d{2}\b",
|
| 145 |
+
context=r"montant|prix|total|facture|co[uû]t|tarif|solde|HT\b|TTC\b|"
|
| 146 |
+
r"honoraires|acompte|remise|net\b|TVA\b|\bpar mois\b|\bmensuel")
|
| 147 |
+
|
| 148 |
+
_p("ADDRESS", r"\b(?:B[âa]timent|B[âa]t\.?|Immeuble|R[ée]sidence|Escalier|Hall|Lot)"
|
| 149 |
+
r" ?[A-Z0-9][\w-]{0,12}\b", flags=re.IGNORECASE)
|
| 150 |
+
|
| 151 |
+
# Recensement du 31/07 : 7 adresses non protegees sur 172, en quatre
|
| 152 |
+
# familles. Le corpus contient de la correspondance suisse et anglo-saxonne.
|
| 153 |
+
_VOIE = (r"rue|avenue|av\.|boulevard|bd\.?|chemin|impasse|all[ée]e|place|"
|
| 154 |
+
r"route|quai|cours|square|villa|passage|sentier|faubourg")
|
| 155 |
+
# ordre suisse et belge : le numero SUIT le nom de voie (« Rue Galilee 4 »)
|
| 156 |
+
_p("ADDRESS", rf"\b(?:{_VOIE})\s+[A-ZÀ-Þ][\wÀ-ÿ'’-]*(?:[ -](?:de|du|des|la|le)"
|
| 157 |
+
rf"|[ -][A-ZÀ-Þ][\wÀ-ÿ'’-]*)*\s+\d{{1,4}}[a-zA-Z]?\b",
|
| 158 |
+
flags=re.IGNORECASE)
|
| 159 |
+
# numero double a la francaise : « 28 / 32 Boulevard », « 12-14 rue »
|
| 160 |
+
_p("ADDRESS", rf"\b\d{{1,4}}\s?[/-]\s?\d{{1,4}}(?:,)? (?:{_VOIE})\b[^\n,;]{{0,40}}",
|
| 161 |
+
flags=re.IGNORECASE)
|
| 162 |
+
# boites postales, France et Suisse
|
| 163 |
+
_p("ADDRESS", r"\b(?:CP|BP|Case postale|Bo[îi]te postale)\s?\d{1,5}\b",
|
| 164 |
+
flags=re.IGNORECASE)
|
| 165 |
+
# code postal britannique : deux blocs, le second toujours chiffre-lettre-lettre
|
| 166 |
+
_p("ADDRESS", r"\b[A-Z]{1,2}\d[A-Z\d]? ?\d[A-Z]{2}\b")
|
| 167 |
+
# etat americain suivi du ZIP : « FL 33180 ». Le ZIP seul serait indistinguable
|
| 168 |
+
# d'un nombre quelconque, on exige donc l'etat.
|
| 169 |
+
_p("ADDRESS", r"\b(?:AL|AK|AZ|AR|CA|CO|CT|DE|FL|GA|HI|ID|IL|IN|IA|KS|KY|LA|ME|"
|
| 170 |
+
r"MD|MA|MI|MN|MS|MO|MT|NE|NV|NH|NJ|NM|NY|NC|ND|OH|OK|OR|PA|RI|SC|"
|
| 171 |
+
r"SD|TN|TX|UT|VT|VA|WA|WV|WI|WY|DC) \d{5}(?:-\d{4})?\b")
|
| 172 |
+
# voie anglo-saxonne : numero, direction optionnelle, ordinal, type de voie
|
| 173 |
+
_p("ADDRESS", r"\b\d{1,5} (?:[NSEW]{1,2} )?[\w'-]+(?:st|nd|rd|th)? "
|
| 174 |
+
r"(?:Street|St\.?|Avenue|Ave\.?|Road|Rd\.?|Drive|Dr\.?|Lane|Ln\.?|"
|
| 175 |
+
r"Boulevard|Blvd\.?|Way|Court|Ct\.?|Place|Pl\.?)"
|
| 176 |
+
r"(?:,? (?:Suite|Ste\.?|Apt\.?|Unit|Floor|Fl\.?) ?#? ?[\w-]+)?",
|
| 177 |
+
flags=re.IGNORECASE)
|
| 178 |
+
|
| 179 |
+
# Adresses FR : "33, rue de Labbé", "7 avenue Luce Marchal", "chemin des Prés".
|
| 180 |
+
# Le NER rate 40 % de nos adresses (matrice 2026-07-28) alors que la
|
| 181 |
+
# structure "n°, type de voie + nom propre" est tres reguliere en francais.
|
| 182 |
+
_VOIES = ("rue|avenue|av\\.|boulevard|bd|chemin|impasse|all[ée]e|place|quai|"
|
| 183 |
+
"route|cours|square|passage|sente|villa|hameau|faubourg|lotissement|"
|
| 184 |
+
"r[ée]sidence")
|
| 185 |
+
_UPPER = "A-ZÀ-ÖØ-Þ"
|
| 186 |
+
_WORD = rf"[{_UPPER}][\w'’-]*"
|
| 187 |
+
_PARTICLE = r"(?:de\s+la\s+|de\s+l[’']\s?|du\s+|des\s+|de\s+|d[’']\s?|la\s+|le\s+|les\s+)"
|
| 188 |
+
# casse : type de voie insensible (Rue/RUE), nom propre exige une majuscule
|
| 189 |
+
# (sinon "rue de la république est calme" avalerait "est" et la suite)
|
| 190 |
+
_p("ADDRESS",
|
| 191 |
+
rf"\b(?:\d{{1,4}}(?:-\d{{1,4}})?\s?(?i:bis|ter)?\s*,?\s+)?(?i:{_VOIES})\s+"
|
| 192 |
+
rf"{_PARTICLE}?{_WORD}(?:\s+{_PARTICLE}?{_WORD}){{0,3}}")
|
| 193 |
+
|
| 194 |
+
# lieux-dits et hameaux (le mot "lieu-dit" porte son contexte)
|
| 195 |
+
_p("ADDRESS", rf"(?i:lieu-dit)\s+{_PARTICLE}?{_WORD}(?:\s+{_PARTICLE}?{_WORD}){{0,3}}")
|
| 196 |
+
|
| 197 |
+
# "N Grande Rue" : voie sans nom propre derriere
|
| 198 |
+
_p("ADDRESS", r"\b\d{1,4},? ?(?i:grande rue)\b")
|
| 199 |
+
|
| 200 |
+
# adresse sans type de voie ("5 Le Gasset", "4 Grande Rue") : uniquement
|
| 201 |
+
# derriere un mot d'adresse ("siège social :", "demeurant", "sis", "habite")
|
| 202 |
+
_p("ADDRESS", rf"\b\d{{1,4}}(?: ?bis| ?ter)?(?: {_WORD}| {_PARTICLE.strip()}){{1,4}}",
|
| 203 |
+
context=(r"siège social|si[eè]ge\b|demeurant|domicili|adresse|r[eé]sidant|"
|
| 204 |
+
r"\bsis(?:e)?\b|habite|logement|\bbien\b|\bau\b|livr|exp[eé]di"))
|
| 205 |
+
|
| 206 |
+
# denomination sociale : "Dénomination : STOLKIN." / "raison sociale : X" —
|
| 207 |
+
# groupe 1 = la valeur seule (le mot-cle n'est pas masque)
|
| 208 |
+
_p("COMPANY",
|
| 209 |
+
r"(?i:(?:dénomination|denomination|raison sociale)(?:\s+sociale)?\s*:\s*)"
|
| 210 |
+
r"([^\n]{2,60}?)(?=\.(?:\s|$)|,|\n|$)")
|
| 211 |
+
|
| 212 |
+
# marques et raisons sociales (remontees bench_v2 / BODACC) :
|
| 213 |
+
_UPWORD = r"[A-ZÀ-ÖØ-Þ][A-ZÀ-ÖØ-Þ0-9&'-]{1,}"
|
| 214 |
+
_FORMES = r"(?:S\.A\.S\.U?|S\.A\.R\.L\.|S\.A\.|SARL|SASU|SAS|SA|SCI|EURL|SNC|SELARL)"
|
| 215 |
+
# 1. style domaine : HOARAU.FR, TOSCA.COM
|
| 216 |
+
_p("COMPANY", r"\b[A-ZÀ-ÖØ-Þ][A-ZÀ-ÖØ-Þ0-9-]{2,}\.(?:FR|COM)\b")
|
| 217 |
+
# 2. nom + forme juridique (la forme sert de contexte porte ; (?!\w) et
|
| 218 |
+
# pas \b : apres "S.A.S." le point n'offre pas de frontiere de mot)
|
| 219 |
+
_p("COMPANY", rf"\b(?:{_UPWORD} |{_WORD} ){{1,4}}{_FORMES}(?!\w)")
|
| 220 |
+
# 3. mot(s) capitalises derriere un declencheur ("l'agence X", "chez X")
|
| 221 |
+
_p("COMPANY",
|
| 222 |
+
rf"\b(?!(?:SIREN|SIRET|RCS|TVA|IBAN|NIR|BIC|URSSAF|DREETS|CSE)\b)"
|
| 223 |
+
rf"{_UPWORD}(?: {_UPWORD}){{0,3}}",
|
| 224 |
+
context=r"soci[eé]t[eé]|agence|entreprise|[eé]tablissements?|maison|cabinet|\bchez\b|\bst[eé]\b")
|
| 225 |
+
# 4. apposition d'annonce legale : "X, société par actions simplifiée..."
|
| 226 |
+
_p("COMPANY",
|
| 227 |
+
rf"\b({_WORD}(?: {_WORD}){{0,3}}|{_UPWORD}(?: {_UPWORD}){{0,3}})"
|
| 228 |
+
rf"(?=, soci[eé]t[eé] (?:par|à|a|anonyme|civile|en))")
|
| 229 |
+
|
| 230 |
+
# code postal FR suivi d'une ville (signatures multi-sites, audit reel)
|
| 231 |
+
_p("ADDRESS", rf"\b(?:0[1-9]|[1-9]\d)\d{{3}}[ ]{_WORD}(?:[- ]{_WORD}){{0,2}}")
|
| 232 |
+
# code postal isole en fin de ligne (signature multi-sites)
|
| 233 |
+
_p("ADDRESS", r"\b(?:0[1-9]|[1-9]\d)\d{3}(?=\s*(?:$|\n|[|/,-]))",
|
| 234 |
+
context=(r"adresse|si[eè]ge|bureaux?|agence|site|locaux|cedex|\bCS\b|\bBP\b|"
|
| 235 |
+
r"rue|avenue|boulevard|chemin|place|route|\|"))
|
| 236 |
+
|
| 237 |
+
# --- types techniques (audit ai4privacy 2026-07-29) : presents dans les
|
| 238 |
+
# logs, exports et emails techniques francais aussi. Regex-ables, sans
|
| 239 |
+
# ambiguite metier.
|
| 240 |
+
|
| 241 |
+
# mot de passe / secret annonce en clair ("mot de passe : xxx", "pwd=xxx")
|
| 242 |
+
_p("SECRET",
|
| 243 |
+
r"(?i:(?:mot de passe|passe|password|pwd|pass|secret|token|api[_ -]?key|"
|
| 244 |
+
r"cl[eé] api|client[_ -]?secret|passphrase)\s*(?:est|:|=)\s*)"
|
| 245 |
+
r"[\"']?([^\s\"'<>,;]{6,80})")
|
| 246 |
+
|
| 247 |
+
# user-agent (navigateur/robot) : signature tres reconnaissable
|
| 248 |
+
_p("USERAGENT", r"Mozilla/\d[^\n]{10,200}")
|
| 249 |
+
_p("USERAGENT", r"\b(?:curl|Wget|PostmanRuntime|python-requests|okhttp|axios)/[\d.]+")
|
| 250 |
+
|
| 251 |
+
# adresses techniques
|
| 252 |
+
_p("MAC", r"\b(?:[0-9A-Fa-f]{2}[:-]){5}[0-9A-Fa-f]{2}\b")
|
| 253 |
+
_p("IPV6", r"\b(?:[0-9A-Fa-f]{1,4}:){2,7}[0-9A-Fa-f]{1,4}\b")
|
| 254 |
+
|
| 255 |
+
# identifiants opaques : cles et jetons longs (base64/hex) annonces ou nus
|
| 256 |
+
_p("SECRET", r"\b(?:sk|pk|rk)_(?:live|test)_[A-Za-z0-9]{16,}\b")
|
| 257 |
+
_p("SECRET", r"\bgh[pousr]_[A-Za-z0-9]{30,}\b")
|
| 258 |
+
_p("SECRET", r"\beyJ[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\.[A-Za-z0-9_-]{10,}\b")
|
| 259 |
+
_p("SECRET", r"\b[0-9a-f]{32,64}\b",
|
| 260 |
+
context=r"cl[eé]|key|token|secret|hash|signature|empreinte|md5|sha")
|
| 261 |
+
|
| 262 |
+
# age en contexte RH/dossier ("45 ans", "age : 45")
|
| 263 |
+
_p("AGE", r"\b\d{1,3} ans\b",
|
| 264 |
+
context=r"[aâ]g[eé]|ann[eé]es|naissance|salari|candidat|patient|enfant|\best\b|\ba\b")
|
| 265 |
+
_p("AGE", r"(?i:[aâ]ge\s*(?::|est de)\s*)(\d{1,3})\b")
|
| 266 |
+
|
| 267 |
+
# IBAN etranger sans checksum FR mais format IBAN valide (deja couvert),
|
| 268 |
+
# et numero de compte annonce ("compte n° 12345678")
|
| 269 |
+
_p("ACCOUNT", r"(?i:(?:compte|account)\s*(?:bancaire\s*)?(?:n°|no|num[eé]ro|#|:)\s*)([0-9]{6,17})")
|
| 270 |
+
|
| 271 |
+
# --- sans checksum : contexte requis -------------------------------------
|
| 272 |
+
_p("PHONE", r"\b0[1-9]\d{8}\b",
|
| 273 |
+
context=r"t[eé]l|portable|mobile|fixe|appel|joign|rappel|contact|num[eé]ro|\bau\b")
|
| 274 |
+
# identifiants internes rattaches a une personne (audit 2026-07-29 :
|
| 275 |
+
# matricule, n° de police, contrat, reference client = PII RGPD)
|
| 276 |
+
_p("REF", r"\b\d{4,8}\b",
|
| 277 |
+
context=(r"matricule|police|contrat|dossier|r[eé]f[eé]rence|r[eé]f\.|"
|
| 278 |
+
r"abonn|adh[eé]rent|client|sinistre|avenant"))
|
| 279 |
+
|
| 280 |
+
_p("RG", r"\b\d{2}/\d{5}\b",
|
| 281 |
+
context=(r"\bRG\b|r[oô]le|r[eé]pertoire|dossier|tribunal|jugement|"
|
| 282 |
+
r"instance|enr[oô]l|audience|greffe|affaire|contentieux"))
|
| 283 |
+
_p("PLATE", r"\b\d{3} [A-Z]{3} \d{2}\b", context=r"immatricul|v[eé]hicule|plaque")
|
| 284 |
+
|
| 285 |
+
|
| 286 |
+
def _ip_valid(s: str) -> bool:
|
| 287 |
+
return all(int(o) <= 255 for o in s.split("."))
|
| 288 |
+
|
| 289 |
+
|
| 290 |
+
_TO_DIGIT = str.maketrans("OolISsBb", "00115588")
|
| 291 |
+
_TO_LETTER = str.maketrans("0158", "olsb")
|
| 292 |
+
_TOKEN_RE = re.compile(r"[A-Za-z0-9]+")
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
def ocr_normalize(text: str) -> str:
|
| 296 |
+
"""Corrige les confusions OCR token par token, longueur conservee.
|
| 297 |
+
|
| 298 |
+
Token a dominante chiffres -> lettres confusables vers chiffres (O->0...).
|
| 299 |
+
Token a dominante lettres -> chiffres confusables vers lettres (0->o...).
|
| 300 |
+
Le checksum/pattern reste le juge en aval : on ne decide rien ici.
|
| 301 |
+
"""
|
| 302 |
+
out = list(text)
|
| 303 |
+
for m in _TOKEN_RE.finditer(text):
|
| 304 |
+
tok = m.group(0)
|
| 305 |
+
if len(tok) < 2:
|
| 306 |
+
continue
|
| 307 |
+
digits = sum(c.isdigit() for c in tok)
|
| 308 |
+
fixed = tok.translate(_TO_DIGIT) if digits * 2 >= len(tok) else tok.translate(_TO_LETTER)
|
| 309 |
+
if fixed != tok:
|
| 310 |
+
out[m.start():m.end()] = fixed
|
| 311 |
+
return "".join(out)
|
| 312 |
+
|
| 313 |
+
|
| 314 |
+
def _scan(text: str, original: str) -> list[dict]:
|
| 315 |
+
candidates = []
|
| 316 |
+
for etype, pattern, context in _PATTERNS:
|
| 317 |
+
for m in pattern.finditer(text):
|
| 318 |
+
# si le pattern a un groupe de capture, le span est le groupe 1
|
| 319 |
+
# (permet un mot-cle declencheur hors masque, ex. "Dénomination :")
|
| 320 |
+
grp = 1 if m.groups() else 0
|
| 321 |
+
value = m.group(grp)
|
| 322 |
+
if not value:
|
| 323 |
+
continue
|
| 324 |
+
if etype in _VALIDATORS and not _VALIDATORS[etype](value):
|
| 325 |
+
continue
|
| 326 |
+
if etype == "IP" and not _ip_valid(value):
|
| 327 |
+
continue
|
| 328 |
+
if context is not None:
|
| 329 |
+
before = text[max(0, m.start() - _CONTEXT_WINDOW):m.start()]
|
| 330 |
+
if not re.search(context, before, re.IGNORECASE):
|
| 331 |
+
continue
|
| 332 |
+
candidates.append(
|
| 333 |
+
{"start": m.start(grp), "end": m.end(grp), "type": etype,
|
| 334 |
+
"value": original[m.start(grp):m.end(grp)]}
|
| 335 |
+
)
|
| 336 |
+
return candidates
|
| 337 |
+
|
| 338 |
+
|
| 339 |
+
def detect(text: str) -> list[dict]:
|
| 340 |
+
# variantes a longueur constante (offsets communs) : correction OCR, et
|
| 341 |
+
# sauts de ligne aplatis — une valeur coupee par un \n (PDF, courrier)
|
| 342 |
+
# doit etre detectee ("MEYER\nTRANSPORTS", "26\nnovembre 2025")
|
| 343 |
+
variants = [text]
|
| 344 |
+
for base in (text, ocr_normalize(text)):
|
| 345 |
+
for v in (base, base.replace("\n", " ")):
|
| 346 |
+
if v not in variants:
|
| 347 |
+
variants.append(v)
|
| 348 |
+
|
| 349 |
+
candidates = _scan(text, text)
|
| 350 |
+
seen = {(c["start"], c["end"], c["type"]) for c in candidates}
|
| 351 |
+
for v in variants[1:]:
|
| 352 |
+
flattened = "\n" in text and "\n" not in v
|
| 353 |
+
for c in _scan(v, text):
|
| 354 |
+
# la passe "sauts de ligne aplatis" ne sert qu'aux valeurs
|
| 355 |
+
# coupees par un \n dans un PDF (identifiants, dates, montants).
|
| 356 |
+
# Sur les types a mots (ADDRESS, COMPANY, CITY) elle recollait
|
| 357 |
+
# deux lignes distinctes ("75011 Paris" + "Tél") — audit reel.
|
| 358 |
+
if flattened and c["type"] in ("ADDRESS", "COMPANY", "CITY", "URL",
|
| 359 |
+
"REF", "USERAGENT", "SECRET", "AGE"):
|
| 360 |
+
continue
|
| 361 |
+
if (c["start"], c["end"], c["type"]) not in seen:
|
| 362 |
+
seen.add((c["start"], c["end"], c["type"]))
|
| 363 |
+
candidates.append(c)
|
| 364 |
+
|
| 365 |
+
# le span le plus long gagne ; a longueur egale, premier arrive (ordre
|
| 366 |
+
# de declaration = priorite : checksum avant format avant contexte)
|
| 367 |
+
candidates.sort(key=lambda c: (-(c["end"] - c["start"]), c["start"]))
|
| 368 |
+
kept: list[dict] = []
|
| 369 |
+
occupied: set[int] = set()
|
| 370 |
+
for c in candidates:
|
| 371 |
+
span = set(range(c["start"], c["end"]))
|
| 372 |
+
if span & occupied:
|
| 373 |
+
continue
|
| 374 |
+
kept.append(c)
|
| 375 |
+
occupied |= span
|
| 376 |
+
kept.sort(key=lambda c: c["start"])
|
| 377 |
+
return kept
|
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Lance un detecteur sur un gold JSONL et ecrit les predictions + le score.
|
| 2 |
+
|
| 3 |
+
Usage :
|
| 4 |
+
python -m bench.detect.run data/bench_v0.jsonl --out data/pred_regex.jsonl
|
| 5 |
+
|
| 6 |
+
Detecteurs disponibles : regex (couche A). Les candidats NER/GLiNER viendront
|
| 7 |
+
s'ajouter ici en phase 2 (meme interface : detect(text) -> spans).
|
| 8 |
+
|
| 9 |
+
Le rapport est decoupe clean / bruite OCR : la degradation du regex sur le
|
| 10 |
+
bruit est une mesure attendue du benchmark (analyse §7.4).
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
import argparse
|
| 14 |
+
import json
|
| 15 |
+
|
| 16 |
+
from bench.detect import regex_layer
|
| 17 |
+
from bench.harness.score import format_report, load_jsonl, score
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
def _ner(text):
|
| 21 |
+
from bench.detect import ner_onnx
|
| 22 |
+
|
| 23 |
+
return ner_onnx.detect(text)
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _clip(span, occupied, text):
|
| 27 |
+
"""Decoupe un span autour des zones occupees : on garde les morceaux
|
| 28 |
+
libres (jeter le span entier ferait perdre "Jean Dupont" quand le NER
|
| 29 |
+
sort "Jean Dupont, 87, chemin Roux" et que le regex prend l'adresse)."""
|
| 30 |
+
pieces = []
|
| 31 |
+
start = None
|
| 32 |
+
for i in range(span["start"], span["end"] + 1):
|
| 33 |
+
free = i < span["end"] and i not in occupied
|
| 34 |
+
if free and start is None:
|
| 35 |
+
start = i
|
| 36 |
+
elif not free and start is not None:
|
| 37 |
+
while start < i and not text[start].isalnum():
|
| 38 |
+
start += 1
|
| 39 |
+
end = i
|
| 40 |
+
while end > start and not text[end - 1].isalnum():
|
| 41 |
+
end -= 1
|
| 42 |
+
if end - start >= 2:
|
| 43 |
+
pieces.append({"start": start, "end": end,
|
| 44 |
+
"type": span["type"], "value": text[start:end]})
|
| 45 |
+
start = None
|
| 46 |
+
return pieces
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _fusion(text):
|
| 50 |
+
"""regex + NER : la couche regex (checksums) est prioritaire sur ses
|
| 51 |
+
spans ; le NER complete partout ailleurs, decoupe si chevauchement."""
|
| 52 |
+
spans = regex_layer.detect(text)
|
| 53 |
+
occupied = set()
|
| 54 |
+
for s in spans:
|
| 55 |
+
occupied.update(range(s["start"], s["end"]))
|
| 56 |
+
for s in _ner(text):
|
| 57 |
+
for piece in _clip(s, occupied, text):
|
| 58 |
+
occupied.update(range(piece["start"], piece["end"]))
|
| 59 |
+
spans.append(piece)
|
| 60 |
+
return sorted(spans, key=lambda s: s["start"])
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def _full(text):
|
| 64 |
+
"""regex + NER + propagation document-entier des personnes."""
|
| 65 |
+
from bench.detect.propagation import propagate
|
| 66 |
+
|
| 67 |
+
spans = _fusion(text)
|
| 68 |
+
spans.extend(propagate(text, spans))
|
| 69 |
+
from bench.detect.propagation import propagate_exact, propagate_enumerations
|
| 70 |
+
from bench.detect.tools_filter import filtrer
|
| 71 |
+
spans.extend(propagate_exact(text, spans))
|
| 72 |
+
spans.extend(propagate_enumerations(text, spans))
|
| 73 |
+
spans.extend(propagate_exact(text, spans))
|
| 74 |
+
return filtrer(sorted(spans, key=lambda s: s["start"]))
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
def _hybrid(text):
|
| 78 |
+
"""La reco mesuree : regex -> gazetteer communes -> camembert-ner
|
| 79 |
+
generique (PERSON/CITY, meilleur rappel) -> Anonym-IA (le reste) ->
|
| 80 |
+
propagation."""
|
| 81 |
+
from bench.detect import gazetteer, ner_onnx
|
| 82 |
+
from bench.detect.propagation import propagate
|
| 83 |
+
|
| 84 |
+
spans = regex_layer.detect(text)
|
| 85 |
+
occupied = set()
|
| 86 |
+
for s in spans:
|
| 87 |
+
occupied.update(range(s["start"], s["end"]))
|
| 88 |
+
|
| 89 |
+
for source in (
|
| 90 |
+
gazetteer.detect(text),
|
| 91 |
+
[s for s in ner_onnx.detect_generic(text) if s["type"] in ("PERSON", "CITY")],
|
| 92 |
+
_ner(text),
|
| 93 |
+
):
|
| 94 |
+
for s in source:
|
| 95 |
+
for piece in _clip(s, occupied, text):
|
| 96 |
+
occupied.update(range(piece["start"], piece["end"]))
|
| 97 |
+
spans.append(piece)
|
| 98 |
+
|
| 99 |
+
spans.extend(propagate(text, spans))
|
| 100 |
+
from bench.detect.propagation import propagate_exact, propagate_enumerations
|
| 101 |
+
from bench.detect.tools_filter import filtrer
|
| 102 |
+
spans.extend(propagate_exact(text, spans))
|
| 103 |
+
spans.extend(propagate_enumerations(text, spans))
|
| 104 |
+
spans.extend(propagate_exact(text, spans))
|
| 105 |
+
return filtrer(sorted(spans, key=lambda s: s["start"]))
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def _camembert_baseline(text):
|
| 109 |
+
from bench.detect.ner_baseline import detect
|
| 110 |
+
|
| 111 |
+
return detect(text)
|
| 112 |
+
|
| 113 |
+
|
| 114 |
+
def _hybrid2(text):
|
| 115 |
+
"""hybrid + NOTRE fine-tune en moteur COMPANY/filet metier, insere entre
|
| 116 |
+
camembert-ner (qui garde PERSON/CITY) et Anonym-IA (types exotiques)."""
|
| 117 |
+
from bench.detect import gazetteer, ner_onnx
|
| 118 |
+
from bench.detect.propagation import propagate
|
| 119 |
+
|
| 120 |
+
spans = regex_layer.detect(text)
|
| 121 |
+
occupied = set()
|
| 122 |
+
for s in spans:
|
| 123 |
+
occupied.update(range(s["start"], s["end"]))
|
| 124 |
+
|
| 125 |
+
for source in (
|
| 126 |
+
gazetteer.detect(text),
|
| 127 |
+
[s for s in ner_onnx.detect_generic(text) if s["type"] in ("PERSON", "CITY")],
|
| 128 |
+
ner_onnx.detect_noirci(text),
|
| 129 |
+
_ner(text),
|
| 130 |
+
):
|
| 131 |
+
for s in source:
|
| 132 |
+
for piece in _clip(s, occupied, text):
|
| 133 |
+
occupied.update(range(piece["start"], piece["end"]))
|
| 134 |
+
spans.append(piece)
|
| 135 |
+
|
| 136 |
+
spans.extend(propagate(text, spans))
|
| 137 |
+
from bench.detect.propagation import propagate_exact, propagate_enumerations
|
| 138 |
+
from bench.detect.tools_filter import filtrer
|
| 139 |
+
spans.extend(propagate_exact(text, spans))
|
| 140 |
+
spans.extend(propagate_enumerations(text, spans))
|
| 141 |
+
spans.extend(propagate_exact(text, spans))
|
| 142 |
+
return filtrer(sorted(spans, key=lambda s: s["start"]))
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
def _lite(text):
|
| 146 |
+
"""Candidat executable : regex -> gazetteer -> UN seul modele (notre
|
| 147 |
+
fine-tune v2, corpus v4 mixte metier+WikiNER) -> propagation."""
|
| 148 |
+
from bench.detect import gazetteer, ner_onnx
|
| 149 |
+
from bench.detect.propagation import propagate
|
| 150 |
+
|
| 151 |
+
from bench.detect import vocabulaire
|
| 152 |
+
|
| 153 |
+
spans = regex_layer.detect(text)
|
| 154 |
+
occupied = set()
|
| 155 |
+
for s in spans:
|
| 156 |
+
occupied.update(range(s["start"], s["end"]))
|
| 157 |
+
from bench.detect import gazetteer_company
|
| 158 |
+
# le vocabulaire local passe avant les modeles : c'est une connaissance
|
| 159 |
+
# certaine, elle doit ancrer la propagation plutot que la subir
|
| 160 |
+
for source in (vocabulaire.detect(text), gazetteer.detect(text),
|
| 161 |
+
ner_onnx.detect_noirci(text),
|
| 162 |
+
gazetteer_company.detect(text)):
|
| 163 |
+
for s in source:
|
| 164 |
+
for piece in _clip(s, occupied, text):
|
| 165 |
+
occupied.update(range(piece["start"], piece["end"]))
|
| 166 |
+
spans.append(piece)
|
| 167 |
+
spans.extend(propagate(text, spans))
|
| 168 |
+
from bench.detect.propagation import propagate_exact, propagate_enumerations
|
| 169 |
+
from bench.detect.tools_filter import filtrer
|
| 170 |
+
spans.extend(propagate_exact(text, spans))
|
| 171 |
+
spans.extend(propagate_enumerations(text, spans))
|
| 172 |
+
spans.extend(propagate_exact(text, spans))
|
| 173 |
+
return filtrer(sorted(spans, key=lambda s: s["start"]))
|
| 174 |
+
|
| 175 |
+
|
| 176 |
+
def _lite2(text):
|
| 177 |
+
"""lite + seconde passe en majuscules ciblees (bench/detect/casse.py).
|
| 178 |
+
Une inference de plus par document, contre un tiers de fuite COMPANY
|
| 179 |
+
en moins. Voir la mesure du 31/07 dans doc/memory/matrice_comparaison.md."""
|
| 180 |
+
from bench.detect.casse import seconde_passe
|
| 181 |
+
from bench.detect.propagation import propagate_exact
|
| 182 |
+
from bench.detect.tools_filter import filtrer
|
| 183 |
+
|
| 184 |
+
spans = list(_lite(text))
|
| 185 |
+
spans.extend(seconde_passe(text, spans, _lite))
|
| 186 |
+
spans.extend(propagate_exact(text, spans))
|
| 187 |
+
return filtrer(sorted(spans, key=lambda s: s["start"]))
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
def _hybrid3(text):
|
| 191 |
+
"""hybrid2 SANS Anonym-IA : ablation anti sur-masquage (2026-07-29).
|
| 192 |
+
regex -> gazetteer -> generique (PERSON/CITY) -> noirci v2 -> propagation."""
|
| 193 |
+
from bench.detect import gazetteer, ner_onnx
|
| 194 |
+
from bench.detect.propagation import propagate
|
| 195 |
+
|
| 196 |
+
spans = regex_layer.detect(text)
|
| 197 |
+
occupied = set()
|
| 198 |
+
for s in spans:
|
| 199 |
+
occupied.update(range(s["start"], s["end"]))
|
| 200 |
+
for source in (
|
| 201 |
+
gazetteer.detect(text),
|
| 202 |
+
[s for s in ner_onnx.detect_generic(text) if s["type"] in ("PERSON", "CITY")],
|
| 203 |
+
ner_onnx.detect_noirci(text),
|
| 204 |
+
):
|
| 205 |
+
for s in source:
|
| 206 |
+
for piece in _clip(s, occupied, text):
|
| 207 |
+
occupied.update(range(piece["start"], piece["end"]))
|
| 208 |
+
spans.append(piece)
|
| 209 |
+
spans.extend(propagate(text, spans))
|
| 210 |
+
from bench.detect.propagation import propagate_exact, propagate_enumerations
|
| 211 |
+
from bench.detect.tools_filter import filtrer
|
| 212 |
+
spans.extend(propagate_exact(text, spans))
|
| 213 |
+
spans.extend(propagate_enumerations(text, spans))
|
| 214 |
+
spans.extend(propagate_exact(text, spans))
|
| 215 |
+
return filtrer(sorted(spans, key=lambda s: s["start"]))
|
| 216 |
+
|
| 217 |
+
|
| 218 |
+
DETECTORS = {
|
| 219 |
+
"regex": regex_layer.detect,
|
| 220 |
+
"lite": _lite,
|
| 221 |
+
"lite2": _lite2,
|
| 222 |
+
"hybrid3": _hybrid3,
|
| 223 |
+
"ner": _ner,
|
| 224 |
+
"regex+ner": _fusion,
|
| 225 |
+
"full": _full,
|
| 226 |
+
"hybrid": _hybrid,
|
| 227 |
+
"hybrid2": _hybrid2,
|
| 228 |
+
"camembert-ner": _camembert_baseline,
|
| 229 |
+
}
|
| 230 |
+
|
| 231 |
+
|
| 232 |
+
def main():
|
| 233 |
+
ap = argparse.ArgumentParser(description="Detection + scoring sur un gold JSONL")
|
| 234 |
+
ap.add_argument("gold")
|
| 235 |
+
ap.add_argument("--detector", choices=DETECTORS, default="regex")
|
| 236 |
+
ap.add_argument("--out", help="fichier predictions JSONL (optionnel)")
|
| 237 |
+
args = ap.parse_args()
|
| 238 |
+
|
| 239 |
+
detector = DETECTORS[args.detector]
|
| 240 |
+
gold = load_jsonl(args.gold)
|
| 241 |
+
preds = {
|
| 242 |
+
doc_id: {"id": doc_id, "entities": detector(doc["text"])}
|
| 243 |
+
for doc_id, doc in gold.items()
|
| 244 |
+
}
|
| 245 |
+
|
| 246 |
+
if args.out:
|
| 247 |
+
with open(args.out, "w", encoding="utf-8") as f:
|
| 248 |
+
for p in preds.values():
|
| 249 |
+
f.write(json.dumps(p, ensure_ascii=False) + "\n")
|
| 250 |
+
|
| 251 |
+
for label, keep in [
|
| 252 |
+
("TOUT", lambda d: True),
|
| 253 |
+
("CLEAN", lambda d: not d.get("noise")),
|
| 254 |
+
("BRUITE OCR", lambda d: d.get("noise")),
|
| 255 |
+
]:
|
| 256 |
+
subset = {i: d for i, d in gold.items() if keep(d)}
|
| 257 |
+
if not subset:
|
| 258 |
+
continue
|
| 259 |
+
print(f"\n=== {args.detector} / {label} ({len(subset)} segments) ===")
|
| 260 |
+
print(format_report(score(subset, preds)))
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
if __name__ == "__main__":
|
| 264 |
+
main()
|
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Outils et plateformes grand public : hors perimetre de masquage.
|
| 2 |
+
|
| 3 |
+
Decision produit (2026-07-31, Loic) : masquer « Zoom », « Excel » ou
|
| 4 |
+
« Stripe » ne protege personne et rend le texte inutilisable. Le type
|
| 5 |
+
COMPANY est reserve aux organisations qui IDENTIFIENT quelqu'un : societe
|
| 6 |
+
cliente, fournisseur nomme, cabinet, employeur.
|
| 7 |
+
|
| 8 |
+
Ces valeurs sortent donc du gold ET des predictions. Un client qui veut les
|
| 9 |
+
masquer quand meme le fera par politique (types= dans pseudonymize).
|
| 10 |
+
"""
|
| 11 |
+
import re
|
| 12 |
+
import unicodedata
|
| 13 |
+
from functools import lru_cache
|
| 14 |
+
from pathlib import Path
|
| 15 |
+
|
| 16 |
+
LISTE = Path(__file__).resolve().parents[2] / "data" / "tools_grand_public.txt"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
def _norm(s: str) -> str:
|
| 20 |
+
s = unicodedata.normalize("NFD", s.lower())
|
| 21 |
+
s = "".join(c for c in s if unicodedata.category(c) != "Mn")
|
| 22 |
+
return re.sub(r"[^a-z0-9]+", " ", s).strip()
|
| 23 |
+
|
| 24 |
+
|
| 25 |
+
@lru_cache(maxsize=1)
|
| 26 |
+
def _set():
|
| 27 |
+
if not LISTE.exists():
|
| 28 |
+
return set()
|
| 29 |
+
return {_norm(l) for l in LISTE.read_text(encoding="utf-8").splitlines() if l.strip()}
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def est_outil(valeur: str) -> bool:
|
| 33 |
+
"""Vrai si la valeur designe un outil/plateforme grand public."""
|
| 34 |
+
v = _norm(valeur)
|
| 35 |
+
if not v:
|
| 36 |
+
return False
|
| 37 |
+
if v in _set():
|
| 38 |
+
return True
|
| 39 |
+
# "5000.dev" ou "stripe.com" : le nom de domaine d'un outil connu
|
| 40 |
+
racine = v.split(" ")[0]
|
| 41 |
+
return racine in _set() and len(v.split()) <= 2
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def filtrer(spans: list[dict]) -> list[dict]:
|
| 45 |
+
"""Retire les COMPANY qui sont des outils grand public."""
|
| 46 |
+
return [s for s in spans
|
| 47 |
+
if not (s["type"] == "COMPANY" and est_outil(s["value"]))]
|
|
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Vote de typage entre couches (audit reel 2026-07-29).
|
| 2 |
+
|
| 3 |
+
Constat : ~5 spans PERSON du pipeline sont en realite des societes (et
|
| 4 |
+
inversement). Ces cas ne FUIENT pas (la valeur est masquee) mais degradent
|
| 5 |
+
la qualite des jetons envoyes au LLM ("PERSON_3" pour un editeur de
|
| 6 |
+
logiciel embrouille le modele).
|
| 7 |
+
|
| 8 |
+
Regle : quand deux sources independantes proposent le meme span (memes
|
| 9 |
+
frontieres a la normalisation pres) avec des types differents, on tranche
|
| 10 |
+
par priorite de fiabilite mesuree, et non par ordre d'arrivee :
|
| 11 |
+
- regex/gazetteer (deterministe) > tout
|
| 12 |
+
- camembert-ner generique sur PERSON/CITY (mesure : 0,5 % de fuite)
|
| 13 |
+
- fine-tune metier sur COMPANY/ADDRESS (mesure : le meilleur sur ces types)
|
| 14 |
+
"""
|
| 15 |
+
|
| 16 |
+
# fiabilite par (source, type) : plus haut = plus credible
|
| 17 |
+
PRIORITY = {
|
| 18 |
+
("regex", None): 100,
|
| 19 |
+
("gazetteer", "CITY"): 90,
|
| 20 |
+
("generic", "PERSON"): 80,
|
| 21 |
+
("generic", "CITY"): 70,
|
| 22 |
+
("noirci", "COMPANY"): 75,
|
| 23 |
+
("noirci", "ADDRESS"): 60,
|
| 24 |
+
("noirci", "CADASTRE"): 60,
|
| 25 |
+
("generic", "COMPANY"): 40,
|
| 26 |
+
("noirci", "PERSON"): 50,
|
| 27 |
+
("noirci", "CITY"): 40,
|
| 28 |
+
}
|
| 29 |
+
DEFAULT = 30
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def score(source: str, etype: str) -> int:
|
| 33 |
+
return PRIORITY.get((source, etype), PRIORITY.get((source, None), DEFAULT))
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def resolve(candidates: list[dict]) -> list[dict]:
|
| 37 |
+
"""candidates : spans portant une cle 'source'. Les spans qui se
|
| 38 |
+
chevauchent sont regroupes ; le type gagnant est celui de la source la
|
| 39 |
+
plus fiable, les frontieres restent celles du span le plus long."""
|
| 40 |
+
if not candidates:
|
| 41 |
+
return []
|
| 42 |
+
ordered = sorted(candidates, key=lambda c: (c["start"], -(c["end"] - c["start"])))
|
| 43 |
+
groups: list[list[dict]] = []
|
| 44 |
+
for c in ordered:
|
| 45 |
+
if groups and c["start"] < groups[-1][0]["end"]:
|
| 46 |
+
groups[-1].append(c)
|
| 47 |
+
else:
|
| 48 |
+
groups.append([c])
|
| 49 |
+
|
| 50 |
+
out = []
|
| 51 |
+
for grp in groups:
|
| 52 |
+
longest = max(grp, key=lambda c: c["end"] - c["start"])
|
| 53 |
+
best = max(grp, key=lambda c: score(c.get("source", "?"), c["type"]))
|
| 54 |
+
out.append({"start": longest["start"], "end": longest["end"],
|
| 55 |
+
"type": best["type"], "value": longest["value"]})
|
| 56 |
+
return out
|
|
@@ -0,0 +1,104 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Vocabulaire propre au deploiement : les noms que seul l'utilisateur connait.
|
| 2 |
+
|
| 3 |
+
Constat sur la correspondance reelle (analyse du 31/07) : un tiers des
|
| 4 |
+
societes non protegees etaient le nom de l'agence elle-meme, ecrit « 5000 »,
|
| 5 |
+
« 5000.dev », « 5000 Dev » et « 5000dev » selon les phrases. Aucun modele
|
| 6 |
+
statistique n'apprendra qu'un nombre a quatre chiffres est une raison
|
| 7 |
+
sociale, et il ne devrait pas : c'est une connaissance locale, pas une
|
| 8 |
+
regularite de la langue.
|
| 9 |
+
|
| 10 |
+
D'ou cette couche. Chaque installation declare ses propres entites (sa
|
| 11 |
+
raison sociale, ses clients, ses noms de projets internes) dans un fichier
|
| 12 |
+
texte, une par ligne, au format `valeur = TYPE`. Le type est facultatif et
|
| 13 |
+
vaut COMPANY par defaut.
|
| 14 |
+
|
| 15 |
+
5000.dev = COMPANY
|
| 16 |
+
5000 Dev
|
| 17 |
+
Vegetalents = COMPANY
|
| 18 |
+
Ferrand-Lemoine = PERSON
|
| 19 |
+
|
| 20 |
+
Le match replie casse et accents mais exige une majuscule quand l'entree en
|
| 21 |
+
porte une, pour ne pas masquer un homographe en minuscules. Les entrees
|
| 22 |
+
sont essayees de la plus longue a la plus courte, donc « 5000.dev » gagne
|
| 23 |
+
sur « 5000 » et le jeton reste coherent.
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
+
import re
|
| 27 |
+
import unicodedata
|
| 28 |
+
from functools import lru_cache
|
| 29 |
+
from pathlib import Path
|
| 30 |
+
|
| 31 |
+
_APRES_MONTANT = re.compile(r"\s*(?:€|EUR\b|euros?\b|HT\b|TTC\b|k€|%)")
|
| 32 |
+
|
| 33 |
+
FICHIER = Path(__file__).resolve().parents[2] / "data" / "vocabulaire.txt"
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def _fold(s: str) -> str:
|
| 37 |
+
"""Repli casse + accents a longueur constante (offsets preserves)."""
|
| 38 |
+
out = []
|
| 39 |
+
for ch in s:
|
| 40 |
+
d = unicodedata.normalize("NFD", ch)
|
| 41 |
+
base = "".join(c for c in d if unicodedata.category(c) != "Mn")
|
| 42 |
+
out.append((base[0] if base else ch).lower())
|
| 43 |
+
return "".join(out)
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
@lru_cache(maxsize=4)
|
| 47 |
+
def charger(chemin: str | None = None) -> list[tuple[str, str, str]]:
|
| 48 |
+
"""(replie, type, surface d'origine), du plus long au plus court."""
|
| 49 |
+
p = Path(chemin) if chemin else FICHIER
|
| 50 |
+
if not p.exists():
|
| 51 |
+
return []
|
| 52 |
+
entrees = []
|
| 53 |
+
for ligne in p.read_text(encoding="utf-8").splitlines():
|
| 54 |
+
ligne = ligne.split("#", 1)[0].strip()
|
| 55 |
+
if not ligne:
|
| 56 |
+
continue
|
| 57 |
+
if "=" in ligne:
|
| 58 |
+
valeur, _, etype = ligne.partition("=")
|
| 59 |
+
valeur, etype = valeur.strip(), etype.strip().upper()
|
| 60 |
+
else:
|
| 61 |
+
valeur, etype = ligne, "COMPANY"
|
| 62 |
+
if len(valeur) < 2:
|
| 63 |
+
continue
|
| 64 |
+
entrees.append((_fold(valeur), etype or "COMPANY", valeur))
|
| 65 |
+
return sorted(entrees, key=lambda e: -len(e[0]))
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def detect(text: str, chemin: str | None = None) -> list[dict]:
|
| 69 |
+
entrees = charger(chemin)
|
| 70 |
+
if not entrees:
|
| 71 |
+
return []
|
| 72 |
+
replie = _fold(text)
|
| 73 |
+
pris = set()
|
| 74 |
+
spans = []
|
| 75 |
+
for aiguille, etype, origine in entrees:
|
| 76 |
+
exige_maj = any(c.isupper() for c in origine)
|
| 77 |
+
depart = 0
|
| 78 |
+
while True:
|
| 79 |
+
i = replie.find(aiguille, depart)
|
| 80 |
+
if i < 0:
|
| 81 |
+
break
|
| 82 |
+
depart = i + 1
|
| 83 |
+
j = i + len(aiguille)
|
| 84 |
+
if pris & set(range(i, j)):
|
| 85 |
+
continue
|
| 86 |
+
if i > 0 and (text[i - 1].isalnum() or text[i - 1] in "@."):
|
| 87 |
+
continue
|
| 88 |
+
if j < len(text) and (text[j].isalnum() or
|
| 89 |
+
(text[j] == "." and j + 1 < len(text)
|
| 90 |
+
and text[j + 1].isalnum())):
|
| 91 |
+
continue
|
| 92 |
+
surface = text[i:j]
|
| 93 |
+
if exige_maj and not any(c.isupper() for c in surface) \
|
| 94 |
+
and not any(c.isdigit() for c in surface):
|
| 95 |
+
continue
|
| 96 |
+
# une entree purement numerique ("5000") suivie d'une devise ou
|
| 97 |
+
# d'une unite est un montant, pas une raison sociale
|
| 98 |
+
if surface.replace(" ", "").isdigit() and \
|
| 99 |
+
_APRES_MONTANT.match(text[j:j + 12]):
|
| 100 |
+
continue
|
| 101 |
+
pris |= set(range(i, j))
|
| 102 |
+
spans.append({"start": i, "end": j, "type": etype,
|
| 103 |
+
"value": surface})
|
| 104 |
+
return sorted(spans, key=lambda s: s["start"])
|
|
File without changes
|
|
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Harness de scoring — metrique reine : leak rate par type d'entite.
|
| 2 |
+
|
| 3 |
+
Format d'echange (JSONL, un segment par ligne) :
|
| 4 |
+
{"id": "...", "text": "...", "domain": "juridique", "noise": false,
|
| 5 |
+
"entities": [{"start": 10, "end": 21, "type": "PERSON", "value": "Jean Dupont"}]}
|
| 6 |
+
|
| 7 |
+
Les predictions suivent le meme format (memes ids, offsets sur le meme texte).
|
| 8 |
+
|
| 9 |
+
Definitions (voir doc/memory/analyse.md §5.1) :
|
| 10 |
+
- Une entite gold est COUVERTE si l'union des spans predits (tous types
|
| 11 |
+
confondus) couvre 100 % de ses caracteres significatifs (espaces/ponctuation
|
| 12 |
+
de bord exclus). Un IBAN masque aux 3/4 est une FUITE, pas un succes partiel.
|
| 13 |
+
- leak rate = 1 - (couvertes / total), par type et global.
|
| 14 |
+
- partial rate = entites touchees mais pas entierement couvertes (fuites
|
| 15 |
+
quand meme, comptees a part car symptome different : frontieres de spans).
|
| 16 |
+
- over-masking = part des caracteres predits qui ne recouvrent aucune entite
|
| 17 |
+
gold (bruit impose au LLM).
|
| 18 |
+
- F1 span exact avec normalisation des frontieres (strip ponctuation, espaces
|
| 19 |
+
et titres M./Mme/Me/Dr) + match du type.
|
| 20 |
+
"""
|
| 21 |
+
|
| 22 |
+
import json
|
| 23 |
+
from collections import defaultdict
|
| 24 |
+
from dataclasses import dataclass
|
| 25 |
+
|
| 26 |
+
_TITLES = ("M. ", "Mme ", "Me ", "Dr ", "Monsieur ", "Madame ", "Maître ")
|
| 27 |
+
_STRIP_CHARS = " \t\n.,;:()[]«»\"'"
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
@dataclass(frozen=True)
|
| 31 |
+
class Span:
|
| 32 |
+
start: int
|
| 33 |
+
end: int
|
| 34 |
+
type: str
|
| 35 |
+
|
| 36 |
+
def normalized(self, text: str) -> "Span":
|
| 37 |
+
s, e = self.start, self.end
|
| 38 |
+
while s < e and text[s] in _STRIP_CHARS:
|
| 39 |
+
s += 1
|
| 40 |
+
while e > s and text[e - 1] in _STRIP_CHARS:
|
| 41 |
+
e -= 1
|
| 42 |
+
for t in _TITLES:
|
| 43 |
+
if text[s:e].startswith(t):
|
| 44 |
+
s += len(t)
|
| 45 |
+
break
|
| 46 |
+
return Span(s, e, self.type)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def _significant_chars(text: str, span: Span) -> set[int]:
|
| 50 |
+
n = span.normalized(text)
|
| 51 |
+
return {i for i in range(n.start, n.end) if text[i] not in _STRIP_CHARS}
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def load_jsonl(path) -> dict[str, dict]:
|
| 55 |
+
docs = {}
|
| 56 |
+
with open(path, encoding="utf-8") as f:
|
| 57 |
+
for line in f:
|
| 58 |
+
line = line.strip()
|
| 59 |
+
if line:
|
| 60 |
+
d = json.loads(line)
|
| 61 |
+
docs[d["id"]] = d
|
| 62 |
+
return docs
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def _spans(doc: dict) -> list[Span]:
|
| 66 |
+
return [Span(e["start"], e["end"], e["type"]) for e in doc.get("entities", [])]
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
def score(gold_docs: dict[str, dict], pred_docs: dict[str, dict]) -> dict:
|
| 70 |
+
per_type = defaultdict(lambda: {"total": 0, "covered": 0, "partial": 0, "missed": 0})
|
| 71 |
+
exact = defaultdict(lambda: {"tp": 0, "fp": 0, "fn": 0})
|
| 72 |
+
overmask_chars = 0
|
| 73 |
+
pred_chars = 0
|
| 74 |
+
|
| 75 |
+
for doc_id, gold in gold_docs.items():
|
| 76 |
+
text = gold["text"]
|
| 77 |
+
pred = pred_docs.get(doc_id, {"entities": []})
|
| 78 |
+
gspans, pspans = _spans(gold), _spans(pred)
|
| 79 |
+
|
| 80 |
+
pred_cover = set()
|
| 81 |
+
for p in pspans:
|
| 82 |
+
pred_cover |= set(range(p.start, p.end))
|
| 83 |
+
|
| 84 |
+
gold_cover = set()
|
| 85 |
+
for g in gspans:
|
| 86 |
+
gold_cover |= set(range(g.start, g.end))
|
| 87 |
+
|
| 88 |
+
# leak / partial par entite gold, couverture tous types confondus
|
| 89 |
+
for g in gspans:
|
| 90 |
+
sig = _significant_chars(text, g)
|
| 91 |
+
if not sig:
|
| 92 |
+
continue
|
| 93 |
+
hit = len(sig & pred_cover)
|
| 94 |
+
st = per_type[g.type]
|
| 95 |
+
st["total"] += 1
|
| 96 |
+
if hit == len(sig):
|
| 97 |
+
st["covered"] += 1
|
| 98 |
+
elif hit > 0:
|
| 99 |
+
st["partial"] += 1
|
| 100 |
+
else:
|
| 101 |
+
st["missed"] += 1
|
| 102 |
+
|
| 103 |
+
# over-masking : caracteres significatifs predits hors de tout gold
|
| 104 |
+
sig_pred = {i for i in pred_cover if i < len(text) and text[i] not in _STRIP_CHARS}
|
| 105 |
+
pred_chars += len(sig_pred)
|
| 106 |
+
overmask_chars += len(sig_pred - gold_cover)
|
| 107 |
+
|
| 108 |
+
# F1 exact (frontieres normalisees + type)
|
| 109 |
+
gset = {(s.normalized(text)) for s in gspans}
|
| 110 |
+
pset = {(s.normalized(text)) for s in pspans}
|
| 111 |
+
for s in gset & pset:
|
| 112 |
+
exact[s.type]["tp"] += 1
|
| 113 |
+
for s in gset - pset:
|
| 114 |
+
exact[s.type]["fn"] += 1
|
| 115 |
+
for s in pset - gset:
|
| 116 |
+
exact[s.type]["fp"] += 1
|
| 117 |
+
|
| 118 |
+
report = {"per_type": {}, "global": {}}
|
| 119 |
+
tot = {"total": 0, "covered": 0, "partial": 0, "missed": 0}
|
| 120 |
+
for etype in sorted(per_type):
|
| 121 |
+
st = per_type[etype]
|
| 122 |
+
ex = exact[etype]
|
| 123 |
+
prec = ex["tp"] / (ex["tp"] + ex["fp"]) if ex["tp"] + ex["fp"] else 0.0
|
| 124 |
+
rec = ex["tp"] / (ex["tp"] + ex["fn"]) if ex["tp"] + ex["fn"] else 0.0
|
| 125 |
+
f1 = 2 * prec * rec / (prec + rec) if prec + rec else 0.0
|
| 126 |
+
report["per_type"][etype] = {
|
| 127 |
+
**st,
|
| 128 |
+
"leak_rate": 1 - st["covered"] / st["total"] if st["total"] else 0.0,
|
| 129 |
+
"exact_precision": round(prec, 4),
|
| 130 |
+
"exact_recall": round(rec, 4),
|
| 131 |
+
"exact_f1": round(f1, 4),
|
| 132 |
+
}
|
| 133 |
+
for k in tot:
|
| 134 |
+
tot[k] += st[k]
|
| 135 |
+
|
| 136 |
+
report["global"] = {
|
| 137 |
+
**tot,
|
| 138 |
+
"leak_rate": 1 - tot["covered"] / tot["total"] if tot["total"] else 0.0,
|
| 139 |
+
"overmask_rate": overmask_chars / pred_chars if pred_chars else 0.0,
|
| 140 |
+
}
|
| 141 |
+
return report
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
def format_report(report: dict) -> str:
|
| 145 |
+
lines = [
|
| 146 |
+
f"{'type':<12} {'total':>6} {'covered':>8} {'partial':>8} {'missed':>7} "
|
| 147 |
+
f"{'LEAK':>7} {'P':>6} {'R':>6} {'F1':>6}"
|
| 148 |
+
]
|
| 149 |
+
for etype, st in report["per_type"].items():
|
| 150 |
+
lines.append(
|
| 151 |
+
f"{etype:<12} {st['total']:>6} {st['covered']:>8} {st['partial']:>8} "
|
| 152 |
+
f"{st['missed']:>7} {st['leak_rate']:>7.2%} {st['exact_precision']:>6.2f} "
|
| 153 |
+
f"{st['exact_recall']:>6.2f} {st['exact_f1']:>6.2f}"
|
| 154 |
+
)
|
| 155 |
+
g = report["global"]
|
| 156 |
+
lines.append("-" * len(lines[0]))
|
| 157 |
+
lines.append(
|
| 158 |
+
f"{'GLOBAL':<12} {g['total']:>6} {g['covered']:>8} {g['partial']:>8} "
|
| 159 |
+
f"{g['missed']:>7} {g['leak_rate']:>7.2%} over-masking {g['overmask_rate']:.2%}"
|
| 160 |
+
)
|
| 161 |
+
return "\n".join(lines)
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def main():
|
| 165 |
+
import argparse
|
| 166 |
+
|
| 167 |
+
ap = argparse.ArgumentParser(description="Score des predictions PII vs gold")
|
| 168 |
+
ap.add_argument("gold")
|
| 169 |
+
ap.add_argument("pred")
|
| 170 |
+
ap.add_argument("--json", action="store_true", help="sortie JSON complete")
|
| 171 |
+
args = ap.parse_args()
|
| 172 |
+
|
| 173 |
+
report = score(load_jsonl(args.gold), load_jsonl(args.pred))
|
| 174 |
+
if args.json:
|
| 175 |
+
print(json.dumps(report, ensure_ascii=False, indent=2))
|
| 176 |
+
else:
|
| 177 |
+
print(format_report(report))
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
if __name__ == "__main__":
|
| 181 |
+
main()
|
|
File without changes
|
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Validateurs et generateurs d'identifiants francais a checksum.
|
| 2 |
+
|
| 3 |
+
Ces fonctions servent deux usages :
|
| 4 |
+
- generation de PII valides pour le corpus synthetique (bench)
|
| 5 |
+
- plus tard, la couche A de detection (un match regex + checksum OK = decision)
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import random
|
| 9 |
+
import string
|
| 10 |
+
|
| 11 |
+
# ---------------------------------------------------------------- Luhn (CB, SIREN, SIRET)
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def luhn_checksum(digits: str) -> int:
|
| 15 |
+
total = 0
|
| 16 |
+
for i, ch in enumerate(reversed(digits)):
|
| 17 |
+
d = int(ch)
|
| 18 |
+
if i % 2 == 1:
|
| 19 |
+
d *= 2
|
| 20 |
+
if d > 9:
|
| 21 |
+
d -= 9
|
| 22 |
+
total += d
|
| 23 |
+
return total % 10
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def luhn_valid(digits: str) -> bool:
|
| 27 |
+
return digits.isdigit() and luhn_checksum(digits) == 0
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
def _luhn_complete(prefix: str) -> str:
|
| 31 |
+
"""Ajoute le digit de controle rendant prefix+d valide au sens de Luhn."""
|
| 32 |
+
check = (10 - luhn_checksum(prefix + "0")) % 10
|
| 33 |
+
return prefix + str(check)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
def gen_siren(rng: random.Random) -> str:
|
| 37 |
+
return _luhn_complete("".join(rng.choices(string.digits, k=8)))
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def gen_siret(rng: random.Random, siren: str | None = None) -> str:
|
| 41 |
+
"""SIRET = SIREN + NIC (5 chiffres), le tout valide Luhn sur 14 chiffres."""
|
| 42 |
+
siren = siren or gen_siren(rng)
|
| 43 |
+
nic4 = "".join(rng.choices(string.digits, k=4))
|
| 44 |
+
return _luhn_complete(siren + nic4)
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
def siren_valid(s: str) -> bool:
|
| 48 |
+
return len(s) == 9 and luhn_valid(s)
|
| 49 |
+
|
| 50 |
+
|
| 51 |
+
def siret_valid(s: str) -> bool:
|
| 52 |
+
return len(s) == 14 and luhn_valid(s)
|
| 53 |
+
|
| 54 |
+
|
| 55 |
+
def gen_carte_bancaire(rng: random.Random) -> str:
|
| 56 |
+
prefix = rng.choice(["4", "51", "52", "53", "54", "55"]) # Visa / MC
|
| 57 |
+
body = "".join(rng.choices(string.digits, k=15 - len(prefix)))
|
| 58 |
+
return _luhn_complete(prefix + body)
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# ---------------------------------------------------------------- NIR (n° de securite sociale)
|
| 62 |
+
|
| 63 |
+
_NIR_DEPTS = [f"{d:02d}" for d in range(1, 96) if d != 20] + ["2A", "2B", "97"]
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def nir_key(nir13: str) -> int:
|
| 67 |
+
"""Cle = 97 - (NIR mod 97). Corse : 2A -> -1e6, 2B -> -2e6 sur le nombre."""
|
| 68 |
+
s = nir13.upper()
|
| 69 |
+
if "A" in s:
|
| 70 |
+
n = int(s.replace("A", "0")) - 1_000_000
|
| 71 |
+
elif "B" in s:
|
| 72 |
+
n = int(s.replace("B", "0")) - 2_000_000
|
| 73 |
+
else:
|
| 74 |
+
n = int(s)
|
| 75 |
+
return 97 - (n % 97)
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def gen_nir(rng: random.Random) -> str:
|
| 79 |
+
"""NIR complet 15 caracteres (13 + cle), checksum valide, Corse incluse."""
|
| 80 |
+
sexe = rng.choice("12")
|
| 81 |
+
annee = f"{rng.randint(0, 99):02d}"
|
| 82 |
+
mois = f"{rng.randint(1, 12):02d}"
|
| 83 |
+
dept = rng.choice(_NIR_DEPTS)
|
| 84 |
+
commune = f"{rng.randint(1, 990):03d}"
|
| 85 |
+
ordre = f"{rng.randint(1, 999):03d}"
|
| 86 |
+
nir13 = sexe + annee + mois + dept + commune + ordre
|
| 87 |
+
return nir13 + f"{nir_key(nir13):02d}"
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def nir_valid(s: str) -> bool:
|
| 91 |
+
s = s.replace(" ", "").upper()
|
| 92 |
+
if len(s) != 15:
|
| 93 |
+
return False
|
| 94 |
+
nir13, key = s[:13], s[13:]
|
| 95 |
+
if not key.isdigit():
|
| 96 |
+
return False
|
| 97 |
+
core = nir13.replace("A", "").replace("B", "")
|
| 98 |
+
if not core.isdigit() or len(core) < 12:
|
| 99 |
+
return False
|
| 100 |
+
return nir_key(nir13) == int(key)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
# ---------------------------------------------------------------- IBAN
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def _iban_mod97(iban: str) -> int:
|
| 107 |
+
rearranged = iban[4:] + iban[:4]
|
| 108 |
+
num = "".join(str(int(c, 36)) for c in rearranged)
|
| 109 |
+
return int(num) % 97
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def iban_valid(s: str) -> bool:
|
| 113 |
+
s = s.replace(" ", "").upper()
|
| 114 |
+
if len(s) < 15 or not s[:2].isalpha() or not s[2:4].isdigit():
|
| 115 |
+
return False
|
| 116 |
+
return _iban_mod97(s) == 1
|
| 117 |
+
|
| 118 |
+
|
| 119 |
+
def gen_iban_fr(rng: random.Random) -> str:
|
| 120 |
+
"""IBAN FR : FRkk BBBBB GGGGG CCCCCCCCCCC KK (cle RIB + cle IBAN valides)."""
|
| 121 |
+
banque = "".join(rng.choices(string.digits, k=5))
|
| 122 |
+
guichet = "".join(rng.choices(string.digits, k=5))
|
| 123 |
+
compte = "".join(rng.choices(string.digits, k=11))
|
| 124 |
+
cle_rib = 97 - ((89 * int(banque) + 15 * int(guichet) + 3 * int(compte)) % 97)
|
| 125 |
+
bban = f"{banque}{guichet}{compte}{cle_rib:02d}"
|
| 126 |
+
check = 98 - _iban_mod97(f"FR00{bban}")
|
| 127 |
+
return f"FR{check:02d}{bban}"
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
# ---------------------------------------------------------------- TVA intracommunautaire FR
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def gen_tva_fr(rng: random.Random, siren: str | None = None) -> str:
|
| 134 |
+
siren = siren or gen_siren(rng)
|
| 135 |
+
key = (12 + 3 * (int(siren) % 97)) % 97
|
| 136 |
+
return f"FR{key:02d}{siren}"
|
| 137 |
+
|
| 138 |
+
|
| 139 |
+
def tva_fr_valid(s: str) -> bool:
|
| 140 |
+
s = s.replace(" ", "").upper()
|
| 141 |
+
if len(s) != 13 or not s.startswith("FR") or not s[2:].isdigit():
|
| 142 |
+
return False
|
| 143 |
+
siren = s[4:]
|
| 144 |
+
return int(s[2:4]) == (12 + 3 * (int(siren) % 97)) % 97 and siren_valid(siren)
|
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generation de valeurs PII francaises pour le corpus synthetique.
|
| 2 |
+
|
| 3 |
+
Chaque generateur renvoie (valeur_texte, type_entite). Les formats de surface
|
| 4 |
+
varient volontairement (espaces IBAN, points telephone, casse noms) : le
|
| 5 |
+
benchmark doit refleter la realite des documents, pas des valeurs canoniques.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import random
|
| 9 |
+
from dataclasses import dataclass, field
|
| 10 |
+
|
| 11 |
+
from faker import Faker
|
| 12 |
+
|
| 13 |
+
from . import checksums as ck
|
| 14 |
+
|
| 15 |
+
# Types d'entites du benchmark (aligne sur l'analyse, doc/memory/analyse.md §2)
|
| 16 |
+
TYPES = [
|
| 17 |
+
"PERSON", "COMPANY", "ADDRESS", "CITY", "EMAIL", "PHONE", "DATE",
|
| 18 |
+
"DATE_BIRTH", "IBAN", "NIR", "SIREN", "SIRET", "TVA", "CARD", "PLATE",
|
| 19 |
+
"RG", "CADASTRE", "IP", "AMOUNT", "REF", "URL", "SECRET",
|
| 20 |
+
"USERAGENT", "MAC", "IPV6", "AGE", "ACCOUNT",
|
| 21 |
+
]
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
@dataclass
|
| 25 |
+
class Person:
|
| 26 |
+
"""Une personne avec ses variantes de surface (piege n°1 : 'Dupont' seul)."""
|
| 27 |
+
first: str
|
| 28 |
+
last: str
|
| 29 |
+
civ: str = "M."
|
| 30 |
+
|
| 31 |
+
@property
|
| 32 |
+
def full(self) -> str:
|
| 33 |
+
return f"{self.first} {self.last}"
|
| 34 |
+
|
| 35 |
+
def variants(self) -> list[str]:
|
| 36 |
+
return [
|
| 37 |
+
self.full,
|
| 38 |
+
f"{self.civ} {self.last}",
|
| 39 |
+
self.last.upper(),
|
| 40 |
+
self.last,
|
| 41 |
+
f"{self.civ} {self.first} {self.last.upper()}",
|
| 42 |
+
f"{self.first[0]}. {self.last}",
|
| 43 |
+
f"{self.last}, {self.first}", # etat civil / BODACC : Nom, Prenom
|
| 44 |
+
]
|
| 45 |
+
|
| 46 |
+
|
| 47 |
+
@dataclass
|
| 48 |
+
class PiiFactory:
|
| 49 |
+
seed: int = 0
|
| 50 |
+
rng: random.Random = field(init=False)
|
| 51 |
+
fk: Faker = field(init=False)
|
| 52 |
+
|
| 53 |
+
def __post_init__(self):
|
| 54 |
+
self.rng = random.Random(self.seed)
|
| 55 |
+
self.fk = Faker("fr_FR")
|
| 56 |
+
self.fk.seed_instance(self.seed)
|
| 57 |
+
|
| 58 |
+
# --- personnes / societes / lieux ------------------------------------
|
| 59 |
+
def person(self) -> Person:
|
| 60 |
+
civ = self.rng.choice(["M.", "Mme", "Me", "Dr"])
|
| 61 |
+
if civ == "Mme":
|
| 62 |
+
first = self.fk.first_name_female()
|
| 63 |
+
else:
|
| 64 |
+
first = self.fk.first_name_male()
|
| 65 |
+
return Person(first=first, last=self.fk.last_name(), civ=civ)
|
| 66 |
+
|
| 67 |
+
def company(self) -> str:
|
| 68 |
+
# styles releves sur BODACC (remontees reelles 2026-07-28) : marques
|
| 69 |
+
# tout-majuscules, sigles, style domaine — pas que du Faker propre
|
| 70 |
+
style = self.rng.random()
|
| 71 |
+
if style < 0.5:
|
| 72 |
+
base = self.fk.company()
|
| 73 |
+
forme = self.rng.choice(["", "", " SARL", " SAS", " SA", " SCI"])
|
| 74 |
+
return base + forme
|
| 75 |
+
if style < 0.7:
|
| 76 |
+
suffix = self.rng.choice(["", "", " TRANSPORTS", " CONSEIL",
|
| 77 |
+
" IMMO", " DISTRIBUTION", " BATIMENT"])
|
| 78 |
+
return self.fk.last_name().upper().replace(" ", "") + suffix
|
| 79 |
+
if style < 0.8:
|
| 80 |
+
return self.fk.last_name().upper() + "." + self.rng.choice(["FR", "COM"])
|
| 81 |
+
if style < 0.9:
|
| 82 |
+
letters = [w[0].upper() for w in self.fk.company().split()[:3]]
|
| 83 |
+
while len(letters) < 2:
|
| 84 |
+
letters.append(self.rng.choice("BCDFGMPRST"))
|
| 85 |
+
return ".".join(letters) + "."
|
| 86 |
+
return self.fk.company().upper()
|
| 87 |
+
|
| 88 |
+
def address(self) -> str:
|
| 89 |
+
# formes reelles : plages de numeros, lieux-dits, hameaux sans type
|
| 90 |
+
# de voie, Grande Rue, residences (remontees BODACC)
|
| 91 |
+
style = self.rng.random()
|
| 92 |
+
if style < 0.55:
|
| 93 |
+
return self.fk.street_address()
|
| 94 |
+
if style < 0.65:
|
| 95 |
+
n = self.rng.randint(1, 120)
|
| 96 |
+
return f"{n}-{n + self.rng.choice([2, 4, 6])} {self.fk.street_name()}"
|
| 97 |
+
if style < 0.75:
|
| 98 |
+
art = self.rng.choice(["La", "Le", "Les"])
|
| 99 |
+
return f"Lieu-dit {art} {self.fk.last_name()}"
|
| 100 |
+
if style < 0.85:
|
| 101 |
+
return f"{self.rng.randint(1, 40)} {self.fk.last_name()}"
|
| 102 |
+
if style < 0.93:
|
| 103 |
+
return f"{self.rng.randint(1, 60)} Grande Rue"
|
| 104 |
+
art = self.rng.choice(["La", "Le", "Les"])
|
| 105 |
+
return (f"{self.rng.randint(1, 30)} Résidence {art} "
|
| 106 |
+
f"{self.fk.last_name()}")
|
| 107 |
+
|
| 108 |
+
def city(self) -> str:
|
| 109 |
+
city = self.fk.city()
|
| 110 |
+
if city.startswith("Saint") and self.rng.random() < 0.5:
|
| 111 |
+
return city.replace("Sainte-", "Ste-").replace("Saint-", "St-")
|
| 112 |
+
return city
|
| 113 |
+
|
| 114 |
+
def email(self, person: Person | None = None) -> str:
|
| 115 |
+
if person and self.rng.random() < 0.7:
|
| 116 |
+
dom = self.rng.choice(["gmail.com", "orange.fr", "free.fr", "outlook.fr"])
|
| 117 |
+
sep = self.rng.choice([".", "", "-"])
|
| 118 |
+
return f"{person.first.lower()}{sep}{person.last.lower()}@{dom}".replace(" ", "")
|
| 119 |
+
return self.fk.email()
|
| 120 |
+
|
| 121 |
+
# --- identifiants a checksum -----------------------------------------
|
| 122 |
+
def iban(self) -> str:
|
| 123 |
+
raw = ck.gen_iban_fr(self.rng)
|
| 124 |
+
if self.rng.random() < 0.6:
|
| 125 |
+
return " ".join(raw[i:i + 4] for i in range(0, len(raw), 4))
|
| 126 |
+
return raw
|
| 127 |
+
|
| 128 |
+
def nir(self) -> str:
|
| 129 |
+
raw = ck.gen_nir(self.rng)
|
| 130 |
+
if self.rng.random() < 0.5:
|
| 131 |
+
p = [raw[0], raw[1:3], raw[3:5], raw[5:7], raw[7:10], raw[10:13], raw[13:15]]
|
| 132 |
+
return " ".join(p)
|
| 133 |
+
return raw
|
| 134 |
+
|
| 135 |
+
def siren(self) -> str:
|
| 136 |
+
raw = ck.gen_siren(self.rng)
|
| 137 |
+
if self.rng.random() < 0.5:
|
| 138 |
+
return f"{raw[:3]} {raw[3:6]} {raw[6:]}"
|
| 139 |
+
return raw
|
| 140 |
+
|
| 141 |
+
def siret(self) -> str:
|
| 142 |
+
raw = ck.gen_siret(self.rng)
|
| 143 |
+
if self.rng.random() < 0.5:
|
| 144 |
+
return f"{raw[:3]} {raw[3:6]} {raw[6:9]} {raw[9:]}"
|
| 145 |
+
return raw
|
| 146 |
+
|
| 147 |
+
def tva(self) -> str:
|
| 148 |
+
raw = ck.gen_tva_fr(self.rng)
|
| 149 |
+
if self.rng.random() < 0.4:
|
| 150 |
+
return f"{raw[:4]} {raw[4:]}"
|
| 151 |
+
return raw
|
| 152 |
+
|
| 153 |
+
def card(self) -> str:
|
| 154 |
+
raw = ck.gen_carte_bancaire(self.rng)
|
| 155 |
+
if self.rng.random() < 0.5:
|
| 156 |
+
return " ".join(raw[i:i + 4] for i in range(0, 16, 4))
|
| 157 |
+
return raw
|
| 158 |
+
|
| 159 |
+
# --- regex sans checksum ----------------------------------------------
|
| 160 |
+
def phone(self) -> str:
|
| 161 |
+
prefix = self.rng.choice(["01", "02", "03", "04", "05", "06", "07", "09"])
|
| 162 |
+
digits = [f"{self.rng.randint(0, 99):02d}" for _ in range(4)]
|
| 163 |
+
style = self.rng.random()
|
| 164 |
+
if style < 0.3:
|
| 165 |
+
return "+33 " + prefix[1] + " " + " ".join(digits)
|
| 166 |
+
if style < 0.6:
|
| 167 |
+
return prefix + " " + " ".join(digits)
|
| 168 |
+
if style < 0.8:
|
| 169 |
+
return prefix + "." + ".".join(digits)
|
| 170 |
+
return prefix + "".join(digits)
|
| 171 |
+
|
| 172 |
+
def plate(self) -> str:
|
| 173 |
+
letters = "BCDFGHJKLMNPRSTVWXZ"
|
| 174 |
+
if self.rng.random() < 0.8:
|
| 175 |
+
return (f"{self.rng.choice(letters)}{self.rng.choice(letters)}-"
|
| 176 |
+
f"{self.rng.randint(100, 999)}-"
|
| 177 |
+
f"{self.rng.choice(letters)}{self.rng.choice(letters)}")
|
| 178 |
+
return (f"{self.rng.randint(100, 999)} "
|
| 179 |
+
f"{''.join(self.rng.choices(letters, k=3))} "
|
| 180 |
+
f"{self.rng.randint(1, 95):02d}")
|
| 181 |
+
|
| 182 |
+
def rg(self) -> str:
|
| 183 |
+
return f"{self.rng.randint(18, 26):02d}/{self.rng.randint(1, 99999):05d}"
|
| 184 |
+
|
| 185 |
+
def cadastre(self) -> str:
|
| 186 |
+
letters = "ABCDEFGHIKLMNOPRSTVXYZ"
|
| 187 |
+
section = "".join(self.rng.choices(letters, k=self.rng.choice([1, 2])))
|
| 188 |
+
return f"section {section} n° {self.rng.randint(1, 999)}"
|
| 189 |
+
|
| 190 |
+
def ip(self) -> str:
|
| 191 |
+
return self.fk.ipv4()
|
| 192 |
+
|
| 193 |
+
# --- divers ------------------------------------------------------------
|
| 194 |
+
def date(self) -> str:
|
| 195 |
+
d = self.fk.date_between(start_date="-3y", end_date="today")
|
| 196 |
+
if self.rng.random() < 0.5:
|
| 197 |
+
return d.strftime("%d/%m/%Y")
|
| 198 |
+
months = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet",
|
| 199 |
+
"août", "septembre", "octobre", "novembre", "décembre"]
|
| 200 |
+
return f"{d.day} {months[d.month - 1]} {d.year}"
|
| 201 |
+
|
| 202 |
+
def ref(self) -> str:
|
| 203 |
+
"""Numero de dossier/facture NON etiquete : distracteur numerique."""
|
| 204 |
+
return f"{self.rng.randint(100, 99999):05d}"
|
| 205 |
+
|
| 206 |
+
def date_birth(self) -> str:
|
| 207 |
+
d = self.fk.date_of_birth(minimum_age=18, maximum_age=90)
|
| 208 |
+
style = self.rng.random()
|
| 209 |
+
if style < 0.4:
|
| 210 |
+
return d.strftime("%d/%m/%Y")
|
| 211 |
+
if style < 0.7:
|
| 212 |
+
months = ["janvier", "février", "mars", "avril", "mai", "juin", "juillet",
|
| 213 |
+
"août", "septembre", "octobre", "novembre", "décembre"]
|
| 214 |
+
return f"{d.day} {months[d.month - 1]} {d.year}"
|
| 215 |
+
return d.strftime("%d.%m.%Y")
|
| 216 |
+
|
| 217 |
+
def amount(self) -> str:
|
| 218 |
+
v = self.rng.choice([
|
| 219 |
+
f"{self.rng.randint(100, 9999)},{self.rng.randint(0, 99):02d}",
|
| 220 |
+
f"{self.rng.randint(1, 99)} {self.rng.randint(100, 999)},{self.rng.randint(0, 99):02d}",
|
| 221 |
+
str(self.rng.randint(50, 5000)),
|
| 222 |
+
])
|
| 223 |
+
# decimale POINT et devise EUR : formats reels (BODACC, exports
|
| 224 |
+
# bancaires), remontee 2026-07-28
|
| 225 |
+
style = self.rng.random()
|
| 226 |
+
if style < 0.15:
|
| 227 |
+
return f"{self.rng.randint(500, 90000)}.{self.rng.randint(0, 99):02d} EUR"
|
| 228 |
+
if style < 0.25:
|
| 229 |
+
return f"{v.replace(',', '.').replace(' ', '')} EUR"
|
| 230 |
+
if style < 0.35:
|
| 231 |
+
return f"{v} euros"
|
| 232 |
+
return f"{v} €"
|
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Factory a VALEURS REELLES pour l'eval anti-contamination.
|
| 2 |
+
|
| 3 |
+
Remplace Faker par les pools moissonnes sur BODACC
|
| 4 |
+
(data/real_values_pool.json, bench/real/harvest.py) pour les types a
|
| 5 |
+
vocabulaire : personnes, societes, adresses, villes, SIREN (et TVA, dont la
|
| 6 |
+
cle se calcule sur le SIREN reel, donc valide). Les identifiants purement
|
| 7 |
+
generes (IBAN, NIR, CB, telephone...) restent ceux de PiiFactory : leurs
|
| 8 |
+
checksums sont la seule chose qui compte, pas leur vocabulaire.
|
| 9 |
+
|
| 10 |
+
But : mesurer un modele fine-tune sur des VALEURS jamais vues au train
|
| 11 |
+
(Faker a des listes finies de noms, partagees train/eval — un modele peut
|
| 12 |
+
les memoriser au lieu d'apprendre la reconnaissance en contexte).
|
| 13 |
+
"""
|
| 14 |
+
|
| 15 |
+
import json
|
| 16 |
+
from pathlib import Path
|
| 17 |
+
|
| 18 |
+
from bench.pii.generators import Person, PiiFactory
|
| 19 |
+
|
| 20 |
+
POOL = Path(__file__).resolve().parents[2] / "data" / "real_values_pool.json"
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
class RealValuesFactory(PiiFactory):
|
| 24 |
+
def __post_init__(self):
|
| 25 |
+
super().__post_init__()
|
| 26 |
+
pools = json.loads(POOL.read_text(encoding="utf-8"))
|
| 27 |
+
self._persons = pools["persons"]
|
| 28 |
+
self._first_names = pools.get("first_names_insee", [])
|
| 29 |
+
self._companies = pools["companies"]
|
| 30 |
+
self._addresses = pools["addresses"]
|
| 31 |
+
self._cities = pools["cities"]
|
| 32 |
+
self._sirens = pools["sirens"]
|
| 33 |
+
|
| 34 |
+
def person(self) -> Person:
|
| 35 |
+
civ = self.rng.choice(["M.", "Mme", "Me", "Dr"])
|
| 36 |
+
p = self.rng.choice(self._persons)
|
| 37 |
+
# croisement prenom INSEE x nom BODACC : demultiplie la variete
|
| 38 |
+
# reelle (445 personnes moissonnees, 3000 prenoms, produit libre)
|
| 39 |
+
if self._first_names and self.rng.random() < 0.6:
|
| 40 |
+
return Person(first=self.rng.choice(self._first_names),
|
| 41 |
+
last=p["last"], civ=civ)
|
| 42 |
+
return Person(first=p["first"], last=p["last"], civ=civ)
|
| 43 |
+
|
| 44 |
+
def company(self) -> str:
|
| 45 |
+
return self.rng.choice(self._companies)
|
| 46 |
+
|
| 47 |
+
def address(self) -> str:
|
| 48 |
+
return self.rng.choice(self._addresses)
|
| 49 |
+
|
| 50 |
+
def city(self) -> str:
|
| 51 |
+
return self.rng.choice(self._cities)
|
| 52 |
+
|
| 53 |
+
def siren(self) -> str:
|
| 54 |
+
raw = self.rng.choice(self._sirens)
|
| 55 |
+
if self.rng.random() < 0.5:
|
| 56 |
+
return f"{raw[:3]} {raw[3:6]} {raw[6:]}"
|
| 57 |
+
return raw
|
| 58 |
+
|
| 59 |
+
def tva(self) -> str:
|
| 60 |
+
from bench.pii.checksums import gen_tva_fr
|
| 61 |
+
|
| 62 |
+
siren = self.rng.choice(self._sirens)
|
| 63 |
+
raw = gen_tva_fr(self.rng, siren=siren)
|
| 64 |
+
if self.rng.random() < 0.4:
|
| 65 |
+
return f"{raw[:4]} {raw[4:]}"
|
| 66 |
+
return raw
|
|
File without changes
|
|
@@ -0,0 +1,155 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Construction du corpus synthetique : templates + PII generees + offsets gold.
|
| 2 |
+
|
| 3 |
+
Usage :
|
| 4 |
+
# jeu d'evaluation (templates du pool EVAL, jamais vus en train)
|
| 5 |
+
python -m bench.synth.build --split eval --n 1500 --out data/bench_v1.jsonl
|
| 6 |
+
# corpus d'entrainement (hors git, regenerable a l'identique par seed)
|
| 7 |
+
python -m bench.synth.build --split train --n 100000 \
|
| 8 |
+
--out data/corpus_train_100k.jsonl
|
| 9 |
+
|
| 10 |
+
Chaque segment est un objet JSONL au format du harness (voir harness/score.py).
|
| 11 |
+
~30 % des segments recoivent un bruitage OCR a longueur constante (offsets
|
| 12 |
+
inchanges, flag "noise": true), ~8 % sont des negatifs purs sans PII, et les
|
| 13 |
+
valeurs longues (IBAN, NIR...) peuvent etre coupees par un saut de ligne
|
| 14 |
+
(piege OCR/PDF, longueur conservee).
|
| 15 |
+
|
| 16 |
+
Limite assumee : synthetique pur. L'eval reelle annotee main (Judilibre,
|
| 17 |
+
BODACC, documents fictifs relus) reste indispensable avant toute conclusion —
|
| 18 |
+
analyse §4.3 : "jamais du synthetique seul".
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
import argparse
|
| 22 |
+
import json
|
| 23 |
+
import random
|
| 24 |
+
import re
|
| 25 |
+
from pathlib import Path
|
| 26 |
+
|
| 27 |
+
from bench.pii.generators import Person, PiiFactory
|
| 28 |
+
from bench.synth.noise import apply_noise
|
| 29 |
+
from bench.synth.templates import NEGATIVES, all_templates
|
| 30 |
+
|
| 31 |
+
_SLOT_RE = re.compile(r"\{([a-z_]+?)(\d+)(_v)?\}")
|
| 32 |
+
|
| 33 |
+
# prefixe de slot -> (methode factory, label ; None = distracteur non etiquete)
|
| 34 |
+
_SLOT_TYPES = {
|
| 35 |
+
"person": "PERSON", "company": "COMPANY", "address": "ADDRESS",
|
| 36 |
+
"city": "CITY", "email": "EMAIL", "phone": "PHONE", "date": "DATE",
|
| 37 |
+
"date_birth": "DATE_BIRTH", "iban": "IBAN", "nir": "NIR",
|
| 38 |
+
"siren": "SIREN", "siret": "SIRET", "tva": "TVA", "card": "CARD",
|
| 39 |
+
"plate": "PLATE", "rg": "RG", "cadastre": "CADASTRE", "ip": "IP",
|
| 40 |
+
"amount": "AMOUNT", "ref": None,
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _maybe_linebreak(surface: str, rng: random.Random) -> str:
|
| 45 |
+
"""Piege PDF/OCR : coupe une valeur longue par un saut de ligne (meme
|
| 46 |
+
longueur, un espace interieur remplace par \\n)."""
|
| 47 |
+
if len(surface) < 14 or " " not in surface[2:-2] or rng.random() > 0.04:
|
| 48 |
+
return surface
|
| 49 |
+
spaces = [i for i, c in enumerate(surface) if c == " " and 1 < i < len(surface) - 2]
|
| 50 |
+
i = rng.choice(spaces)
|
| 51 |
+
return surface[:i] + "\n" + surface[i + 1:]
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def fill_template(template: str, factory: PiiFactory, rng: random.Random,
|
| 55 |
+
ref_label: str | None = None) -> dict:
|
| 56 |
+
values: dict[tuple[str, str], object] = {}
|
| 57 |
+
text_parts: list[str] = []
|
| 58 |
+
entities: list[dict] = []
|
| 59 |
+
pos = 0
|
| 60 |
+
cursor = 0
|
| 61 |
+
|
| 62 |
+
for m in _SLOT_RE.finditer(template):
|
| 63 |
+
name, idx, variant = m.group(1), m.group(2), m.group(3)
|
| 64 |
+
if name not in _SLOT_TYPES:
|
| 65 |
+
raise ValueError(f"slot inconnu : {m.group(0)}")
|
| 66 |
+
|
| 67 |
+
text_parts.append(template[cursor:m.start()])
|
| 68 |
+
pos += m.start() - cursor
|
| 69 |
+
cursor = m.end()
|
| 70 |
+
|
| 71 |
+
key = (name, idx)
|
| 72 |
+
if key not in values:
|
| 73 |
+
values[key] = getattr(factory, name)()
|
| 74 |
+
val = values[key]
|
| 75 |
+
|
| 76 |
+
if isinstance(val, Person):
|
| 77 |
+
surface = rng.choice(val.variants()[1:]) if variant else val.full
|
| 78 |
+
else:
|
| 79 |
+
surface = _maybe_linebreak(str(val), rng)
|
| 80 |
+
|
| 81 |
+
etype = _SLOT_TYPES[name]
|
| 82 |
+
if name == "ref" and ref_label:
|
| 83 |
+
etype = ref_label
|
| 84 |
+
if etype is not None:
|
| 85 |
+
entities.append(
|
| 86 |
+
{"start": pos, "end": pos + len(surface), "type": etype, "value": surface}
|
| 87 |
+
)
|
| 88 |
+
text_parts.append(surface)
|
| 89 |
+
pos += len(surface)
|
| 90 |
+
|
| 91 |
+
text_parts.append(template[cursor:])
|
| 92 |
+
return {"text": "".join(text_parts), "entities": entities}
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def build_corpus(n: int, seed: int, noise_share: float,
|
| 96 |
+
split: str = "all", negative_share: float = 0.08,
|
| 97 |
+
values: str = "faker", ref_label: str | None = None) -> list[dict]:
|
| 98 |
+
rng = random.Random(seed)
|
| 99 |
+
if values == "real":
|
| 100 |
+
from bench.pii.real_factory import RealValuesFactory
|
| 101 |
+
|
| 102 |
+
factory = RealValuesFactory(seed=seed)
|
| 103 |
+
else:
|
| 104 |
+
factory = PiiFactory(seed=seed)
|
| 105 |
+
templates = all_templates(split)
|
| 106 |
+
domains = list(templates)
|
| 107 |
+
segments = []
|
| 108 |
+
for i in range(n):
|
| 109 |
+
if rng.random() < negative_share:
|
| 110 |
+
domain = "negatif"
|
| 111 |
+
seg = fill_template(rng.choice(NEGATIVES), factory, rng, ref_label=ref_label)
|
| 112 |
+
else:
|
| 113 |
+
domain = domains[i % len(domains)]
|
| 114 |
+
seg = fill_template(rng.choice(templates[domain]), factory, rng, ref_label=ref_label)
|
| 115 |
+
noised = rng.random() < noise_share
|
| 116 |
+
if noised:
|
| 117 |
+
seg["text"] = apply_noise(seg["text"], rng)
|
| 118 |
+
for e in seg["entities"]:
|
| 119 |
+
e["value"] = seg["text"][e["start"]:e["end"]]
|
| 120 |
+
seg = {"id": f"{split}-{domain}-{i:06d}", "domain": domain,
|
| 121 |
+
"noise": noised, **seg}
|
| 122 |
+
segments.append(seg)
|
| 123 |
+
return segments
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def main():
|
| 127 |
+
ap = argparse.ArgumentParser(description="Genere le corpus benchmark synthetique")
|
| 128 |
+
ap.add_argument("--n", type=int, default=600)
|
| 129 |
+
ap.add_argument("--seed", type=int, default=42)
|
| 130 |
+
ap.add_argument("--noise-share", type=float, default=0.3)
|
| 131 |
+
ap.add_argument("--negative-share", type=float, default=0.08)
|
| 132 |
+
ap.add_argument("--split", choices=["train", "eval", "all"], default="all")
|
| 133 |
+
ap.add_argument("--values", choices=["faker", "real"], default="faker",
|
| 134 |
+
help="real = pools BODACC (anti-contamination fine-tune)")
|
| 135 |
+
ap.add_argument("--label-refs", action="store_true",
|
| 136 |
+
help="etiquette les {ref} en REF (convention 2026-07-29)")
|
| 137 |
+
ap.add_argument("--out", default="data/bench_v0.jsonl")
|
| 138 |
+
args = ap.parse_args()
|
| 139 |
+
|
| 140 |
+
segments = build_corpus(args.n, args.seed, args.noise_share,
|
| 141 |
+
args.split, args.negative_share, args.values,
|
| 142 |
+
"REF" if args.label_refs else None)
|
| 143 |
+
out = Path(args.out)
|
| 144 |
+
out.parent.mkdir(parents=True, exist_ok=True)
|
| 145 |
+
with out.open("w", encoding="utf-8") as f:
|
| 146 |
+
for seg in segments:
|
| 147 |
+
f.write(json.dumps(seg, ensure_ascii=False) + "\n")
|
| 148 |
+
|
| 149 |
+
n_ent = sum(len(s["entities"]) for s in segments)
|
| 150 |
+
n_noise = sum(1 for s in segments if s["noise"])
|
| 151 |
+
print(f"{len(segments)} segments ({n_noise} bruites), {n_ent} entites -> {out}")
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
if __name__ == "__main__":
|
| 155 |
+
main()
|
|
@@ -0,0 +1,205 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Generation de squelettes de documents par sous-agents LLM (Haiku).
|
| 2 |
+
|
| 3 |
+
Methode GLiNER2-PII (analyse §4) : le LLM ecrit des SQUELETTES a slots, pas
|
| 4 |
+
des documents finis. Nos generateurs injectent les valeurs (checksums
|
| 5 |
+
valides), donc les offsets gold restent exacts par construction, et la
|
| 6 |
+
diversite de prose vient du LLM.
|
| 7 |
+
|
| 8 |
+
Validation stricte avant d'entrer au pool :
|
| 9 |
+
- slots ⊂ inventaire connu, syntaxe exacte, indices numeriques
|
| 10 |
+
- remplissage reel via fill_template sur 2 seeds (aucune accolade restante,
|
| 11 |
+
≥ 2 entites)
|
| 12 |
+
- longueur 80-1500 caracteres, dedup par similarite (difflib ≥ 0,88 = rejet)
|
| 13 |
+
Repartition train/eval deterministe par hash (≈ 85/15), pools disjoints.
|
| 14 |
+
|
| 15 |
+
Sortie : bench/synth/templates_llm.json, charge par templates.all_templates.
|
| 16 |
+
|
| 17 |
+
Usage :
|
| 18 |
+
python -m bench.synth.llm_templates --target 500 --parallel 8
|
| 19 |
+
"""
|
| 20 |
+
|
| 21 |
+
import argparse
|
| 22 |
+
import difflib
|
| 23 |
+
import hashlib
|
| 24 |
+
import json
|
| 25 |
+
import random
|
| 26 |
+
import re
|
| 27 |
+
import subprocess
|
| 28 |
+
from concurrent.futures import ThreadPoolExecutor
|
| 29 |
+
from pathlib import Path
|
| 30 |
+
|
| 31 |
+
from bench.pii.generators import PiiFactory
|
| 32 |
+
from bench.synth.build import _SLOT_TYPES, fill_template
|
| 33 |
+
|
| 34 |
+
OUT = Path(__file__).resolve().parent / "templates_llm.json"
|
| 35 |
+
|
| 36 |
+
DOMAINS_CORRESPONDANCE = {
|
| 37 |
+
"email_signature": "emails professionnels FR se terminant par un bloc de signature complet (prénom+nom, fonction, société, téléphone, site) après un corps long de plusieurs paragraphes",
|
| 38 |
+
"email_tiers": "emails où l'on cite des sociétés TIERCES en pleine prose sans forme juridique : l'éditeur du logiciel, la plateforme utilisée, le prestataire de paiement, un concurrent, le client du client",
|
| 39 |
+
"compte_rendu": "comptes rendus de réunion nominatifs longs : participants prénom+nom en début de paragraphe, sociétés et outils cités plusieurs fois, décisions datées",
|
| 40 |
+
"echange_long": "fils d'emails longs (800-1500 caractères) avec relances, plusieurs interlocuteurs nommés et plusieurs sociétés mentionnées au fil du texte",
|
| 41 |
+
"note_projet": "notes internes de projet citant des outils SaaS, des plateformes et des partenaires par leur marque, plus des identifiants de dossier",
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
DOMAINS = {
|
| 45 |
+
"juridique": "assignations, conclusions, jugements, courriers d'avocat, PV d'huissier, requêtes",
|
| 46 |
+
"compta": "factures, relances, devis, avoirs, notes de frais, courriers URSSAF/impôts, rapprochements",
|
| 47 |
+
"rh": "contrats de travail, bulletins de paie, CV, convocations, attestations, soldes de tout compte, DPAE",
|
| 48 |
+
"immobilier": "baux, états des lieux, quittances, compromis, mandats de gestion, PV d'AG de copropriété",
|
| 49 |
+
"email_client": "emails et messages de clients ou au client : réclamations, résiliations, SAV, relances, WhatsApp/SMS",
|
| 50 |
+
"assurance_banque": "déclarations de sinistre, avis d'échéance, crédits, résiliations, alertes bancaires",
|
| 51 |
+
"sante_social": "certificats médicaux, courriers mutuelle, CPAM, arrêts de travail, dossiers CAF",
|
| 52 |
+
"administratif": "courriers préfecture, cartes grises, impôts locaux, état civil, demandes de documents",
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
+
STYLES = [
|
| 56 |
+
"courrier formel et long, avec en-tête, objet, formules de politesse",
|
| 57 |
+
"email court et pressé, tutoiement possible, phrases inachevées",
|
| 58 |
+
"formulaire ou fiche : lignes 'Libellé : valeur', sauts de ligne fréquents",
|
| 59 |
+
"acte ou document officiel dense, numérotation d'articles, majuscules d'en-tête",
|
| 60 |
+
"message type WhatsApp/SMS : familier, ponctuation relâchée, urgence",
|
| 61 |
+
"document tabulaire dégradé type OCR : colonnes aplaties, libellés abrégés",
|
| 62 |
+
]
|
| 63 |
+
|
| 64 |
+
SLOTS_DOC = """person1, person2... (personne ; {person1_v} = variante de surface de la MÊME personne : nom seul, initiale, M./Mme + nom)
|
| 65 |
+
company1... (société), address1... (adresse postale), city1... (ville)
|
| 66 |
+
email1..., phone1..., date1... (date quelconque), date_birth1... (date de NAISSANCE uniquement)
|
| 67 |
+
iban1..., nir1... (n° sécu), siren1..., siret1..., tva1... (TVA intracom), card1... (carte bancaire)
|
| 68 |
+
plate1... (plaque immat), rg1... (n° RG tribunal, écrire 'RG' à proximité), cadastre1... (référence cadastrale complète, ne pas écrire 'section' avant)
|
| 69 |
+
ip1..., amount1... (montant avec devise), ref1... (n° de dossier/facture NON confidentiel)"""
|
| 70 |
+
|
| 71 |
+
PROMPT = """Tu écris des SQUELETTES de documents français réalistes pour un corpus d'entraînement à la détection de données personnelles. Un squelette = le texte du document où chaque donnée personnelle est remplacée par un slot entre accolades. Nos générateurs rempliront les slots.
|
| 72 |
+
|
| 73 |
+
Domaine : {domain} ({desc}).
|
| 74 |
+
Style imposé : {style}.
|
| 75 |
+
|
| 76 |
+
Slots autorisés (UNIQUEMENT ceux-là, syntaxe exacte {{nom+numéro}}) :
|
| 77 |
+
{slots}
|
| 78 |
+
|
| 79 |
+
Règles :
|
| 80 |
+
- 12 squelettes, très différents entre eux (structures, longueurs 300-900 caractères, tons variés)
|
| 81 |
+
- AUCUNE donnée personnelle en clair : tout passe par les slots (pas de nom, ville, montant ou numéro inventé dans le texte)
|
| 82 |
+
- Le même numéro = la même entité (réutiliser {{person1}} ou {{person1_v}} pour reparler de la même personne)
|
| 83 |
+
- 3 à 8 slots par squelette, mélanger les types, utiliser aussi les types rares (nir, plate, cadastre, tva, card, ip)
|
| 84 |
+
- Utiliser \\n pour les sauts de ligne
|
| 85 |
+
- Le texte hors slots doit être du français naturel de vrai document, pas générique
|
| 86 |
+
|
| 87 |
+
Réponds UNIQUEMENT avec un tableau JSON de 12 chaînes, sans commentaire."""
|
| 88 |
+
|
| 89 |
+
_SLOT_RE = re.compile(r"\{([a-z_]+?)(\d+)(_v)?\}")
|
| 90 |
+
_BRACE_RE = re.compile(r"[{}]")
|
| 91 |
+
|
| 92 |
+
|
| 93 |
+
def _valid_slots(tpl: str) -> bool:
|
| 94 |
+
stripped = _SLOT_RE.sub("", tpl)
|
| 95 |
+
if _BRACE_RE.search(stripped):
|
| 96 |
+
return False
|
| 97 |
+
ok = False
|
| 98 |
+
for name, _, variant in _SLOT_RE.findall(tpl):
|
| 99 |
+
if name not in _SLOT_TYPES:
|
| 100 |
+
return False
|
| 101 |
+
if variant and name != "person":
|
| 102 |
+
return False
|
| 103 |
+
ok = True
|
| 104 |
+
return ok
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
def validate(tpl: str) -> bool:
|
| 108 |
+
if not (80 <= len(tpl) <= 1500) or not _valid_slots(tpl):
|
| 109 |
+
return False
|
| 110 |
+
try:
|
| 111 |
+
for seed in (1, 2):
|
| 112 |
+
seg = fill_template(tpl, PiiFactory(seed=seed), random.Random(seed))
|
| 113 |
+
if "{" in seg["text"] or len(seg["entities"]) < 2:
|
| 114 |
+
return False
|
| 115 |
+
except Exception:
|
| 116 |
+
return False
|
| 117 |
+
return True
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def _signature(tpl: str) -> str:
|
| 121 |
+
return re.sub(r"\s+", " ", _SLOT_RE.sub("@", tpl)).lower()
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def _too_similar(tpl: str, accepted_sigs: list[str]) -> bool:
|
| 125 |
+
sig = _signature(tpl)
|
| 126 |
+
for other in accepted_sigs:
|
| 127 |
+
if difflib.SequenceMatcher(None, sig, other).quick_ratio() >= 0.88 and \
|
| 128 |
+
difflib.SequenceMatcher(None, sig, other).ratio() >= 0.88:
|
| 129 |
+
return True
|
| 130 |
+
return False
|
| 131 |
+
|
| 132 |
+
|
| 133 |
+
def _ask(job) -> list[str]:
|
| 134 |
+
domain, desc, style, salt = job
|
| 135 |
+
prompt = PROMPT.format(domain=domain, desc=desc, style=style,
|
| 136 |
+
slots=SLOTS_DOC)
|
| 137 |
+
prompt += f"\n(lot {salt} : évite les scénarios évidents déjà trop vus)"
|
| 138 |
+
try:
|
| 139 |
+
r = subprocess.run(["claude", "-p", prompt, "--model", "haiku"],
|
| 140 |
+
capture_output=True, text=True, timeout=300)
|
| 141 |
+
m = re.search(r"\[.*\]", r.stdout, re.DOTALL)
|
| 142 |
+
if not m:
|
| 143 |
+
return []
|
| 144 |
+
out = json.loads(m.group(0))
|
| 145 |
+
return [t for t in out if isinstance(t, str)]
|
| 146 |
+
except Exception:
|
| 147 |
+
return []
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def main():
|
| 151 |
+
ap = argparse.ArgumentParser()
|
| 152 |
+
ap.add_argument("--target", type=int, default=500)
|
| 153 |
+
ap.add_argument("--parallel", type=int, default=8)
|
| 154 |
+
ap.add_argument("--eval-share", type=float, default=0.15)
|
| 155 |
+
ap.add_argument("--profile", choices=["metier", "correspondance"], default="metier")
|
| 156 |
+
ap.add_argument("--out", default=None)
|
| 157 |
+
args = ap.parse_args()
|
| 158 |
+
|
| 159 |
+
jobs = []
|
| 160 |
+
salt = 0
|
| 161 |
+
domains = DOMAINS_CORRESPONDANCE if args.profile == "correspondance" else DOMAINS
|
| 162 |
+
while len(jobs) * 12 < args.target * 1.6:
|
| 163 |
+
for domain, desc in domains.items():
|
| 164 |
+
for style in STYLES:
|
| 165 |
+
jobs.append((domain, desc, style, salt))
|
| 166 |
+
salt += 1
|
| 167 |
+
rng = random.Random(0)
|
| 168 |
+
rng.shuffle(jobs)
|
| 169 |
+
|
| 170 |
+
accepted: dict[str, dict[str, list[str]]] = {
|
| 171 |
+
"train": {d: [] for d in domains}, "eval": {d: [] for d in domains}}
|
| 172 |
+
sigs: list[str] = []
|
| 173 |
+
stats = {"recus": 0, "invalides": 0, "doublons": 0}
|
| 174 |
+
|
| 175 |
+
with ThreadPoolExecutor(max_workers=args.parallel) as pool:
|
| 176 |
+
for job, result in zip(jobs, pool.map(_ask, jobs)):
|
| 177 |
+
domain = job[0]
|
| 178 |
+
for tpl in result:
|
| 179 |
+
stats["recus"] += 1
|
| 180 |
+
tpl = tpl.strip()
|
| 181 |
+
if not validate(tpl):
|
| 182 |
+
stats["invalides"] += 1
|
| 183 |
+
continue
|
| 184 |
+
if _too_similar(tpl, sigs):
|
| 185 |
+
stats["doublons"] += 1
|
| 186 |
+
continue
|
| 187 |
+
sigs.append(_signature(tpl))
|
| 188 |
+
h = int(hashlib.sha256(tpl.encode()).hexdigest(), 16)
|
| 189 |
+
split = "eval" if (h % 100) < args.eval_share * 100 else "train"
|
| 190 |
+
accepted[split][domain].append(tpl)
|
| 191 |
+
total = sum(len(lst) for s in accepted.values() for lst in s.values())
|
| 192 |
+
if total >= args.target:
|
| 193 |
+
break
|
| 194 |
+
|
| 195 |
+
total = sum(len(lst) for s in accepted.values() for lst in s.values())
|
| 196 |
+
n_eval = sum(len(lst) for lst in accepted["eval"].values())
|
| 197 |
+
out_path = Path(args.out) if args.out else OUT
|
| 198 |
+
out_path.write_text(json.dumps(accepted, ensure_ascii=False, indent=1),
|
| 199 |
+
encoding="utf-8")
|
| 200 |
+
print(f"{total} squelettes acceptes ({n_eval} eval) -> {out_path}")
|
| 201 |
+
print(stats)
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
if __name__ == "__main__":
|
| 205 |
+
main()
|
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Bruitage OCR/typo a longueur constante.
|
| 2 |
+
|
| 3 |
+
Contrainte forte : les substitutions preservent la longueur du texte, pour que
|
| 4 |
+
les offsets gold restent valides sans re-mapping. C'est ce qui permet de scorer
|
| 5 |
+
les memes segments propres ET bruites (analyse §5.1, metrique robustesse OCR).
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import random
|
| 9 |
+
import unicodedata
|
| 10 |
+
|
| 11 |
+
# substitutions OCR classiques, 1 caractere -> 1 caractere
|
| 12 |
+
_OCR_SUBS = {
|
| 13 |
+
"0": "O", "O": "0", "o": "0",
|
| 14 |
+
"1": "l", "l": "1", "I": "1",
|
| 15 |
+
"5": "S", "S": "5",
|
| 16 |
+
"8": "B", "B": "8",
|
| 17 |
+
"é": "e", "è": "e", "ê": "e", "à": "a", "ç": "c", "û": "u", "ô": "o",
|
| 18 |
+
"É": "E", "È": "E", "À": "A", "Ç": "C",
|
| 19 |
+
"m": "n", "u": "v",
|
| 20 |
+
}
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
def _strip_accent(ch: str) -> str:
|
| 24 |
+
d = unicodedata.normalize("NFD", ch)
|
| 25 |
+
base = d[0]
|
| 26 |
+
return base if len(base) == 1 else ch
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def apply_noise(text: str, rng: random.Random, rate: float = 0.03) -> str:
|
| 30 |
+
"""Bruite ~rate des caracteres eligibles. Longueur strictement conservee."""
|
| 31 |
+
chars = list(text)
|
| 32 |
+
for i, ch in enumerate(chars):
|
| 33 |
+
if rng.random() >= rate:
|
| 34 |
+
continue
|
| 35 |
+
r = rng.random()
|
| 36 |
+
if ch in _OCR_SUBS and r < 0.6:
|
| 37 |
+
chars[i] = _OCR_SUBS[ch]
|
| 38 |
+
elif ch.isalpha() and r < 0.8:
|
| 39 |
+
chars[i] = ch.upper() if ch.islower() else ch.lower()
|
| 40 |
+
elif ch.isalpha():
|
| 41 |
+
chars[i] = _strip_accent(ch)
|
| 42 |
+
out = "".join(chars)
|
| 43 |
+
assert len(out) == len(text)
|
| 44 |
+
return out
|
|
@@ -0,0 +1,364 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Templates metier pour le corpus synthetique.
|
| 2 |
+
|
| 3 |
+
Syntaxe des slots : {nom_du_slot}. Le prefixe du nom donne le type de PII
|
| 4 |
+
(person, company, iban...). Un suffixe numerique identifie l'entite au sein du
|
| 5 |
+
segment (person1 reapparait = meme personne). Le suffixe `_v` demande une
|
| 6 |
+
variante de surface ("M. Dupont", "DUPONT", "Dupont" seul) de la MEME
|
| 7 |
+
personne : c'est le piege n°1 du juridique, il doit etre dans le corpus.
|
| 8 |
+
{refN} produit un numero de dossier/facture NON etiquete (distracteur).
|
| 9 |
+
|
| 10 |
+
Deux pools DISJOINTS :
|
| 11 |
+
- TEMPLATES_TRAIN : generation du corpus d'entrainement (fine-tune futur)
|
| 12 |
+
- TEMPLATES_EVAL : jeux d'evaluation (bench_v1+). Jamais utilises en train,
|
| 13 |
+
sinon l'eval mesure la memorisation des gabarits, pas la generalisation.
|
| 14 |
+
NEGATIVES : segments sans aucune PII (mesure des faux positifs).
|
| 15 |
+
|
| 16 |
+
Types de documents tires de l'inventaire des apps 5000.dev (analyse §4).
|
| 17 |
+
"""
|
| 18 |
+
|
| 19 |
+
TEMPLATES_TRAIN = {
|
| 20 |
+
"juridique": [
|
| 21 |
+
"Par assignation du {date1}, {person1}, demeurant {address1} à "
|
| 22 |
+
"{city1}, a saisi le tribunal judiciaire. L'affaire est enrôlée sous le "
|
| 23 |
+
"n° RG {rg1}. {person1_v} sollicite la condamnation de la société "
|
| 24 |
+
"{company1} au paiement de {amount1}.",
|
| 25 |
+
|
| 26 |
+
"Vu les conclusions déposées par Me {person1} pour le compte de "
|
| 27 |
+
"{person2}, né le {date_birth1}, la société {company1} (SIREN "
|
| 28 |
+
"{siren1}) conteste la créance de {amount1}. {person2_v} demande "
|
| 29 |
+
"l'exécution provisoire. Dossier RG n° {rg1}.",
|
| 30 |
+
|
| 31 |
+
"Le bien situé {address1}, cadastré {cadastre1}, appartient à "
|
| 32 |
+
"{person1} et {person2}. Il a été acquis suivant acte reçu par Me "
|
| 33 |
+
"{person3}, notaire à {city1}, le {date1}. {person1_v} en "
|
| 34 |
+
"détient l'usufruit.",
|
| 35 |
+
|
| 36 |
+
"TRIBUNAL JUDICIAIRE DE {city1} — Jugement du {date1}, RG "
|
| 37 |
+
"{rg1}. Entre : {person1}, comparant en personne, et {company1}, "
|
| 38 |
+
"représentée par Me {person2}. Le tribunal condamne {company1} à "
|
| 39 |
+
"verser à {person1_v} la somme de {amount1}.",
|
| 40 |
+
|
| 41 |
+
"Maître, je fais suite à votre courrier concernant le dossier de "
|
| 42 |
+
"{person1} contre {company1}. Mon client, joignable au {phone1} ou "
|
| 43 |
+
"par mail à {email1}, conteste l'intégralité des demandes. Le "
|
| 44 |
+
"véhicule immatriculé {plate1} n'a jamais été impliqué.",
|
| 45 |
+
|
| 46 |
+
"PROCÈS-VERBAL — Le {date1}, à {city1}, l'agent a constaté que le "
|
| 47 |
+
"véhicule {plate1}, appartenant à {person1} ({address1}), était "
|
| 48 |
+
"stationné en infraction. Amende forfaitaire : {amount1}. "
|
| 49 |
+
"{person1_v} dispose de 45 jours pour contester.",
|
| 50 |
+
|
| 51 |
+
"Conclusions en défense pour {company1}, SIRET {siret1}, contre "
|
| 52 |
+
"{person1}. {person1_v}, qui se domicilie {address1} à {city1}, "
|
| 53 |
+
"réclame {amount1} au titre du préjudice. Notre cliente conteste. "
|
| 54 |
+
"Affaire RG {rg1}, audience du {date1}.",
|
| 55 |
+
|
| 56 |
+
"Testament olographe de {person1}, né le {date_birth1} à {city1}. "
|
| 57 |
+
"Je lègue à {person2} la parcelle {cadastre1} sise à {city2}, et à "
|
| 58 |
+
"{person3} la somme de {amount1} déposée sur le compte {iban1}.",
|
| 59 |
+
|
| 60 |
+
"Ordonnance de référé du {date1} — Le juge, saisi par Me {person1} "
|
| 61 |
+
"pour {company1}, ordonne à {person2} de libérer les lieux sis "
|
| 62 |
+
"{address1}. Astreinte : {amount1} par jour de retard. {person2_v} "
|
| 63 |
+
"peut faire appel. RG {rg1}.",
|
| 64 |
+
|
| 65 |
+
"Courrier à Mme la Greffière — Dans le dossier {person1} c/ "
|
| 66 |
+
"{person2} (RG {rg1}), je sollicite le renvoi de l'audience du "
|
| 67 |
+
"{date1}. Ma cliente, {person1_v}, est convoquée le même jour à "
|
| 68 |
+
"{city1}. Contact au cabinet : {phone1}.",
|
| 69 |
+
],
|
| 70 |
+
"compta": [
|
| 71 |
+
"FACTURE n° 2026-{ref1} — {company1}, {address1}, {city1}. SIRET "
|
| 72 |
+
"{siret1}, TVA intracommunautaire {tva1}. Total TTC : {amount1}. "
|
| 73 |
+
"Règlement par virement sur le compte {iban1}.",
|
| 74 |
+
|
| 75 |
+
"Bonjour, la facture de {amount1} émise par {company1} reste "
|
| 76 |
+
"impayée. Merci de régulariser sous huitaine sur l'IBAN {iban1}. À "
|
| 77 |
+
"défaut, le dossier sera transmis à notre conseil, Me {person1} "
|
| 78 |
+
"({email1}).",
|
| 79 |
+
|
| 80 |
+
"Relevé du {date1} — le paiement de {amount1} par carte "
|
| 81 |
+
"{card1} a été refusé. Le prélèvement sera représenté sur le compte "
|
| 82 |
+
"{iban1}. Contact : {phone1}.",
|
| 83 |
+
|
| 84 |
+
"La société {company1}, immatriculée sous le SIREN {siren1}, dont le "
|
| 85 |
+
"siège est {address1} à {city1}, déclare un chiffre d'affaires de "
|
| 86 |
+
"{amount1}. Expert-comptable : {person1}, tél. {phone1}.",
|
| 87 |
+
|
| 88 |
+
"AVOIR n° {ref1} du {date1} — {company1} (TVA {tva1}) crédite "
|
| 89 |
+
"{company2} de {amount1} suite au retour de marchandises. Le "
|
| 90 |
+
"remboursement interviendra sur le compte {iban1} sous 30 jours.",
|
| 91 |
+
|
| 92 |
+
"Note de frais — {person1}, déplacement à {city1} le {date1}. "
|
| 93 |
+
"Total : {amount1}, remboursé par virement sur {iban1}. Justificatifs "
|
| 94 |
+
"transmis à {email1}.",
|
| 95 |
+
|
| 96 |
+
"Rapprochement bancaire du {date1} : écart de {amount1} sur le "
|
| 97 |
+
"compte {iban1}. Écriture n° {ref1} pointée avec la facture "
|
| 98 |
+
"{company1}. Voir avec {person1} au {phone1}.",
|
| 99 |
+
|
| 100 |
+
"DEVIS n° {ref1} — {company1}, {address1}, {city1}, SIREN {siren1}. "
|
| 101 |
+
"À l'attention de {person1}. Montant total : {amount1} TTC, acompte "
|
| 102 |
+
"de {amount2} à la commande par carte ou virement ({iban1}). Devis "
|
| 103 |
+
"valable jusqu'au {date1}.",
|
| 104 |
+
|
| 105 |
+
"L'URSSAF réclame à {company1} (SIRET {siret1}) un rappel de "
|
| 106 |
+
"cotisations de {amount1} au titre de l'exercice clos. Le gérant, "
|
| 107 |
+
"{person1}, conteste ; échéancier demandé le {date1}. Réf. dossier "
|
| 108 |
+
"{ref1}.",
|
| 109 |
+
|
| 110 |
+
# style annonce legale : boilerplate NON etiquete (forme juridique,
|
| 111 |
+
# greffe) autour des vraies PII — mesure le sur-masquage (remontee
|
| 112 |
+
# reelle BODACC 2026-07-28)
|
| 113 |
+
"Greffe du Tribunal de Commerce de {city1}. Immatriculation au RCS. "
|
| 114 |
+
"Dénomination : {company1}. Forme : société à responsabilité "
|
| 115 |
+
"limitée. Capital : {amount1}. Siège social : {address1}, {city2}. "
|
| 116 |
+
"RCS {siren1}. Gérant : {person1_v}.",
|
| 117 |
+
],
|
| 118 |
+
"rh": [
|
| 119 |
+
"CONTRAT DE TRAVAIL — Entre {company1} (SIRET {siret1}) et "
|
| 120 |
+
"{person1}, né(e) le {date_birth1} à {city1}, demeurant {address1}, "
|
| 121 |
+
"n° de sécurité sociale {nir1}. Rémunération mensuelle brute : "
|
| 122 |
+
"{amount1}. {person1_v} prend ses fonctions le {date2}.",
|
| 123 |
+
|
| 124 |
+
"Bulletin de paie — {person1}, matricule {ref1}, NIR {nir1}. "
|
| 125 |
+
"Employeur : {company1}, {city1}. Net à payer : {amount1}, viré sur "
|
| 126 |
+
"le compte {iban1}.",
|
| 127 |
+
|
| 128 |
+
"CV — {person1}, {address1}, {city1}. Tél : {phone1}, email : "
|
| 129 |
+
"{email1}. Né le {date_birth1}. Dernier poste chez {company1}.",
|
| 130 |
+
|
| 131 |
+
"Objet : rupture conventionnelle de {person1}. La DREETS a validé la "
|
| 132 |
+
"convention le {date1}. L'indemnité de {amount1} sera versée "
|
| 133 |
+
"sur le compte habituel de {person1_v}. Copie à {email1}.",
|
| 134 |
+
|
| 135 |
+
"Arrêt de travail — {person1}, NIR {nir1}, salarié de {company1}, "
|
| 136 |
+
"est arrêté du {date1} au {date2}. Le médecin traitant exerce à "
|
| 137 |
+
"{city1}. Subrogation : IJSS versées à l'employeur (SIRET {siret1}).",
|
| 138 |
+
|
| 139 |
+
"Attestation employeur — {company1} certifie que {person1}, né le "
|
| 140 |
+
"{date_birth1}, est employé depuis le {date1} en qualité de cadre. "
|
| 141 |
+
"Salaire mensuel : {amount1}. Fait à {city1}, contact RH : "
|
| 142 |
+
"{email1}.",
|
| 143 |
+
|
| 144 |
+
"Convocation à entretien préalable — {person1_v} est convoqué le "
|
| 145 |
+
"{date1} à {city1}. {person1} peut se faire assister. Courrier "
|
| 146 |
+
"recommandé n° {ref1}, copie au CSE et à {email1}.",
|
| 147 |
+
|
| 148 |
+
"Solde de tout compte — {person1}, matricule {ref1}, quitte "
|
| 149 |
+
"{company1} le {date1}. Indemnités : {amount1}. Virement sur "
|
| 150 |
+
"{iban1}. Documents remis en main propre à {person1_v}.",
|
| 151 |
+
],
|
| 152 |
+
"immobilier": [
|
| 153 |
+
"BAIL D'HABITATION — Bailleur : {person1}, {address1}, {city1}. "
|
| 154 |
+
"Locataire : {person2}, né le {date_birth1}. Loyer mensuel {amount1} "
|
| 155 |
+
"payable par virement à {person1_v} sur l'IBAN {iban1}. Dépôt de "
|
| 156 |
+
"garantie : {amount2}.",
|
| 157 |
+
|
| 158 |
+
"L'état des lieux du bien sis {address1} à {city1} (cadastre "
|
| 159 |
+
"{cadastre1}) a été réalisé en présence de {person1} et de l'agence "
|
| 160 |
+
"{company1}. Les clés ont été remises à {person1_v}, joignable au "
|
| 161 |
+
"{phone1}.",
|
| 162 |
+
|
| 163 |
+
"COMPROMIS DE VENTE — {person1} et {person2} vendent à {person3} le "
|
| 164 |
+
"bien cadastré {cadastre1} à {city1}, au prix de {amount1}. "
|
| 165 |
+
"Séquestre de {amount2} versé chez Me {person4}, notaire. Signature "
|
| 166 |
+
"de l'acte authentique prévue le {date1}.",
|
| 167 |
+
|
| 168 |
+
"Assemblée générale du {date1} — copropriété {address1}, {city1}. "
|
| 169 |
+
"Le syndic {company1} appelle une provision de {amount1} par lot. "
|
| 170 |
+
"Le président de séance, {person1}, est joignable à {email1}.",
|
| 171 |
+
|
| 172 |
+
"Quittance de loyer — {person1} atteste que {person2} a réglé "
|
| 173 |
+
"{amount1} pour le logement situé {address1} à {city1}, période du "
|
| 174 |
+
"{date1}. Paiement reçu par virement depuis le compte {iban1}.",
|
| 175 |
+
],
|
| 176 |
+
"email_client": [
|
| 177 |
+
"Bonjour {person1}, votre commande est expédiée à {address1}, "
|
| 178 |
+
"{city1}. Pour toute question, répondez à ce mail ou appelez le "
|
| 179 |
+
"{phone1}. Votre numéro client reste inchangé.",
|
| 180 |
+
|
| 181 |
+
"Bonjour, je n'arrive pas à me connecter avec {email1}. Pouvez-vous "
|
| 182 |
+
"me rappeler au {phone1} ? Cordialement, {person1}, {company1}.",
|
| 183 |
+
|
| 184 |
+
"Suite à notre échange, je vous confirme le RIB : {iban1}. La "
|
| 185 |
+
"connexion depuis l'adresse IP {ip1} a bien été vérifiée. Bien à "
|
| 186 |
+
"vous, {person1}.",
|
| 187 |
+
|
| 188 |
+
"Madame, Monsieur, je souhaite résilier mon abonnement souscrit le "
|
| 189 |
+
"{date1}. Mes références : {person1}, {address1}, {city1}, "
|
| 190 |
+
"carte utilisée : {card1}. Merci de confirmer par retour à "
|
| 191 |
+
"{email1}.",
|
| 192 |
+
|
| 193 |
+
"Salut, c'est {person1}. Le livreur est passé au {address1} mais "
|
| 194 |
+
"j'étais à {city1}. Tu peux le rappeler au {phone1} ? Sinon mail à "
|
| 195 |
+
"{email1}. Merci !",
|
| 196 |
+
|
| 197 |
+
"Objet : contestation de prélèvement — Un débit de {amount1} du "
|
| 198 |
+
"{date1} apparaît sur mon compte {iban1} au profit de {company1}. "
|
| 199 |
+
"Je n'ai rien commandé. {person1}, cliente depuis 2019, {phone1}.",
|
| 200 |
+
|
| 201 |
+
"Bonjour {person1_v}, nous avons bien reçu le dossier de {person1}. "
|
| 202 |
+
"Il manque la copie de la carte grise du véhicule {plate1} et un "
|
| 203 |
+
"RIB. Vous pouvez les déposer sur votre espace ou les envoyer à "
|
| 204 |
+
"{email1}.",
|
| 205 |
+
],
|
| 206 |
+
"assurance_banque": [
|
| 207 |
+
"Déclaration de sinistre — {person1}, contrat n° {ref1}, véhicule "
|
| 208 |
+
"{plate1}. Accident survenu le {date1} à {city1} ; tiers identifié : "
|
| 209 |
+
"{person2}, assuré chez {company1}. Devis réparation : {amount1}. "
|
| 210 |
+
"Contact : {phone1}.",
|
| 211 |
+
|
| 212 |
+
"Votre crédit immobilier — {person1}, né le {date_birth1}, emprunte "
|
| 213 |
+
"{amount1} auprès de {company1}. Mensualité : {amount2}, prélevée "
|
| 214 |
+
"sur le compte {iban1} à partir du {date1}. Conseiller : {person2}, "
|
| 215 |
+
"{email1}.",
|
| 216 |
+
|
| 217 |
+
"Résiliation du contrat santé n° {ref1} — Assuré principal : "
|
| 218 |
+
"{person1}, NIR {nir1}. La résiliation prend effet le {date1}. Le "
|
| 219 |
+
"trop-perçu de {amount1} sera remboursé sur l'IBAN {iban1}.",
|
| 220 |
+
|
| 221 |
+
"Alerte sécurité — une connexion à votre espace bancaire a été "
|
| 222 |
+
"détectée depuis l'IP {ip1} le {date1}. Si vous n'êtes pas à "
|
| 223 |
+
"l'origine de cette opération, contactez le {phone1}. Votre carte "
|
| 224 |
+
"{card1} a été temporairement bloquée. {company1}.",
|
| 225 |
+
],
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
TEMPLATES_EVAL = {
|
| 229 |
+
"juridique": [
|
| 230 |
+
"SIGNIFICATION D'ACTE — À la requête de {company1} (SIREN {siren1}), "
|
| 231 |
+
"j'ai signifié à {person1}, demeurant {address1} à {city1}, une "
|
| 232 |
+
"sommation de payer {amount1}. L'huissier, Me {person2}, certifie "
|
| 233 |
+
"la remise le {date1}. Dossier RG {rg1}.",
|
| 234 |
+
|
| 235 |
+
"Requête devant le JAF — {person1} et {person2} sollicitent la "
|
| 236 |
+
"fixation de la résidence des enfants. {person1_v}, sans emploi "
|
| 237 |
+
"depuis le {date1}, demande une pension de {amount1}. Audience à "
|
| 238 |
+
"{city1}, RG n° {rg1}. Avocat : Me {person3}, {phone1}.",
|
| 239 |
+
|
| 240 |
+
"Le notaire soussigné atteste que la parcelle {cadastre1}, commune "
|
| 241 |
+
"de {city1}, a été vendue par {person1} (né le {date_birth1}) à "
|
| 242 |
+
"{company1} pour {amount1}. Le prix a transité par le compte "
|
| 243 |
+
"séquestre {iban1}. {person1_v} a donné quittance.",
|
| 244 |
+
],
|
| 245 |
+
"compta": [
|
| 246 |
+
"RELANCE 3 — {company1}, votre échéance du {date1} ({amount1}, "
|
| 247 |
+
"facture {ref1}) demeure impayée malgré nos courriers. Sans "
|
| 248 |
+
"règlement sur {iban1} sous 8 jours, transmission au contentieux. "
|
| 249 |
+
"Votre interlocutrice : {person1}, {phone1}.",
|
| 250 |
+
|
| 251 |
+
"AVIS DE MODIFICATION — Greffe du Tribunal de Commerce de {city1}. "
|
| 252 |
+
"{company1}, société par actions simplifiée au capital de "
|
| 253 |
+
"{amount1}, RCS {siren1}. Aux termes des décisions du {date1}, "
|
| 254 |
+
"{person1_v} a été nommé président en remplacement de {person2}, "
|
| 255 |
+
"démissionnaire. Siège : {address1}, {city2}.",
|
| 256 |
+
|
| 257 |
+
"Écriture d'inventaire — provision de {amount1} sur la créance "
|
| 258 |
+
"{company1} (SIRET {siret1}). Le client, représenté par {person1}, "
|
| 259 |
+
"est en redressement depuis le {date1}. Dotation validée par "
|
| 260 |
+
"{person2_v} le {date2}.",
|
| 261 |
+
],
|
| 262 |
+
"rh": [
|
| 263 |
+
"PROMESSE D'EMBAUCHE — {company1} s'engage à recruter {person1}, "
|
| 264 |
+
"domicilié {address1} à {city1}, à compter du {date1}. Salaire "
|
| 265 |
+
"annuel brut : {amount1}. Réponse attendue avant le {date2} à "
|
| 266 |
+
"{email1}. NIR à fournir : {nir1}.",
|
| 267 |
+
|
| 268 |
+
"Registre du personnel — entrée n° {ref1} : {person1}, né le "
|
| 269 |
+
"{date_birth1} à {city1}, embauché le {date1}. Sortie le {date2}. "
|
| 270 |
+
"{person1_v} a été déclaré via la DPAE (SIRET {siret1}).",
|
| 271 |
+
],
|
| 272 |
+
"immobilier": [
|
| 273 |
+
"MANDAT DE GESTION — {person1} confie à l'agence {company1} la "
|
| 274 |
+
"gestion du bien sis {address1}, {city1} (cadastre {cadastre1}). "
|
| 275 |
+
"Honoraires : {amount1} TTC/an. Les loyers seront reversés sur "
|
| 276 |
+
"l'IBAN {iban1}. Fait le {date1}. {person1_v}, propriétaire.",
|
| 277 |
+
],
|
| 278 |
+
"email_client": [
|
| 279 |
+
"Bonjour, je vous écris pour {person1}, ma mère, qui n'a pas "
|
| 280 |
+
"internet. Elle habite {address1} à {city1} et son dossier porte le "
|
| 281 |
+
"n° {ref1}. Merci de la rappeler au {phone1}. Sa date de naissance "
|
| 282 |
+
"est le {date_birth1}. Cordialement, {person2}.",
|
| 283 |
+
|
| 284 |
+
"URGENT : fuite d'eau au {address1} ! Le plombier demande {amount1} "
|
| 285 |
+
"pour intervenir ce soir. Je valide ? Répondez-moi vite au {phone1} "
|
| 286 |
+
"ou sur {email1}. {person1_v}.",
|
| 287 |
+
],
|
| 288 |
+
"assurance_banque": [
|
| 289 |
+
"Avenant au contrat {ref1} — À compter du {date1}, le véhicule "
|
| 290 |
+
"{plate1} remplace l'ancien véhicule de {person1}. Nouvelle prime "
|
| 291 |
+
"annuelle : {amount1}, prélevée sur {iban1}. Signature électronique "
|
| 292 |
+
"envoyée à {email1}.",
|
| 293 |
+
],
|
| 294 |
+
}
|
| 295 |
+
|
| 296 |
+
# Segments sans AUCUNE PII : mesurent le sur-masquage / les faux positifs.
|
| 297 |
+
# {refN} y est autorise (distracteur numerique non etiquete).
|
| 298 |
+
NEGATIVES = [
|
| 299 |
+
"Le serveur de production a redémarré trois fois cette semaine. Le "
|
| 300 |
+
"ticket {ref1} reste ouvert : les sauvegardes nocturnes échouent quand "
|
| 301 |
+
"le volume dépasse 80 %. Une intervention est planifiée hors heures "
|
| 302 |
+
"ouvrées.",
|
| 303 |
+
|
| 304 |
+
"Rappel : la salle de réunion du deuxième étage est réservée aux "
|
| 305 |
+
"formations jusqu'à la fin du mois. Merci de privilégier les salles du "
|
| 306 |
+
"rez-de-chaussée pour les points d'équipe.",
|
| 307 |
+
|
| 308 |
+
"Le rapport trimestriel montre une hausse de la fréquentation du site "
|
| 309 |
+
"et une baisse du taux de rebond. Les pages produit convertissent mieux "
|
| 310 |
+
"depuis la refonte. Détail complet dans le tableau de bord interne.",
|
| 311 |
+
|
| 312 |
+
"Procédure qualité {ref1} : tout lot non conforme doit être isolé en "
|
| 313 |
+
"zone rouge, étiqueté, et consigné dans le registre des non-conformités "
|
| 314 |
+
"avant décision du responsable de production.",
|
| 315 |
+
|
| 316 |
+
"La maintenance de l'ascenseur B est reportée. L'accès aux étages se "
|
| 317 |
+
"fait par l'escalier nord. Les livraisons volumineuses sont à "
|
| 318 |
+
"programmer avec l'accueil.",
|
| 319 |
+
|
| 320 |
+
"Bonjour à tous, la cantine propose un nouveau menu végétarien le "
|
| 321 |
+
"jeudi. Les retours sur le formulaire interne sont bienvenus. Bonne "
|
| 322 |
+
"journée !",
|
| 323 |
+
]
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def _llm_pools() -> dict:
|
| 327 |
+
"""Squelettes generes par sous-agents LLM (bench/synth/llm_templates.py),
|
| 328 |
+
valides et repartis train/eval par hash. Fichier commite."""
|
| 329 |
+
import json
|
| 330 |
+
from pathlib import Path
|
| 331 |
+
|
| 332 |
+
merged = {"train": {}, "eval": {}}
|
| 333 |
+
for fn in ("templates_llm.json", "templates_correspondance.json"):
|
| 334 |
+
path = Path(__file__).resolve().parent / fn
|
| 335 |
+
if not path.exists():
|
| 336 |
+
continue
|
| 337 |
+
pools = json.loads(path.read_text(encoding="utf-8"))
|
| 338 |
+
for split in ("train", "eval"):
|
| 339 |
+
for domain, tpls in pools.get(split, {}).items():
|
| 340 |
+
merged[split].setdefault(domain, []).extend(tpls)
|
| 341 |
+
return merged
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
def all_templates(split: str) -> dict[str, list[str]]:
|
| 345 |
+
"""Pools de templates par split : train / eval / all (disjoints).
|
| 346 |
+
Fusionne les templates main et les squelettes LLM."""
|
| 347 |
+
llm = _llm_pools()
|
| 348 |
+
if split in ("train", "eval"):
|
| 349 |
+
hand = TEMPLATES_TRAIN if split == "train" else TEMPLATES_EVAL
|
| 350 |
+
merged = {d: list(t) for d, t in hand.items()}
|
| 351 |
+
for domain, tpls in llm[split].items():
|
| 352 |
+
merged.setdefault(domain, []).extend(tpls)
|
| 353 |
+
return merged
|
| 354 |
+
if split == "all":
|
| 355 |
+
merged = {}
|
| 356 |
+
for pool in (all_templates("train"), all_templates("eval")):
|
| 357 |
+
for domain, tpls in pool.items():
|
| 358 |
+
merged.setdefault(domain, []).extend(tpls)
|
| 359 |
+
return merged
|
| 360 |
+
raise ValueError(f"split inconnu : {split}")
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
# retro-compatibilite (bench_v0 a ete genere avec ce nom)
|
| 364 |
+
TEMPLATES = TEMPLATES_TRAIN
|