Backend & AI Engineer: Entity Resolution & Manufacturer Name Normalization in Python
When aggregating B2B supply-chain catalogs, financial vendor ledgers, or healthcare provider directories across dozens of external feeds, the same corporate entity appears under dozens of surface variations: "HRS", "Hirose Electric Co., Ltd.", "HIROSE ELECTRIC (USA) INC.", or "Texas Instruments Incorporated" vs. "TI". Naive exact-string joins fragment inventory counts and break facet filters. As a Backend Engineer and AI Application Engineer, I build multi-stage entity resolution pipelines in Python combining deterministic legal-suffix stripping, alias lookup tries, Jaro-Winkler / trigram similarity, and vector embedding disambiguation.
1. Stage 1: Deterministic Unicode Folding, Legal Suffix Stripping & Alias Dictionary Lookup
95% of incoming manufacturer strings should be resolved in microseconds via deterministic normalization and an in-memory canonical alias map before ever touching fuzzy string distance or LLM calls:
import re
import unicodedata
CORPORATE_SUFFIX_RE = re.compile(
r"(co\.?|ltd\.?|inc\.?|incorporated|corp\.?|corporation|gmbh|ag|plc|llc|holdings|electric|electronics)",
re.IGNORECASE,
)
NON_ALNUM_RE = re.compile(r"[^a-z0-9]+")
CANONICAL_ALIAS_MAP = {
"hrs": "HIROSE_ELECTRIC",
"hirose": "HIROSE_ELECTRIC",
"ti": "TEXAS_INSTRUMENTS",
"texasinstruments": "TEXAS_INSTRUMENTS",
"murata": "MURATA_MANUFACTURING",
}
def normalize_manufacturer_key(raw_name: str) -> str:
folded = unicodedata.normalize("NFKC", raw_name).casefold()
without_parens = re.sub(r"\([^)]*\)", " ", folded)
stripped_corp = CORPORATE_SUFFIX_RE.sub(" ", without_parens)
compact = NON_ALNUM_RE.sub("", stripped_corp)
return CANONICAL_ALIAS_MAP.get(compact, compact.upper())
2. Stage 2: PostgreSQL `pg_trgm` + `pgvector` Hybrid Candidate Resolution
When a newly ingested supplier string does not match the deterministic alias map, our pipeline queries PostgreSQL using a combined pg_trgm trigram index (`similarity(alias_name, $1) > 0.55`) and `pgvector` embedding cosine similarity, auto-merging matches above `0.94` confidence and routing borderline candidates (`0.78 - 0.94`) to a human-in-the-loop curation queue—powering our real-time BOM upload & supplier quoting engine and PostgreSQL-to-Elasticsearch catalog search pipelines.
Need a Backend Engineer or AI Application Engineer to solve entity resolution and catalog deduplication at scale? Book a 1-Day Engineering Sprint.