SPEC 05 · DATA SYSTEMS

نسخه فارسی

Persian contact enrichment and name resolution

Production specification for sanitising, indexing and matching high-volume Persian name and location datasets. Deterministic normalisation first, then blocking keys, lightweight scoring, and residual embedding only where needed — at tens to hundreds of millions of records.

1. Introduction and scope

Large Persian-language datasets contain multiple surface forms of the same real-world entity. Person names, organisation titles and place names appear with inconsistent character encodings, optional honorifics, variable compound spacing, phonetic letter substitutions and inverted token order. When these variations exist across independent source systems, exact string matching becomes insufficient.

This blueprint is deliberately layered: inexpensive deterministic transformations execute first, followed by blocking keys that sharply reduce the candidate space, then lightweight string metrics, and only on residual hard pairs more expensive embedding models. The same stages can run in Python (Spark, DuckDB, Pandas), SQL engines, and NoSQL platforms such as Elasticsearch.

2. Structural challenges of Persian text at scale

Persian orthography creates several interacting sources of variation that must be addressed before reliable matching is possible.

Smart DB v1 Architecture

Architected Smart DB processing 100 million distinct records. Engineered a dynamic scoring matrix delivering 70% predictive accuracy for user preferences prior to KYC data ingestion. Integrated real-time operator usage APIs for historical behavioral analysis, decoupling external data aggregation from core storage.

Character encoding and script variants

The same letter may be represented by different Unicode code points (ي vs ی, ك vs ک). Diacritics and tatweel appear inconsistently. NFC alone does not resolve them; an explicit language-specific mapping is required.

Zero-Width Non-Joiner versus space

Compound words and certain prefixes/suffixes are conventionally written with ZWNJ (U+200C). In practice the same unit may appear fully joined, space-separated, or correctly joined with ZWNJ. Tokenisation stays unreliable until these forms share one regime.

Phonetic letter substitution

Modern Iranian Persian has merged several Arabic consonants that remain distinct in writing. The /z/ group (ز ذ ض ظ), /s/ group (س ص ث), /t/ pair (ت ط), /h/ pair (ه ح) and /ɣ~q/ pair (غ ق) are frequently interchanged. A phonetic collapse step is essential for effective blocking.

Token order and honorifics

Administrative records often store names in inverted order. Titles (دکتر، مهندس، سید، حاج، بانو …) appear as prefixes or free tokens. They must be isolated into metadata or rendered order-invariant before matching.

Missing short vowels and homographs

Short vowels are almost never written. The four-letter string ملک can be malak, malek, melk or molk. Pure string methods cannot disambiguate; residual cases need external knowledge or contextual models.

3. Pipeline architecture

Five sequential stages. Each is independently executable so intermediate results can be materialised, audited and re-processed.

  1. Ingestion and basic validation — schema checks, null handling, source tagging.
  2. Deterministic normalisation — character mapping, diacritic removal, ZWNJ standardisation, honorific isolation.
  3. Blocking-key generation — phonetic skeleton and sorted-token fingerprint.
  4. Candidate generation — records sharing both keys form small comparison groups.
  5. Similarity scoring and decision — rapid token-based metrics first; residual pairs may receive embedding-based scores.

Figure 1. End-to-end Persian name cleaning and entity-resolution pipeline. Stages progress from raw ingestion through deterministic normalisation, blocking-key generation, candidate-pair formation and final similarity scoring.

4. Deterministic normalisation layers

The first transformation layer must be fully deterministic and reversible for audit purposes.

Character and encoding normalisation

Arabic letter forms are mapped to their Persian counterparts. Combining diacritics and tatweel are stripped. This eliminates the most common encoding-induced false negatives.

Compound spacing and ZWNJ handling

Known verbal prefixes (می، نمی، بی) and common plural/possessive suffixes are rewritten so a consistent ZWNJ (or space, by house style) separates the morpheme from the stem. Remaining runs of whitespace and ZWNJ are collapsed.

Honorific and title isolation

A controlled dictionary of high-frequency titles is matched. Matched tokens move to a secondary metadata column rather than being deleted. Core personal-name tokens remain available for matching while original title presence is preserved for audit.

5. Blocking keys for candidate generation

After normalisation, exact string equality remains too strict. Blocking constructs inexpensive keys that place likely matches into the same partition so expensive pairwise comparison occurs only inside small groups.

Phonetic skeleton

Letters belonging to the same modern Iranian phoneme class collapse to a single representative. Vowels and weak letters are removed; consecutive duplicate consonants are compressed. Orthographic variants that differ only by phonetic substitution land in the same bucket.

Sorted token fingerprint

The cleaned name is split into tokens, stop-words and single-character tokens are discarded, remaining tokens are sorted alphabetically and concatenated. The key is invariant to the order of given name and family name.

Figure 2. Multiple observed surface forms of a single identity converge, after normalisation, onto a shared phonetic key and sorted-token fingerprint.

6. Scoring residual pairs

Inside each blocking bucket the remaining pairs are scored with lightweight string metrics. Token-sort ratio and token-set ratio provide a strong first signal on cleaned Persian text. A weighted edit distance that assigns lower cost to substitutions inside the same phonetic group further improves ranking. Only the highest-ambiguity residual pairs need embedding models — this keeps cost acceptable at scale.

7. ParsBERT and residual neural scoring

ParsBERT remains the strongest monolingual foundation for Persian tasks that require deep understanding of orthographic variation and compound structure. In production the cross-encoder is reserved for the final ranking stage after aggressive blocking. Bi-encoders scale better when embeddings can be pre-computed. Parameter-efficient fine-tuning (LoRA) recovers nearly the same F1 as full fine-tuning while staying within consumer-GPU budgets.

8. Location and city name handling

Place names show a more restricted vocabulary than personal names yet still display Arabic/Persian letter variation, optional administrative prefixes and Latin transliterations. Maintain a canonical dictionary of principal cities and provinces with their frequent variants; apply the same character and spacing normalisation; look up the normalised string; unmatched values fall back to phonetic blocking and fuzzy scoring.

Figure 3. Example of city-name normalisation. Surface variants in Persian, Arabic-influenced and Latin scripts collapse to a single canonical identifier after cleaning.

9. Operational considerations and quality gates

  • Materialised intermediate tables — each major stage writes Parquet so any step can be re-run independently.
  • Quality metrics — track the percentage of records that receive a blocking key, average candidate-bucket size, and similarity-score distribution.
  • Threshold calibration — decision thresholds are domain-specific (person vs organisation vs location) and should be tuned on a stratified sample.
  • Auditability — original raw values, intermediate normalised forms and final match decisions are retained.
  • Dual-script indexing — when Latin transliterations coexist with Persian script, maintain parallel normalised keys that both resolve to the same master entity identifier.

The objective of an enterprise pipeline is to maximise the proportion of records that can be linked automatically with high confidence, while producing a compact, ranked residual set that can be handled by downstream processes or controlled review.