Buckets:

download
raw
1.25 kB
from __future__ import annotations
from dataclasses import dataclass
from enum import Enum
class PiiType(str, Enum):
NAME = "NAME"
IBAN = "IBAN"
CREDIT_CARD = "CREDIT_CARD"
PERSONAL_ID = "PERSONAL_ID"
SOCIAL_SECURITY = "SOCIAL_SECURITY"
TAX_ID = "TAX_ID"
PHONE = "PHONE"
EMAIL = "EMAIL"
ADDRESS = "ADDRESS"
SECRET = "SECRET"
URL_SECRET = "URL_SECRET"
KVNR = "KVNR"
LICENSE_PLATE = "LICENSE_PLATE"
VAT_ID = "VAT_ID"
DRIVER_LICENSE = "DRIVER_LICENSE"
@dataclass(frozen=True)
class Finding:
pii_type: PiiType
start: int
end: int
text: str
confidence: float
placeholder: str
rule_id: str | None = None # set by SecretDetector to identify which rule matched
def __len__(self) -> int:
return self.end - self.start
@dataclass
class ScanResult:
original_text: str
anonymised_text: str
findings: list[Finding]
mapping: dict[str, str] # placeholder -> original
def restore(self, text: str) -> str:
"""Replace placeholders in text with their original values."""
result = text
for placeholder, original in self.mapping.items():
result = result.replace(placeholder, original)
return result

Xet Storage Details

Size:
1.25 kB
·
Xet hash:
4d6e434703df1989c20c008ef8c770b1a505d22aa2881bbe7f3b3b3f51d68f3c

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.