Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

D.2 实词拼写错误

噪声信道方法也可以检测和纠正产生真实英语词的实词拼写错误。它们可能来自意外产生实词的排印错误,如用 there 代替 three;也可能是写作者误用了同音或近同音词,如 dessert/desertpiece/peace。研究表明,拼写错误中约有 25%–40% 是合法英语词(Kukich, 1992),例如:

This used to belong to thew queen. They are leaving in about fifteen minuets to go to her house.

The design an construction of the system will take more than a year.

Can they lave him my messages?

The study was conducted mainly be John Black.

Mays 等人(1991)提出的实词纠错算法输入句子 X={x1,x2,,xn}X=\{x_1,x_2,\ldots,x_n\},生成大型候选纠正句集合 C(X)C(X),再选择语言模型概率最高的句子。

生成候选句时,先为每个输入词 xix_i 生成候选词集合 C(xi)C(x_i),包含与 xix_i 编辑距离较小的所有英语词。若采用常见的编辑距离 1,实词 thew(罕见词,意为“肌肉力量”)的候选可以是 {the, thaw, threw, them, thwe}。再作简化假设:每个句子只有一个错误。于是,输入 only two of thew apples 的候选句集合包括保持原句、把各位置分别换成其编辑距离为 1 的候选,以及关键候选 only two of the apples 等。

每个句子用噪声信道评分:

W^=argmaxWC(X)P(XW)P(W)(D.7)\hat W=\arg\max_{W\in C(X)}P(X\mid W)P(W)\tag{D.7}

P(W)P(W) 可以采用句子的三元语法概率。信道模型还必须考虑输入词没有错误的可能性。设正确键入词的信道概率 P(ww)P(w\mid w)α\alpha;不同任务可采用不同值,例如假设每 20 个词错 1 个时为 0.95,其他任务中也可以为 0.99。Mays 等人(1991)的简单模型把保留原词的概率设为 α\alpha,再把 1α1-\alpha 均匀分配给其他候选:

P(xw)={α,x=w,1αC(x),wC(x),0,其他情况.(D.8)P(x\mid w)= \begin{cases} \alpha,&x=w,\\ \dfrac{1-\alpha}{|C(x)|},&w\in C(x),\\ 0,&\text{其他情况}. \end{cases}\tag{D.8}

还可以不均匀分配 1α1-\alpha,而是让分配与公式 D.6 中利用混淆矩阵得到的编辑概率成比例。

以字符串 two of thew 为例,作者可能确实想写真实词 thew,也可能把 the 或其他词拼错。只考虑编辑距离为 1 的候选 thethawthrew、罕见名字 thwe,以及原样 thew。采用 Norvig(2009)的编辑概率和在 Google n-gram 上训练的 Stupid Backoff 模型,主要语言模型概率为:

P(thetwo of)=0.476012,P(thewtwo of)=9.95051×108,P(thawtwo of)=2.09267×107,P(threwtwo of)=8.9064×107,P(thwetwo of)=5.18681×109.\begin{aligned} P(\text{the}\mid\text{two of})&=0.476012,\\ P(\text{thew}\mid\text{two of})&=9.95051\times10^{-8},\\ P(\text{thaw}\mid\text{two of})&=2.09267\times10^{-7},\\ P(\text{threw}\mid\text{two of})&=8.9064\times10^{-7},\\ P(\text{thwe}\mid\text{two of})&=5.18681\times10^{-9}. \end{aligned}

这里只计算短语 two of thew;完整句子还要乘上后续词的概率,例如 P(peopleof the)P(\text{people}\mid\text{of the})P(peopleof thew)P(\text{people}\mid\text{of thew}) 等。

依照 Norvig(2009),假设词成为拼写错误的概率为 0.05,即 α=P(ww)=0.95\alpha=P(w\mid w)=0.95。噪声信道的主要评分结果如下,最后一列放大 108 倍:

输入 xx

候选 ww

P(xw)P(x\mid w)

P(wtwo of)P(w\mid\text{two of})

放大后的乘积

thew

the

0.000007

0.48

333

thew

thew

0.95

9.95×1089.95\times10^{-8}

9.45

thew

thaw

0.001

2.1×1072.1\times10^{-7}

0.0209

thew

threw

0.000008

8.9×1078.9\times10^{-7}

0.000713

thew

thwe

0.000003

5.2×1095.2\times10^{-9}

0.00000156

图 D.6 使用 Google n-gram 语料训练的 Stupid Backoff 三元模型和 Norvig(2009)的错误模型,对 thew 的五个候选应用噪声信道。

对错误短语 two of thew,模型正确选择 the。但错误率更低时结果可能改变:若某项任务中的错误概率足够低,即 α\alpha 很高,模型可能认为作者确实想写 thew