[docs]defget_pseudoanonymizer_mapping(seed:Optional[int]=None)->Dict[str,Callable]:"""Get a mapping of entities to pseudo anonymize them."""try:fromfakerimportFakerexceptImportErrorase:raiseImportError("Could not import faker, please install it with `pip install Faker`.")fromefake=Faker()fake.seed_instance(seed)# Listed entities supported by Microsoft Presidio (for now, global and US only)# Source: https://microsoft.github.io/presidio/supported_entities/return{# Global entities"PERSON":lambda_:fake.name(),"EMAIL_ADDRESS":lambda_:fake.email(),"PHONE_NUMBER":lambda_:fake.phone_number(),"IBAN_CODE":lambda_:fake.iban(),"CREDIT_CARD":lambda_:fake.credit_card_number(),"CRYPTO":lambda_:"bc1"+"".join(fake.random_choices(string.ascii_lowercase+string.digits,length=26)),"IP_ADDRESS":lambda_:fake.ipv4_public(),"LOCATION":lambda_:fake.city(),"DATE_TIME":lambda_:fake.date(),"NRP":lambda_:str(fake.random_number(digits=8,fix_len=True)),"MEDICAL_LICENSE":lambda_:fake.bothify(text="??######").upper(),"URL":lambda_:fake.url(),# US-specific entities"US_BANK_NUMBER":lambda_:fake.bban(),"US_DRIVER_LICENSE":lambda_:str(fake.random_number(digits=9,fix_len=True)),"US_ITIN":lambda_:fake.bothify(text="9##-7#-####"),"US_PASSPORT":lambda_:fake.bothify(text="#####??").upper(),"US_SSN":lambda_:fake.ssn(),# UK-specific entities"UK_NHS":lambda_:str(fake.random_number(digits=10,fix_len=True)),# Spain-specific entities"ES_NIF":lambda_:fake.bothify(text="########?").upper(),# Italy-specific entities"IT_FISCAL_CODE":lambda_:fake.bothify(text="??????##?##?###?").upper(),"IT_DRIVER_LICENSE":lambda_:fake.bothify(text="?A#######?").upper(),"IT_VAT_CODE":lambda_:fake.bothify(text="IT???????????"),"IT_PASSPORT":lambda_:str(fake.random_number(digits=9,fix_len=True)),"IT_IDENTITY_CARD":lambda_:lambda_:str(fake.random_number(digits=7,fix_len=True)),# Singapore-specific entities"SG_NRIC_FIN":lambda_:fake.bothify(text="????####?").upper(),# Australia-specific entities"AU_ABN":lambda_:str(fake.random_number(digits=11,fix_len=True)),"AU_ACN":lambda_:str(fake.random_number(digits=9,fix_len=True)),"AU_TFN":lambda_:str(fake.random_number(digits=9,fix_len=True)),"AU_MEDICARE":lambda_:str(fake.random_number(digits=10,fix_len=True)),}