Person name normalization: strip titles, suffixes, resolve nicknames to canonical forms
Project description
corp-names
Person name normalization library. Strips titles, suffixes, middle initials, and resolves nicknames to canonical forms.
Installation
pip install corp-names
Usage
from corp_names import normalize_name
result = normalize_name("Dr. Bob Smith Jr.")
print(result.normalized) # "robert smith"
print(result.first) # "robert"
print(result.last) # "smith"
print(result.prefix) # "dr"
print(result.suffix) # "jr"
CLI
corp-names normalize "Dr. Bob Smith Jr."
# Original: Dr. Bob Smith Jr.
# Normalized: robert smith
# First: robert
# Last: smith
# Prefix: dr
# Suffix: jr
# Nickname: resolved to canonical form
corp-names normalize "Sir William H. Gates III" --json
Normalization Pipeline
- Unicode normalize (unidecode for accented characters)
- Strip punctuation (remove periods, commas; preserve hyphens)
- Tokenize by whitespace
- Strip prefixes (titles, honorifics)
- Strip suffixes (generational, credentials)
- Remove middle initials (single-letter tokens)
- Resolve nicknames to canonical forms
- Build normalized lowercase output
NormalizedName Model
class NormalizedName(BaseModel):
original: str # Original input
normalized: str # Full normalized lowercase name
first: str # First/given name (after nickname resolution)
last: str # Last/family name
prefix: str # Detected prefix(es), e.g. "dr"
suffix: str # Detected suffix(es), e.g. "jr"
nickname_resolved: bool # Whether first name was a nickname
Data
- Prefixes: ~150 titles and honorifics (military, religious, nobility, academic, political)
- Suffixes: ~600 credentials, generational markers, and honors (PhD, Jr, III, OBE, CPA)
- Nicknames: ~400 curated nickname-to-canonical mappings (bob→robert, liz→elizabeth, peggy→margaret)
All data is embedded as Python literals with no runtime dependency on external packages or files.
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file corp_names-0.1.0.tar.gz.
File metadata
- Download URL: corp_names-0.1.0.tar.gz
- Upload date:
- Size: 26.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e9e8b8bb205984affd7f278e6b458bce26849269a5cbb3a7a01ad2e478c07af
|
|
| MD5 |
04be78a346427affc67b50365cd444bb
|
|
| BLAKE2b-256 |
01ca5be4fe4793b557dc9cebff091da562749539a2b6d91d7ba64bb9a84d3f75
|
File details
Details for the file corp_names-0.1.0-py3-none-any.whl.
File metadata
- Download URL: corp_names-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6e04799d04c3768582fd8d9385094dc06af026dc758844af4128f51f20601cf
|
|
| MD5 |
fd6f9da0d5524b51b6da45eaa3f9cf24
|
|
| BLAKE2b-256 |
564e844576d87b3802e9a767505725efe67bf10ce49d92cb6470c62a077b4141
|