This commit is contained in:
Lars committed 2026-08-28 08:40:28 +02:00
1 parent f17b3083e8
commit 4f37991ad1
48 files changed
+4919 -540

No files matched your search

+24
View File
@@ -182,6 +182,28 @@ def confirmed_match_labels(item: dict) -> list[str]:
return labels
def mapping_spellings(item: dict) -> list[str]:
"""All known writings of one mapping: canonical, aliases, observed label, demask form."""
seen: set[str] = set()
result: list[str] = []
def add(raw) -> None:
label = (raw or "").strip()
if not label or label.casefold() in seen or not is_maskable_label(label):
return
seen.add(label.casefold())
result.append(label)
add(item.get("local_label"))
add(item.get("canonical_label"))
add(item.get("demask_label"))
for alias in item.get("aliases") or []:
add(alias)
for label in item.get("labels") or []:
add(label)
return result
def masking_rows_from_confirmed(profile_id: str) -> list[dict]:
"""One masking row per confirmed canonical label or alias. Demask uses canonical."""
rows: list[dict] = []
@@ -202,6 +224,8 @@ def masking_rows_from_confirmed(profile_id: str) -> list[dict]:
"demask_label": canonical,
"entity_type": entity_type,
"source": "confirmed_registry",
"aliases": [item for item in confirmed_match_labels(item) if item.casefold() != label.casefold()],
"labels": confirmed_match_labels(item),
}
)
return rows