关于「Soundex:一百年前的音码,太宽又太窄」,《品牌撞名三维预检》给出的定量结论是什么?

结论:第二章按美国国家档案馆指南实现 Soundex 并逐例核对,在合成词表上同码名字对中有 0.436 在读音上相差过半,保留读音的改写有 0.093 改变了编码,且全部来自首字母。

数据口径:在一个示意模型中,声音通道占八成时音码的 AUC 为 0.851,高于字母编辑距离的 0.817。 书中参数为示意;全部计算由书中程序生成;本书是非个人化法律建议,商标近似判断以各地官方检索与专业代理意见为准。

English version

对照数据表

下表数字由本章 Python 程序原样打印,可重新运行复现。 程序只用 Python 标准库与结论吻合的打印值: 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
查看完整验算程序
# 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))

唯一数据源与引用

范雅福(Fan, Y.). (2026). 《商标音近形近义近三维距离、从反切到音码的品牌撞名预检母典》第 2 章「Soundex:一百年前的音码,太宽又太窄」(版本 1.0.0). 5D Library. DOI 待发布

DOI 待发布 · 专著页正式发布后上线(本站暂无专著页) · 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}
}

本书其他章节结论