Skip to main content

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. Includes 15,000+ name entries covering English nicknames, international variants, and CJK/Arabic/Japanese/Korean names.

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"

International name resolution

normalize_name("Guillaume de la Fontaine").normalized  # "william de la fontaine"
normalize_name("Prof. Klaus Müller").normalized         # "nicholas muller"
normalize_name("Giuseppe Rossi").normalized             # "joseph rossi"

Name lookup API

from corp_names import is_known_name, get_name_category

is_known_name("bob")          # True (nickname)
is_known_name("robert")       # True (canonical)
is_known_name("hiroshi")      # True (japanese)

get_name_category("bob")      # "common"
get_name_category("guillaume") # "international"
get_name_category("hiroshi")  # "japanese"

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

  1. Unicode normalize (unidecode for accented characters)
  2. Strip punctuation (remove periods, commas; preserve hyphens)
  3. Tokenize by whitespace
  4. Strip prefixes (titles, honorifics)
  5. Strip suffixes (generational, credentials)
  6. Remove middle initials (single-letter tokens)
  7. Resolve nicknames to canonical forms
  8. 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

All name data is stored in nicknames.json with categorized entries:

  • Nickname mappings (~1,350): resolve informal/international names to canonical forms
    • common: English nicknames (bob→robert, liz→elizabeth)
    • international: cross-language variants (guillaume→william, giuseppe→joseph)
    • archaic: historical nicknames (elsa→elizabeth, fanny→frances)
  • Standalone canonical names (~13,800): known first names with no mapping needed
    • canonical: Western names (mark, laura, emma, scott)
    • cjk: Chinese names (li, wang, zhang)
    • japanese: Japanese names (hiroshi, takashi, akira)
    • korean: Korean names (kim, park, choi)
    • arabic: Arabic/Islamic names (ali, omar, mustafa)
    • french_compound: French compound names (jean-pierre, marie-claire)
  • Prefixes: ~150 titles and honorifics (military, religious, nobility, academic, political)
  • Suffixes: ~600 credentials, generational markers, and honors (PhD, Jr, III, OBE, CPA)

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

corp_names-0.2.1.tar.gz (84.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

corp_names-0.2.1-py3-none-any.whl (77.4 kB view details)

Uploaded Python 3

File details

Details for the file corp_names-0.2.1.tar.gz.

File metadata

  • Download URL: corp_names-0.2.1.tar.gz
  • Upload date:
  • Size: 84.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for corp_names-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e8eb17131cf46e6d68c2ef7199eed85763137d3ae3caed9c4e1d2ff2e5272cf5
MD5 cf91c538a8034c6572554a1ef2c4feae
BLAKE2b-256 351e7a6a28a3d3448b75eb8d2dec96e41f6efc692b907a7da38a276548ca4fa3

See more details on using hashes here.

File details

Details for the file corp_names-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: corp_names-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 77.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.14

File hashes

Hashes for corp_names-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 05adc91531c8ca4a985560a96cd20b4b35e86917a502b2a9511feb791335b5f5
MD5 eedc41abe31294b9011d57ef5a40f4eb
BLAKE2b-256 80a12207857c8a4205d777322778e02d66675fad1d5195ecdf387d802ea9756b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page