Sub topic 5
Preparing names for comparison
This chapter assumes you know what a sanctions list is and why firms screen against it. It also assumes you can read basic Python. The chapter covers the step that comes before any matching: turning a raw name into a standard form. Matching techniques come in the next chapter.
Why preparation comes first
A screening engine compares a name from your system with names on a list. Both names reach the engine in whatever form someone typed or published them. "JOSÉ O'BRIEN-SMITH", "Jose OBrien Smith" and " josé o’brien‑smith " are the same person. A byte-for-byte comparison treats them as three different strings.
Preparation (also called normalization) maps these surface differences onto one standard form. A fuzzy matcher can sometimes absorb small differences, but each formatting difference it has to absorb uses up some of the score margin. That margin is better spent on real spelling variation. Clean input also makes the score easier to explain to a reviewer or an auditor.
The core steps
Unicode decomposition and accent removal
Unicode can represent "é" as one character or as "e" followed by a combining accent mark. Two strings that look identical on screen may therefore differ in memory. The NFKD form (compatibility decomposition) splits every accented letter into a base letter plus combining marks. It also converts compatibility characters such as full-width letters and ligatures to plain forms. After that, you drop the combining marks.
Case folding
Use casefold() rather than lower(). Casefolding is designed for comparison and handles cases such as the German "ß", which becomes "ss".
Punctuation and whitespace
Hyphens, apostrophes, commas, full stops and typographic variants (the curly ’ versus the straight ') all become spaces. Then collapse runs of whitespace into single spaces and trim the ends. This gives you a clean list of tokens, which are the words that make up the name.
The base function
This is the function from the topic plan. Run it to see the result.
import re
import unicodedata
def normalize(name: str) -> str:
"""Lowercase, strip accents and punctuation, collapse whitespace."""
decomposed = unicodedata.normalize("NFKD", name)
no_accents = "".join(c for c in decomposed if not unicodedata.combining(c))
lowered = no_accents.casefold()
no_punct = re.sub(r"[^\w\s]", " ", lowered)
return " ".join(no_punct.split())
print(normalize(" José O'Brien-Smith "))The output is jose o brien smith.
Notice that "O'Brien" became two tokens, "o" and "brien". That is a design decision, not a neutral cleanup. A list entry written "OBRIEN" would have one token where yours has two. The section on variants below covers this.
What the base function misses
The function above is a sound start, but it has gaps that matter in real screening data.
Letters that do not decompose
Some letters carry a stroke or bar that is part of the letter, not a combining mark. Examples are "ø", "ł", "đ", "æ" and "þ". NFKD leaves them alone, so "Ørsted" and "Orsted" still differ. You need an explicit mapping table.
Scripts where combining marks carry meaning
Removing combining marks is safe for Latin text, where accents are decoration for matching purposes. In scripts such as Devanagari and Thai, combining marks include vowel signs that are part of the spelling. Stripping them damages the name. Apply accent removal only to Latin-script text, or screen non-Latin names in their original script and in a transliteration (see below).
Entity suffixes
For companies, "Acme Trading Ltd", "Acme Trading Limited" and "ACME TRADING L.T.D." should compare as close. A normalized "l t d" is three tokens that can distort a score. Many programs keep a list of legal-form words (limited, ltd, llc, gmbh, sa) and strip or down-weight them. Because a suffix can also distinguish two different companies, keep the original available for review.
Titles and noise words
Customer forms often capture "Mr", "Dr" or "Sheikh" inside the name field. List entries rarely include them. Removing a short, controlled list of titles improves scores. Do not remove words that could be real name parts.
A fuller normalizer with variants
Normalization can produce more than one form per name. When the right treatment of a token is uncertain, generate both forms and screen both. Keep the lists of tokens small and reviewed.
import re
import unicodedata
SPECIAL = str.maketrans(
{"ø": "o", "ł": "l", "đ": "d", "æ": "ae", "œ": "oe", "þ": "th"}
)
TITLES = {"mr", "mrs", "ms", "dr", "prof", "sir"}
PARTICLES = {"al", "el", "bin", "ibn", "van", "von", "de", "del", "da"}
def normalize(name: str) -> str:
decomposed = unicodedata.normalize("NFKD", name)
stripped = "".join(c for c in decomposed if not unicodedata.combining(c))
lowered = stripped.casefold().translate(SPECIAL)
cleaned = re.sub(r"[^\w\s]|_", " ", lowered)
return " ".join(cleaned.split())
def variants(name: str) -> set:
"""Return the normalized name plus a form with particles joined."""
tokens = [t for t in normalize(name).split() if t not in TITLES]
base = " ".join(tokens)
merged = []
i = 0
while i < len(tokens):
if tokens[i] in PARTICLES and i + 1 < len(tokens):
merged.append(tokens[i] + tokens[i + 1])
i += 2
else:
merged.append(tokens[i])
i += 1
return {base, " ".join(merged)}
print(normalize("Ørsted Łukasz Straße"))
print(sorted(variants("Dr. Mohammed Al-Sayed")))The output is:
orsted lukasz strasse
['mohammed al sayed', 'mohammed alsayed']The second line shows why variants help. A list might record the surname as "Al Sayed", "Al-Sayed" or "Alsayed". Screening both the split and joined forms covers all three without relying on the fuzzy score alone.
Transliteration and non-Latin scripts
Sanctions lists are published mainly in Latin script, but many listed persons come from names originally written in Cyrillic, Arabic, Chinese or other scripts. There is no single correct Latin spelling for such names. "Мухаммед", for example, appears as Muhammad, Mohammed, Mohamed and Muhamad. Three practices help:
- Screen the original script when the customer record has it, against list aliases that include the original script.
- When you transliterate, use a documented standard and record which one.
- Treat the spelling variants as the job of the matching stage (phonetic and fuzzy techniques), not of normalization. Normalization should be deterministic and explainable. It should not guess.
Applying the same rules to both sides
The most common error in this area is normalizing one side only. The rules must run identically on the customer data and on the list data, and on every list you screen. If the list vendor delivers pre-normalized names, you still apply your own rules to the customer side, and you check that the two sets of rules agree. A small difference, such as one side keeping the apostrophe as a space and the other deleting it, will quietly lower scores across thousands of records.
Other practices that prevent silent failures:
- Keep the original. Store the raw name next to the normalized one. Reviewers need to see what the customer actually provided, and an audit trail needs it.
- Version your rules. Record which version of the normalizer produced each screening result. If you change a rule, you can explain why the same name scored differently last quarter.
- Handle empty results. A name made only of symbols or an unsupported script can normalize to an empty string. Treat that as a data-quality exception for review. Do not let it screen as "no match".
- Normalize other fields consistently. Dates of birth, country names and identifier numbers (remove spaces and hyphens from a passport number, for example) need their own normalization before you can use them as secondary identifiers.
Summary of common transformations
| Transformation | Example | Main risk |
|---|---|---|
| Accent removal (NFKD) | José to jose | Damages scripts where marks are letters |
| Case folding | STRASSE, Straße to strasse | None for matching purposes |
| Special letter mapping | Ørsted to orsted | Mapping table must be maintained |
| Punctuation to space | O'Brien to o brien | Token count differs from "OBrien" |
| Title removal | Dr Jane Doe to jane doe | Removing a real name part |
| Legal suffix handling | Acme Ltd to acme | Merging two different companies |
| Particle joining | Al Sayed to alsayed | Creates forms absent from lists |
Edge cases to plan for
- Single-token names. Some people have one name only. Tokens-sorted comparisons still work, but the score is more sensitive, so review the volume of alerts this produces.
- Initials. "J. R. Smith" normalizes to "j r smith". Decide whether single letters should be kept. Dropping them can make different people look identical. Keeping them lowers scores against a full name.
- Very long or concatenated fields. Some systems store the full name in one field, others in separate given-name and family-name fields. Join the parts consistently before normalizing, and be aware that name order differs by culture.
- Numbers and symbols in entity names. "7-Eleven" or "A&B Holdings" contain characters your rules may turn into spaces or remove. Test a few.
- Characters outside your expected range. Run a periodic report of characters seen in incoming names that your rules do not handle. New scripts or unusual symbols are an early sign of data-quality problems.
Exercises
Exercise
A normalizer removes accents with NFKD and strips combining marks. A customer's name is written in Devanagari script. What is the risk of applying the same rule, and what should you do instead?
Show answer
In Devanagari, combining marks include vowel signs that are part of the spelling, so stripping them corrupts the name and can cause both false matches and missed matches. Apply accent removal only to Latin-script text. Screen the original script against list aliases in that script, or use a documented transliteration, and keep the original name for review.
Exercise
Your normalizer turns "O'Brien" into "o brien", but a list entry arrives as "OBRIEN". Name two ways to deal with this, and say which part of the pipeline each belongs to.
Show answer
One way is to generate variants during normalization, for example screening both "o brien" and "obrien". This belongs to the preparation stage and is deterministic and explainable. The other way is to rely on the fuzzy matching stage to score "o brien" against "obrien" as similar. This belongs to the matching stage and uses up some score margin. Both rules, and their effect on alert volume, should be tested and documented.
Exercise
Why must the same normalization rules be applied to the customer data and to the list data, and what should you record about them?
Show answer
If the two sides are normalized differently, equal names produce different keys and scores fall without any visible error, so true matches can be missed. Record the version of the normalization rules used for each screening result, and store the original raw name beside the normalized one, so a later reviewer or auditor can reproduce and explain the result.