Sub topic 5
Preparing names for comparison
This chapter covers name normalization, the step that runs before any matching. It assumes you know basic AML and customer due diligence, how onboarding and payment data reach a screening system, and enough Python to read the examples.
Why normalize first
A matching algorithm compares characters. It does not know that "José" and "Jose" are the same name, or that "O'Brien" and "OBrien" are close. If you compare raw strings, formatting differences produce low scores and a real match can be missed.
Normalization turns each name into a standard form before comparison. You apply the same steps to both sides: the customer name and every list entry. If you normalize only one side, the comparison is skewed.
The main normalization steps
| Step | Example input | Example output | Why it matters |
|---|---|---|---|
| Strip accents | José | Jose | Payment messages often drop diacritics |
| Fold case | AL-SAYED | al-sayed | Case carries no identity information |
| Remove punctuation | O'Brien-Smith | o brien smith | Hyphens and apostrophes are entered inconsistently |
| Collapse whitespace | "Jane Doe " | jane doe | Stray spaces break exact comparison |
Unicode makes accent handling less obvious than it looks. The letter "é" can be stored as one character or as "e" plus a combining accent mark. The function below uses the NFKD form, which splits accented letters into a base letter and a separate mark. It then drops the marks.
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 "))This prints jose o brien smith. Punctuation becomes a space, not an empty string. That choice means "Al-Sayed" becomes two tokens, "al" and "sayed", which also matches the spaced spelling "Al Sayed".
Choices that need a decision
The code above is a baseline. Real programs make further choices, and each one trades missed matches against extra alerts.
- Casefold or lower.
casefold()handles more cases thanlower(), such as the German "ß". Prefer it for comparison. - Punctuation as space or nothing. Replacing with a space keeps token boundaries. Deleting joins tokens, so "O'Brien" becomes "obrien". Pick one rule and apply it everywhere.
- Titles and honorifics. Words like "Mr", "Dr", or "Sheikh" often appear in customer data but not on lists. Many firms remove a defined set of them. Removing too many can erase part of a real name.
- Company suffixes. "Ltd", "LLC", and "GmbH" are common to many entities. They add similarity between unrelated companies, so firms often strip them or give them less weight.
- Non-Latin scripts. Names in Arabic, Cyrillic, or Chinese characters need transliteration into Latin letters. One name can have several valid spellings, such as "Mohammed", "Muhammad", and "Mohamed". Normalization does not solve this. Fuzzy and phonetic methods, covered in the next chapter, handle it.
Keep the original value
Never overwrite the source name. Store the normalized form beside the original and show analysts the original. They need the exact text to review an alert, and auditors need to see what was actually screened. Record which version of the normalization rules produced each result, because a change to the rules can change the alerts.
Common errors
- Normalizing the customer name but not the list entries, or the reverse.
- Removing digits or characters that matter in entity names, such as vessel identifiers.
- Treating only the first and last name as the name, which drops middle names and patronymics.
- Changing the rules without retesting, so alert volumes shift without explanation.
Exercise
Why does the normalize function replace punctuation with a space instead of deleting it, and what would "Al-Sayed" become under each choice?
Show answer
Replacing with a space keeps the word boundary, so "Al-Sayed" becomes "al sayed" (two tokens). That matches the spaced spelling "Al Sayed" and works with token-based comparison. Deleting punctuation gives "alsayed", a single token that will not line up with "al sayed". Either rule can work, but it must be applied the same way to customer names and list entries.
Exercise
A screening team adds a step that removes the words "bank", "trading", and "company" from every name before matching. Name one benefit and one risk.
Show answer
Benefit: unrelated entities stop matching just because they share common words, which cuts false positives. Risk: if a listed entity's distinguishing name is mostly one of those words, or the name becomes too short after removal, real matches can be missed or the remaining text can match too many unrelated names. The team should test the change against known true matches before deploying it.