Documentation menuKnown names
Known names
Always replace the names you already know, such as the clients of an office.
The built-in recognisers find a name without title or context only when its first name is on the list. An application usually knows many of the names that can appear: an office knows its clients. Pass them, and they are always replaced.
from isomorphism import anonymize
from isomorphism.known import known_detector
clients = known_detector(["Arben Krasniqi", "Familie Muster", "Reinigung Blitzblank GmbH"])
safe, mapping = anonymize(text, detectors=[clients])
- Full names are found in any case and order:
Arben Krasniqi,KRASNIQI ARBEN,Krasniqi, Arben, also in a chat without capitals. An entry may be writtenKrasniqi, Arben, as offices export their clients: an entry with exactly one comma is read asNachname, Vorname, so leave the place out (Hans Muster, Zürichwould makeZüricha name word). Pass each client once: the same name entered in both orders counts as two names that share a form, see below. A particle starts the surname (Maria da Silva,Hans von Arx), soda Silva Mariais found too. Umlauts are also found as bank statements write them (RUEEGGandRueggforRüegg), accents also without them. All forms of one name get the same placeholder, so the model can follow who is meant;restore()gives back the first form seen in the text, not each spelling as it was. A title before the name (Herr) stays visible. Confidence 0.99,detector == "known". - A single word of a name (
Krasniqi,Arben) is found when it is capitalised or in a line in capitals, with a placeholder of its own that all its spellings share. An entry of one word (Keller) is only such a single word. Surnames that are also ordinary words or places (Keller,Koch,Weber,Zug,Pierre…) are not replaced alone; the patterns still find them after a title. This list is best effort: German writes every noun with a capital, so a client named like a noun can be replaced where the noun is meant. Confidence 0.6,detector == "known-word". - Groups such as
Familie Muster,Erben MusterorEhepaar Musterare found as written, andMusteralone as above. A double surname (Zumsteg-Keller) also gives its halves of four letters or more. - Companies are found with and without the legal form, in any case (
Reinigung Blitzblank GmbH,REINIGUNG BLITZBLANK GMBH,Reinigung Blitzblank), and by the remaining name alone when it is a single word of four letters or more (Blitzblank). Quotes in the entry do not count. - A string with a legal form,
Verein …,…genossenschaft …, a trade (Bäckerei …), a business word (Muster Immobilien,Muster Treuhand) or&is a company, any other a person. A sole proprietorship with a plain name (Hans Muster) cannot be told from a person: pass("ORG", name)or("PERSON", name)to say it yourself. At most 5,000 names. - When two entries share a form (
Martin ThomasandThomas Martin), that form keeps its own placeholder per spelling, sorestore()never swaps them.
Not found yet: a name broken over two lines, initials (A. Krasniqi), genitive and possessive forms (Krasniqis, Krasniqi's), hyphen variants of a name entered without hyphen, a non-breaking space between the words of a full name, ' and ’ swapped, and names that start with a sign ('t Hooft, +GF+ AG). keep= compares the text of each hit: keeping Arben Krasniqi does not keep Krasniqi, Arben.
Build the detector once and keep it while the names do not change. The package keeps nothing between calls: holding the detector (and with it the names) is up to you. Names of authorities stay protected as for every other recogniser.
The README section "Acceptance" shows what known names add on the blind test sets: with every full name of a text known, set C reaches 76 % of the names without a title (patterns alone: 51 %) and all companies, and neither the clients nor 500 unrelated names add a false alarm.