40 lines
1.8 KiB
Python
40 lines
1.8 KiB
Python
"""Contrôle de labeling/carte-des-etiquettes.md : clés, events, étiquettes de l'expert, identifiants.
|
|||
|
|
|
||
|
|
python3 labeling/auto/revue-croisee/2026-11-04/carte/outils/controle_carte.py
|
||
|
|
Rend : clés citées absentes de labeling/manual/ et labeling/auto/, events cités absents de
|
||
|
|
events/INDEX.md, étiquettes revues de l'expert jamais citées, identifiants, taille.
|
||
|
|
"""
|
||
|
|
import glob
|
||
|
|
import json
|
||
|
|
import os
|
||
|
|
import re
|
||
|
|
|
||
|
|
RACINE = os.path.normpath(os.path.join(os.path.dirname(__file__), *[".."] * 6))
|
||
|
|
CLE = r"[A-Z][A-Z0-9_]{3,} \d\d\.\d\d \d\d:\d\d"
|
||
|
|
|
||
|
|
|
||
|
|
def cle(station, debut):
|
||
|
|
return f"{station} {debut[8:10]}.{debut[5:7]} {debut[11:16]}"
|
||
|
|
|
||
|
|
|
||
|
|
connues, expert = set(), set()
|
||
|
|
for chemin in glob.glob(f"{RACINE}/labeling/manual/*.jsonl") + glob.glob(f"{RACINE}/labeling/auto/*.jsonl"):
|
||
|
|
station = os.path.basename(chemin)[: -len(".jsonl")]
|
||
|
|
for ligne in open(chemin, encoding="utf-8"):
|
||
|
|
e = json.loads(ligne)
|
||
|
|
connues.add(cle(station, e["debut"]))
|
||
|
|
if "/manual/" in chemin and "revue" in e:
|
||
|
|
expert.add(cle(station, e["debut"]))
|
||
|
|
|
||
|
|
carte = open(f"{RACINE}/labeling/carte-des-etiquettes.md", encoding="utf-8").read()
|
||
|
|
index = open(f"{RACINE}/events/INDEX.md", encoding="utf-8").read()
|
||
|
|
citees = set(re.findall(CLE, carte))
|
||
|
|
events = set(re.findall(r"E-\d{3}", carte))
|
||
|
|
|
||
|
|
print("Clés inconnues :", sorted(citees - connues) or "aucune")
|
||
|
|
print("Events inconnus :", sorted(e for e in events if f"[{e}]" not in index) or "aucun")
|
||
|
|
print("Étiquettes de l'expert non citées :", sorted(expert - citees) or "aucune")
|
||
|
|
print("Identifiants :", re.findall(r"SIM_CCID|\bip(?:_\w+)?\b|\d+\.\d+\.\d+\.\d+", carte) or "aucun")
|
||
|
|
print(f"{len(citees)} clés, {len(events)} events, {len(carte.encode())} octets, {len(carte.splitlines())} lignes")
|
||
|
|
|
||
|
|
assert re.findall(CLE, "x [NORDEND 03.09 18:01] y") == ["NORDEND 03.09 18:01"]
|