What does Three-Way Brand Collision Pre-Screening conclude, in numbers, about “Soundex: a Century-Old Sound Code, Too Wide and Too Narrow”?

Answer: Chapter 2 implements Soundex from the U.S. National Archives guide and checks it example by example; on a synthetic lexicon 0.436 of same-code pairs differ by more than half in sound, and 0.093 of sound-keeping respellings change the code, all through the initial letter.

Scope of the numbers: In an illustrative model, with the sound channel at eight tenths, the AUC of the sound code is 0.851 against 0.817 for letter edit distance. Parameters are illustrative; all calculations are generated by the book's programs; the book is general analysis, not individualised legal advice, and judgements of trademark similarity rest with official searches in each jurisdiction and professional agents.

中文版

Data table

The numbers below are printed verbatim by the chapter's Python program and can be reproduced by running it. standard-library Python onlyprinted values that match the answer: 0.093, 0.436

distinct names 2764Soundex codes 503largest bucket 36
singleton codes 108
same-code pairs 15648far in sound skeleton 6818share 0.436
sound-keeping respellings 2710Soundex code changed 253share 0.093
of the changed codes, caused by a new first letter 253
Show the full program
# Chapter 2. p22: Soundex buckets are both too wide and too narrow.
# Model: 3000 random invented names (2 or 3 consonant-vowel syllables,
# fixed seed). Too wide: among pairs that share a Soundex code, how
# many are far apart in the sound skeleton of p11 (distance > 0.5)?
# Too narrow: for each name, one sound-keeping respelling (ph for f,
# c for k before a o u, z for s, y for i, a doubled consonant); how
# often does Soundex change while the skeleton stays equal? Counts
# are exact for this synthetic lexicon; the lexicon is illustrative.
import random
import re
from collections import Counter, defaultdict
from itertools import combinations

CODE = {c: d for d, g in (("1", "bfpv"), ("2", "cgjkqsxz"), ("3", "dt"),
                          ("4", "l"), ("5", "mn"), ("6", "r")) for c in g}
SKEL = ((r"ch", "tsh"), (r"ph", "f"), (r"gh", "g"), (r"ck", "k"),
        (r"qu", "kw"),
        (r"q", "k"), (r"x", "ks"), (r"z", "s"), (r"y", "i"),
        (r"ee", "i"), (r"oo", "u"), (r"c(?=[ei])", "s"), (r"c", "k"))
OPS = ((r"f", "ph"), (r"k(?=[aou])", "c"), (r"s", "z"), (r"i", "y"),
       (r"([bdlmnprt])", r"\1\1"))


def soundex(s):
    last, out = CODE.get(s[0], ""), []
    for c in s[1:]:
        d = CODE.get(c, "")
        if d and d != last:
            out.append(d)
        if c not in "hw":
            last = d
    return (s[0] + "".join(out) + "000")[:4]


def skeleton(s):
    for pat, rep in SKEL:
        s = re.sub(pat, rep, s)
    return re.sub(r"(.)\1+", r"\1", s)


def lev(a, b):
    prev = list(range(len(b) + 1))
    for i, x in enumerate(a, 1):
        cur = [i]
        for j, y in enumerate(b, 1):
            cur.append(min(prev[j] + 1, cur[j - 1] + 1,
                           prev[j - 1] + (x != y)))
        prev = cur
    return prev[-1]


def respell(rng, s):
    ops = list(OPS)
    rng.shuffle(ops)
    for pat, rep in ops:
        hits = [m.start() for m in re.finditer(pat, s)]
        if hits:
            k = rng.choice(hits)
            return s[:k] + re.sub(pat, rep, s[k:], count=1)
    return s


if __name__ == "__main__":
    rng = random.Random(20261113)
    names = sorted({"".join(rng.choice("bdfgklmnprstvz") +
                            rng.choice("aeiou")
                            for _ in range(rng.choice((2, 3))))
                    for _ in range(3000)})
    buckets = defaultdict(list)
    for n in names:
        buckets[soundex(n)].append(n)
    sizes = Counter(len(v) for v in buckets.values())
    pairs = far = 0
    for code in sorted(buckets):
        for a, b in combinations(buckets[code], 2):
            ka, kb = skeleton(a), skeleton(b)
            pairs += 1
            if lev(ka, kb) > 0.5 * max(len(ka), len(kb)):
                far += 1
    big = max(len(v) for v in buckets.values())
    print("distinct names {}   Soundex codes {}   largest bucket {}"
          .format(len(names), len(buckets), big))
    print("singleton codes {}".format(sizes[1]))
    print("same-code pairs {}   far in sound skeleton {}   share {:.3f}"
          .format(pairs, far, far / pairs))
    moved = kept = first = 0
    for n in names:
        v = respell(rng, n)
        if v == n:
            continue
        if skeleton(v) == skeleton(n):
            kept += 1
            if soundex(v) != soundex(n):
                moved += 1
                if v[0] != n[0]:
                    first += 1
    print("sound-keeping respellings {}   Soundex code changed {}"
          "   share {:.3f}".format(kept, moved, moved / kept))
    print("of the changed codes, caused by a new first letter {}"
          .format(first))

Single source and citation

Fan, Y. (2026). Phonetic, Graphic and Semantic Distance between Trademarks: Pre-Screening Brand-Name Collisions from Fanqie Spellings to Sound Codes (Version 1.0.0), Chapter 2: Soundex: a Century-Old Sound Code, Too Wide and Too Narrow. 5D Library. DOI pending

DOI pending · monograph page goes live after publication · 5DL-B-317 · v1.0.0 · CC-BY-NC-ND-4.0

BibTeX
@book{fan2026317,
  author    = {Fan, Yafu},
  title     = {Phonetic, Graphic and Semantic Distance between Trademarks: Pre-Screening Brand-Name Collisions from Fanqie Spellings to Sound Codes},
  year      = {2026},
  publisher = {5D Library},
  edition   = {1.0.0},
  note      = {DOI pending}
}

Other chapter answers in this book