ICS 582Lecture 05المحاضرة 05Part 08الجزء 08
State-of-the-art spelling systemsأنظمة الإملاء الحديثة
What real systems add: confidence-driven HCI, weighting the language model with lambda, phonetic (Metaphone) error models, richer edits, keyboard and context features in the channel, and classifiers for confusable pairs.ما تضيفه الأنظمة الحقيقية: تفاعل بين الإنسان والحاسب (HCI) قائم على الثقة، وترجيح نموذج اللغة بـ lambda، ونماذج الأخطاء الصوتية (Metaphone)، والتعديلات الأغنى، وخصائص لوحة المفاتيح والسياق في القناة، والمصنِّفات للأزواج الملتبسة.
- Conceptsالمفاهيم
- 5
- Slidesالشرائح
- 40-48
- Readingمدة القراءة
- 30 min30 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
The noisy channel you built in parts 2 to 7 already corrects acress. This part asks what a production spelling system adds on top. The answer is a short list of engineering upgrades: an interface that acts according to its confidence, a tuned weight on the language model, a second way of finding candidates (by sound), a channel model that knows about keyboards and multi-letter slips, and dedicated classifiers for the pairs of real words people confuse most.
For the exam, the two most testable items are the λ formula with its justification, and the list of factors that influence P(x|w). For research, this part is where the classic model meets current practice: every idea here (weighting model scores, phonetic features, classifiers over context) reappears in speech recognition, machine translation and neural correction.
نموذج القناة المشوشة (noisy channel) الذي بنيته في الأجزاء من 2 إلى 7 يصحّح acress بالفعل. يسأل هذا الجزء: ماذا يضيف نظام تدقيق إملائي حقيقي يعمل في بيئة الإنتاج فوق ذلك؟ الجواب قائمة قصيرة من التحسينات الهندسية: واجهة تتصرف بحسب درجة ثقتها، ووزن مضبوط على نموذج اللغة، وطريقة ثانية لإيجاد المرشحين (عن طريق الصوت)، ونموذج قناة يعرف لوحة المفاتيح والزلّات متعددة الحروف، ومصنّفات مخصصة لأزواج الكلمات الصحيحة التي يخلط الناس بينها أكثر من غيرها.
في الامتحان، أكثر بندين قابلين للسؤال هما معادلة λ مع تبريرها، وقائمة العوامل التي تؤثر في P(x|w). أما في البحث، فهذا الجزء هو المكان الذي يلتقي فيه النموذج الكلاسيكي بالممارسة الحالية: كل فكرة هنا (وزن درجات النماذج، والسمات الصوتية، والمصنّفات المبنية على السياق) تعود للظهور في التعرف على الكلام (speech recognition) والترجمة الآلية (machine translation) والتصحيح العصبي (neural correction).
By the end you canفي نهاية هذا الجزء ستستطيع
- Map the confidence of the best candidate to one of four interface actions: autocorrect, best suggestion, suggestion list, or flag.اربط ثقة النظام بأفضل مرشح بواحد من أربعة إجراءات في الواجهة: التصحيح التلقائي (autocorrect)، أو عرض أفضل اقتراح، أو عرض قائمة اقتراحات، أو مجرد التمييز (flag).
- Explain why real systems weight the prior as P(w)^λ, write the formula in product and log form, and say where λ comes from.اشرح لماذا تزن الأنظمة الحقيقية الاحتمال المسبق على شكل P(w)^λ، واكتب المعادلة بصيغة الضرب وبصيغة اللوغاريتم، وبيّن من أين تأتي λ.
- Compute how λ changes the acress ranking, including the λ at which across overtakes actress.احسب كيف تغيّر λ ترتيب مرشحي acress، بما في ذلك قيمة λ التي تتجاوز عندها across كلمة actress.
- Apply Metaphone rules to turn a word into a pronunciation key, and describe how GNU aspell finds and scores candidates by sound.طبّق قواعد Metaphone لتحويل كلمة إلى مفتاح نطق، وصِف كيف يجد GNU aspell المرشحين ويقيّمهم حسب الصوت.
- Name the factors beyond the letter pair that a better channel model conditions on, including multi-letter edits, keyboard adjacency and homology.سمِّ العوامل التي يشترط عليها نموذج قناة أفضل إلى جانب زوج الحروف، بما فيها التعديلات متعددة الحروف، وتجاور المفاتيح (keyboard adjacency)، والتماثل بين اليدين (homology).
- Describe a classifier for a confusable pair such as whether and weather, and the context features it uses.صِف مصنّفًا لزوج كلمات قابل للالتباس مثل whether وweather، والسمات السياقية التي يستخدمها.
You type "teh" on your phone and it silently becomes "the". You type a colleague's surname and it gets a red underline and nothing else. Same keyboard, same software, two very different behaviours. The difference is how sure the system is about its best candidate.
تكتب «teh» على هاتفك فتتحول بصمت إلى «the». وتكتب اسم عائلة أحد زملائك فيظهر تحته خط أحمر ولا شيء غير ذلك. لوحة المفاتيح نفسها والبرنامج نفسه، لكن السلوكين مختلفان جدًا. والفرق هو مدى تأكد النظام من أفضل مرشح لديه.
Four actions, ordered by confidenceأربعة إجراءات مرتبة حسب الثقة
A spelling corrector produces two things: a ranked list of candidates and, implicitly, a measure of how much better the top candidate is than the rest and than leaving the word alone. The Confidence ladder turns that confidence into an interface decision. When the system is very confident, it performs Autocorrect. When it is less confident, it shows only its single best correction and lets the writer accept it. Less confident still, it offers a correction list. When it is unconfident, it does not guess at all: it just flags the token.
ينتج مصحح الإملاء شيئين: قائمة مرتبة من المرشحين، وضمنيًا مقياسًا لمدى تفوق المرشح الأول على البقية وعلى ترك الكلمة كما هي. يحوّل سلّم الثقة (confidence ladder) هذه الثقة إلى قرار في الواجهة. عندما يكون النظام واثقًا جدًا، ينفّذ التصحيح التلقائي (autocorrect). وعندما تقل ثقته، يعرض أفضل تصحيح واحد فقط ويترك للكاتب أن يقبله. وعندما تقل ثقته أكثر، يعرض قائمة تصحيحات. وعندما لا يكون واثقًا، لا يخمّن أبدًا: يكتفي بتمييز الكلمة (token) على أنها خطأ.
| Confidenceالثقة | Actionالإجراء | Cost of being wrongتكلفة الخطأ |
|---|---|---|
| Very confidentثقة عالية جدًا | Autocorrect: replace silentlyتصحيح تلقائي (autocorrect): استبدال صامت | A wrong replacement changes the writer's meaning without them noticingالاستبدال الخاطئ يغيّر معنى الكاتب دون أن يلاحظ |
| Less confidentثقة أقل | Offer the single best correctionعرض أفضل تصحيح واحد | The writer must accept, so a wrong guess costs one glanceعلى الكاتب أن يقبله، فالتخمين الخاطئ يكلّف نظرة واحدة |
| Less confident stillثقة أقل من ذلك | Offer a ranked correction listعرض قائمة تصحيحات مرتبة | The writer picks, so the system only needs the answer somewhere in the listالكاتب يختار، فيكفي أن تكون الإجابة في مكان ما من القائمة |
| Unconfidentغياب الثقة | Just flag the token as an errorمجرد تمييز الكلمة (flag) على أنها خطأ | No guess is shown, so a bad candidate list cannot misleadلا يُعرض أي تخمين، فلا يمكن لقائمة مرشحين سيئة أن تضلل |
The logic is about the cost of mistakes. A silent wrong replacement is the worst outcome: the writer may never notice that the meaning changed. Each rung down hands more of the decision back to the human, so the system can afford to be less sure. The slides give no rule for choosing the rung; in practice it is a set of thresholds on a confidence signal, such as the score gap between the best candidate and the runner-up, or between the best candidate and the typed word itself.
المنطق قائم على تكلفة الأخطاء. الاستبدال الخاطئ الصامت هو أسوأ نتيجة: قد لا يلاحظ الكاتب أبدًا أن المعنى تغيّر. كل درجة نزولًا تعيد جزءًا أكبر من القرار إلى الإنسان، فيستطيع النظام أن يكون أقل يقينًا. لا تقدم الشرائح قاعدة لاختيار الدرجة؛ وعمليًا هي مجموعة عتبات (thresholds) على إشارة ثقة، مثل فرق الدرجة بين أفضل مرشح والذي يليه، أو بين أفضل مرشح والكلمة المكتوبة نفسها.
This ladder is the interface face of the task ladder from part 1. There, the tasks were Spelling error detection (find the error) and Spelling error correction (propose or apply a fix). Flagging is detection alone. The three upper rungs are correction, delivered with increasing boldness.
هذا السلّم هو الوجه الظاهر في الواجهة لسلّم المهام من الجزء 1. هناك كانت المهمتان هما كشف الأخطاء الإملائية (spelling error detection) أي إيجاد الخطأ، وتصحيح الأخطاء الإملائية (spelling error correction) أي اقتراح إصلاح أو تطبيقه. التمييز (flagging) هو كشف فقط. والدرجات الثلاث العليا تصحيح، يُقدَّم بجرأة متزايدة.
Recall
Name the four rungs of the confidence ladder from most to least confident, and say which one is pure detection.سمِّ درجات سلّم الثقة الأربع من الأعلى ثقة إلى الأقل، وحدّد أيها كشف خالص.
Autocorrect, give the best correction, give a correction list, just flag. Flagging is pure detection: the system reports an error but proposes no fix.
التصحيح التلقائي (autocorrect)، ثم إعطاء أفضل تصحيح، ثم إعطاء قائمة تصحيحات، ثم مجرد التمييز (flag). التمييز كشف خالص: يبلّغ النظام عن وجود خطأ لكنه لا يقترح أي إصلاح.
Look again at the acress table. With the plain product, across scores 2.78 × 10⁻⁹ and actress scores 2.70 × 10⁻⁹. A 3% margin decides the answer. Is that really the right balance between "how easy is this typo" and "how common is this word"? Nothing in the model guarantees it.
انظر مجددًا إلى جدول acress. مع حاصل الضرب العادي، تحصل across على 2.78 × 10⁻⁹ وتحصل actress على 2.70 × 10⁻⁹. هامش قدره 3% يحسم الإجابة. فهل هذا حقًا التوازن الصحيح بين «ما مدى سهولة هذا الخطأ المطبعي» و«ما مدى شيوع هذه الكلمة»؟ لا شيء في النموذج يضمن ذلك.
Why the plain product is not trustedلماذا لا نثق بحاصل الضرب العادي
The Noisy channel model multiplies the Channel model P(x|w) by the Prior probability P(w). Bayes' rule says that product is exact, but only for the true distributions. Our two factors are estimates built under different simplifications. The channel assumes a single edit from a confusion matrix. The language model assumes a unigram or bigram history. Because of these independence assumptions, the two numbers are not commensurate: they live on different effective scales, and one can be systematically over- or under-confident relative to the other. So state-of-the-art systems never just multiply them. They weight them.
يضرب نموذج القناة المشوشة (noisy channel model) نموذجَ القناة (channel model) P(x|w) في الاحتمال المسبق (prior probability) P(w). تقول قاعدة بايز (Bayes' rule) إن هذا الحاصل دقيق، لكن فقط للتوزيعات الحقيقية. أما عاملانا فهما تقديران بُنيا تحت تبسيطات مختلفة. القناة تفترض تعديلًا واحدًا مأخوذًا من مصفوفة الالتباس (confusion matrix). ونموذج اللغة يفترض تاريخًا من نوع unigram أو bigram. وبسبب افتراضات الاستقلال هذه، لا يكون الرقمان متكافئين في المقياس (not commensurate): فهما يعيشان على مقاييس فعلية مختلفة، وقد يكون أحدهما مفرط الثقة أو ناقصها بشكل منهجي مقارنة بالآخر. لذلك لا تكتفي الأنظمة المتقدمة (state-of-the-art) بضربهما أبدًا، بل تزنهما.
This is Lambda weighting. The argmax still runs over the vocabulary V. In log space the formula is a weighted sum of two votes, so λ is literally the weight of the language model relative to the channel. λ = 1 is the plain product. λ > 1 gives the prior more say and favours frequent words. λ < 1 gives the channel more say and favours the cheapest edit. The value is not derived; it is learned by trying several values on a Development test set of real misspellings and keeping the one with the best accuracy.
هذا هو وزن لامدا (lambda weighting). ما زال argmax يمر على المفردات V. وفي فضاء اللوغاريتم تصبح المعادلة مجموعًا موزونًا لصوتين، فتكون λ حرفيًا وزن نموذج اللغة نسبةً إلى القناة. λ = 1 هو حاصل الضرب العادي. λ > 1 يعطي الاحتمال المسبق كلمة أكبر ويفضّل الكلمات الشائعة. λ < 1 يعطي القناة كلمة أكبر ويفضّل أرخص تعديل. هذه القيمة لا تُشتق رياضيًا؛ بل تُتعلَّم بتجربة عدة قيم على مجموعة اختبار تطويرية (development test set) من أخطاء إملائية حقيقية، والاحتفاظ بالقيمة التي تعطي أفضل دقة.
Worked exampleمثال محلول
How λ re-ranks actress and across (unigram prior)كيف تعيد λ ترتيب actress وacross (احتمال مسبق unigram)
Take the logs from the slide tableخذ اللوغاريتمات من جدول الشريحة
actress: log₁₀ P(x|w) = log₁₀ 0.000117 = −3.932 and log₁₀ P(w) = log₁₀ 0.0000231 = −4.636. across: log₁₀ 0.0000093 = −5.032 and log₁₀ 0.000299 = −3.524.actress: log₁₀ P(x|w) = log₁₀ 0.000117 = −3.932 وlog₁₀ P(w) = log₁₀ 0.0000231 = −4.636. across: log₁₀ 0.0000093 = −5.032 وlog₁₀ 0.000299 = −3.524.Score at λ = 1الدرجة عند λ = 1
actress: −3.932 − 4.636 = −8.568. across: −5.032 − 3.524 = −8.556. across wins by 0.012 in log₁₀, a factor of about 1.03. This is the slide's 2.8 versus 2.7.actress: −3.932 − 4.636 = −8.568. across: −5.032 − 3.524 = −8.556. تفوز across بفارق 0.012 في log₁₀، أي بعامل يقارب 1.03. وهذا هو 2.8 مقابل 2.7 في الشريحة.Score at λ = 2الدرجة عند λ = 2
actress: −3.932 − 2(4.636) = −13.204. across: −5.032 − 2(3.524) = −12.080. across now leads by 1.124, about 13×. Because P(across) > P(actress), every increase in λ widens its lead.actress: −3.932 − 2(4.636) = −13.204. across: −5.032 − 2(3.524) = −12.080. تتقدم across الآن بفارق 1.124، أي نحو 13×. ولأن P(across) > P(actress)، فكل زيادة في λ توسّع تقدّمها.Find the crossoverأوجد نقطة التقاطع
Set the scores equal: −3.932 − 4.636λ = −5.032 − 3.524λ, so 1.100 = 1.112λ and λ ≈ 0.989. Below that, the channel's preference for the easy deletion (c|ct) wins and actress comes first.اجعل الدرجتين متساويتين: −3.932 − 4.636λ = −5.032 − 3.524λ، إذن 1.100 = 1.112λ وλ ≈ 0.989. تحت هذه القيمة، يفوز تفضيل القناة للحذف السهل (c|ct) وتأتي actress أولًا.Resultالنتيجة
With a unigram prior, raising λ only strengthens across. The writer meant actress ("versatile acress whose"), and the robust way to get it is context: the bigram prior of part 5 gives P(whose|actress) = .0010 against P(whose|across) = .000006, a 170-fold swing that no reasonable λ on a unigram can match.مع احتمال مسبق من نوع unigram، رفع λ لا يفعل سوى تقوية across. لكن الكاتب قصد actress («versatile acress whose»)، والطريقة المتينة للوصول إليها هي السياق: الاحتمال المسبق من نوع bigram في الجزء 5 يعطي P(whose|actress) = .0010 مقابل P(whose|across) = .000006، أي فرقًا بمقدار 170 ضعفًا لا تستطيع أي قيمة معقولة لـ λ على unigram أن تجاريه.
| λλ | Winnerالفائز | actress versus acrossactress مقابل across | Readingالتفسير |
|---|---|---|---|
| 00 | actressactress | actress leads across by about 12.6×تتقدم actress على across بنحو 12.6× | Channel only: the cheapest edit winsالقناة وحدها: يفوز أرخص تعديل |
| 0.50.5 | actressactress | actress leads across by about 3.5×تتقدم actress على across بنحو 3.5× | Prior counts, but too weakly to overturn the channelالاحتمال المسبق يُحتسب، لكن بضعف لا يكفي لقلب حكم القناة |
| 11 | acrossacross | across leads actress by about 1.03×تتقدم across على actress بنحو 1.03× | Plain Bayes: the slide table's 2.8 versus 2.7بايز العادي: 2.8 مقابل 2.7 في جدول الشريحة |
| 22 | acrossacross | across leads actress by about 13×تتقدم across على actress بنحو 13× | Prior doubled: frequent words pull further aheadالاحتمال المسبق مضاعف: تبتعد الكلمات الشائعة أكثر في الصدارة |
Drag the slider and watch the ranking reorder. Note that at small λ the two acres derivations, summed, also climb above across, because their channel probability is high.
حرّك المنزلق وراقب كيف يُعاد الترتيب. لاحظ أنه عند قيم λ الصغيرة، يرتفع اشتقاقا acres (بعد جمعهما) أيضًا فوق across، لأن احتمال القناة لهما مرتفع.
Each row shows log₁₀ P(x|w) + λ log₁₀ P(w). Higher is better, and the bar spans six decades below the leader. The two acres rows of the slide table are summed into one channel probability.يعرض كل صف log₁₀ P(x|w) + λ log₁₀ P(w). القيمة الأعلى أفضل، ويمتد الشريط ست مراتب عشرية تحت المتصدر. جُمع صفّا acres في جدول الشريحة في احتمال قناة واحد.
- across-8.56
- actress-8.57
- acres-8.68
- access-10.72
- caress-11.55
- cress-12.11
Recall
Why do real systems use P(w)^λ instead of P(w), and how is λ chosen?لماذا تستخدم الأنظمة الحقيقية P(w)^λ بدل P(w)، وكيف تُختار λ؟
Independence assumptions make the channel and the prior estimates not commensurate, so their raw product does not balance them well. Raising the prior to λ (or multiplying log P(w) by λ) sets their relative weight, and λ is tuned for best accuracy on a development test set.
افتراضات الاستقلال تجعل تقديري القناة والاحتمال المسبق غير متكافئين في المقياس، فلا يوازن حاصل ضربهما الخام بينهما جيدًا. رفع الاحتمال المسبق إلى الأس λ (أو ضرب log P(w) في λ) يحدد وزنهما النسبي، وتُضبط λ لتحقيق أفضل دقة على مجموعة اختبار تطويرية (development test set).
Quick checkاختبار سريع
Why does a state-of-the-art noisy channel raise P(w) to a power λ?لماذا ترفع القناة المشوشة المتقدمة (state-of-the-art) الاحتمال P(w) إلى الأس λ؟
Quick checkاختبار سريع
With the unigram acress table and λ = 2, which candidate ranks first?مع جدول acress المبني على unigram وλ = 2، أي مرشح يأتي أولًا؟
A writer who has only heard the word types "nite" for knight. That is three letters missing (k, g, h) and one letter added (the final e). Within edit distance 1, candidate generation never reaches knight. Yet the two words sound identical, and that is the clue the letter-based model ignores.
كاتب سمع الكلمة فقط ولم يرها يكتب «nite» بدل knight. هذه ثلاثة حروف ناقصة (k وg وh) وحرف واحد زائد (حرف e الأخير). ضمن edit distance 1، لا يصل توليد المرشحين أبدًا إلى knight. ومع ذلك تُنطق الكلمتان نطقًا متطابقًا، وهذا هو الدليل الذي يتجاهله النموذج المبني على الحروف.
Metaphone: a key for how a word soundsMetaphone: مفتاح لطريقة نطق الكلمة
Metaphone, published by Lawrence Philips in 1990, is a set of ordered rewrite rules that maps an English word to a rough pronunciation key. The slide quotes three of them:
Metaphone، الذي نشره Lawrence Philips عام 1990، مجموعة من قواعد إعادة الكتابة المرتبة تحوّل الكلمة الإنجليزية إلى مفتاح نطق تقريبي. تقتبس الشريحة ثلاثًا منها:
- Drop duplicate adjacent letters, except for C. So "accross" and "across" share a key.احذف الحروف المكررة المتجاورة، باستثناء C. لذلك تشترك «accross» و«across» في المفتاح نفسه.
- If the word begins with KN, GN, PN, AE or WR, drop the first letter. So knight starts as NIGHT.إذا بدأت الكلمة بـ KN أو GN أو PN أو AE أو WR، فاحذف الحرف الأول. لذلك تبدأ knight على شكل NIGHT.
- Drop B if it is after M at the end of the word. So thumb and thum both end in M.احذف B إذا جاء بعد M في نهاية الكلمة. لذلك تنتهي thumb وthum كلتاهما بـ M.
The full list continues with rules such as PH becoming F, G dropped before an H that is not followed by a vowel, TH becoming the symbol 0, and all vowels dropped except a first one. The key is not a phonetic transcription; the aspell manual calls it a rough approximation of how the word sounds. What matters is that words that sound alike tend to collide on the same key.
تستمر القائمة الكاملة بقواعد مثل تحويل PH إلى F، وحذف G قبل H لا يليها حرف علة، وتحويل TH إلى الرمز 0، وحذف كل حروف العلة ما عدا حرفًا في أول الكلمة. المفتاح ليس كتابة صوتية دقيقة (phonetic transcription)؛ فدليل aspell يصفه بأنه تقريب خشن لطريقة نطق الكلمة. المهم أن الكلمات المتشابهة في النطق تميل إلى الالتقاء على المفتاح نفسه.
Worked exampleمثال محلول
Metaphone key for knight and niteمفتاح Metaphone لكلمتي knight وnite
Initial KNKN في بداية الكلمة
knight begins with KN, so drop the first letter: NIGHT.تبدأ knight بـ KN، لذلك احذف الحرف الأول: NIGHT.G before HG قبل H
The H is followed by T, not a vowel, and is not word-final, so drop the G: NIHT.حرف H يليه T وليس حرف علة، وليس في آخر الكلمة، لذلك احذف G: NIHT.H after a vowelH بعد حرف علة
H follows I and is not before a vowel, so drop it: NIT.حرف H يأتي بعد I وليس قبل حرف علة، لذلك احذفه: NIT.Vowelsحروف العلة
Drop vowels that are not first: NT.احذف حروف العلة التي ليست في أول الكلمة: NT.Resultالنتيجة
nite also loses its non-initial vowels and becomes NT. The keys are identical, so the pronunciation edit distance is 0.كلمة nite أيضًا تفقد حروف العلة غير الأولى وتصبح NT. المفتاحان متطابقان، لذلك مسافة التعديل بين النطقين تساوي 0.
How GNU aspell uses the keyكيف يستخدم GNU aspell المفتاح
GNU aspell builds a Phonetic error model in three steps. First, convert the misspelling to its Metaphone key. Second, collect every dictionary word whose key is within 1 or 2 edits of that key, which is Candidate generation by sound instead of by spelling. Third, score the list with a combination of two distances: the weighted Edit distance from each candidate's spelling to the misspelling, and the edit distance between their pronunciation keys. The lowest scores become the suggestions.
يبني GNU aspell نموذج خطأ صوتيًا (phonetic error model) في ثلاث خطوات. أولًا، يحوّل الخطأ الإملائي إلى مفتاح Metaphone الخاص به. ثانيًا، يجمع كل كلمة في القاموس يقع مفتاحها ضمن تعديل واحد أو تعديلين (1 أو 2) من ذلك المفتاح، وهذا هو توليد المرشحين (candidate generation) عن طريق الصوت بدل الإملاء. ثالثًا، يقيّم القائمة بمزيج من مسافتين: مسافة التعديل (edit distance) الموزونة من إملاء كل مرشح إلى الخطأ الإملائي، ومسافة التعديل بين مفتاحي النطق. وأقل الدرجات تصبح هي الاقتراحات.
Note what this is and is not. Aspell plays the role of the channel model, judging how plausible it is that the writer produced this string, but it is a scoring heuristic, not a probability. It catches Cognitive errors, where the writer spells by ear, which a keyboard-based confusion matrix handles poorly.
انتبه لما هو عليه هذا وما ليس عليه. يؤدي aspell دور نموذج القناة، إذ يحكم على مدى معقولية أن يكون الكاتب قد أنتج هذه السلسلة، لكنه طريقة تقييم تجريبية (heuristic) وليس احتمالًا. وهو يلتقط الأخطاء المعرفية (cognitive errors)، حيث يكتب الكاتب بحسب ما يسمع، وهي أخطاء تتعامل معها مصفوفة الالتباس المبنية على لوحة المفاتيح بشكل سيئ.
Recall
What two distances does aspell combine when it scores candidates, and how are the candidates found?ما المسافتان اللتان يجمعهما aspell عند تقييم المرشحين، وكيف يجد المرشحين؟
Candidates are dictionary words whose Metaphone key is within 1 or 2 edits of the misspelling's key. They are scored by the weighted letter edit distance from candidate to misspelling combined with the edit distance between the two pronunciation keys.
المرشحون هم كلمات القاموس التي يقع مفتاح Metaphone لها ضمن تعديل واحد أو تعديلين (1 أو 2) من مفتاح الخطأ الإملائي. ويُقيَّمون بمسافة تعديل الحروف الموزونة من المرشح إلى الخطأ الإملائي، مجموعةً مع مسافة التعديل بين مفتاحي النطق.
Someone types "fisikle" for physical. Counted letter by letter, that is a pile of unrelated edits, and the Kernighan, Church and Gale channel model, which allows one single-letter edit, assigns it almost no probability. But to a human it is obviously three familiar slips: ph written as f, y as i, al as le.
يكتب أحدهم «fisikle» بدل physical. إذا عددناها حرفًا حرفًا، فهي كومة من التعديلات غير المترابطة، ونموذج القناة لـ Kernighan, Church and Gale، الذي يسمح بتعديل واحد على حرف واحد فقط، يعطيها احتمالًا يكاد يكون معدومًا. لكنها بالنسبة للإنسان ثلاث زلّات مألوفة بوضوح: ph كُتبت f، وy كُتبت i، وal كُتبت le.
Multi-letter edits (Brill and Moore 2000)التعديلات متعددة الحروف (Brill and Moore 2000)
Brill and Moore proposed Richer edits: an edit can rewrite a whole substring. The typist is modelled as choosing a word, cutting it into pieces, and typing each piece, possibly wrongly. So the model can learn probabilities such as ent → ant (independent written independant), ph → f, and le → al. Each edit is also conditioned on its position in the word (start, middle, end). The probability of a misspelling is approximated by its best partition, for example:
اقترح Brill وMoore التعديلات الأغنى (richer edits): يمكن للتعديل الواحد أن يعيد كتابة سلسلة فرعية كاملة. يُنمذَج الكاتب على أنه يختار كلمة، ثم يقطّعها إلى أجزاء، ثم يكتب كل جزء، ربما بشكل خاطئ. لذلك يستطيع النموذج أن يتعلّم احتمالات مثل ent → ant (كتابة independent على شكل independant)، وph → f، وle → al. وكل تعديل مشروط أيضًا بموضعه في الكلمة (البداية، الوسط، النهاية). ويُقرَّب احتمال الخطأ الإملائي بأفضل تقسيم (partition) له، مثلًا:
Compare this with Damerau-Levenshtein distance, which only knows four single-character operations. A frequent multi-letter pattern such as ph to f would cost two edits there and get no special weight. Toutanova and Moore (2002) then added pronunciation directly into the channel, combining a letter-based model with a model over pronunciations, so errors like nite get probability mass from sound as well as spelling.
قارن ذلك بمسافة Damerau-Levenshtein، التي لا تعرف إلا أربع عمليات على حرف واحد. نمط شائع متعدد الحروف مثل تحويل ph إلى f سيكلّف هناك تعديلين ولن يحصل على أي وزن خاص. ثم أضاف Toutanova وMoore (2002) النطق مباشرة إلى القناة، بدمج نموذج مبني على الحروف مع نموذج مبني على النطق، فتحصل أخطاء مثل nite على كتلة احتمالية من الصوت ومن الإملاء معًا.
What else shapes P(x|w)ما الذي يشكّل P(x|w) أيضًا
The single-edit model of part 4 conditions on just the source and target letters from a Confusion matrix. The slides list eight factors that actually influence P(misspelling | word).
نموذج التعديل الواحد في الجزء 4 مشروط فقط بالحرف المصدر والحرف الهدف المأخوذين من مصفوفة الالتباس (confusion matrix). وتسرد الشرائح ثمانية عوامل تؤثر فعليًا في P(misspelling | word).
| Factorالعامل | What it capturesما الذي يلتقطه | Exampleمثال |
|---|---|---|
| Source letterالحرف المصدر | Which intended letter is being typedأي حرف مقصود تجري كتابته | e is mistyped far more often than q simply because it is typed moreيُخطأ في e أكثر بكثير من q لمجرد أنه يُكتب أكثر |
| Target letterالحرف الهدف | Which letter actually appearsأي حرف يظهر فعلًا | e|o in acress: some substitutions are common, most are raree|o في acress: بعض الاستبدالات شائعة، ومعظمها نادر |
| Surrounding lettersالحروف المحيطة | Letters before and after the editالحروف قبل التعديل وبعده | Doubled letters and vowel clusters invite insertions and deletionsالحروف المكررة وتجمعات حروف العلة تستدعي الإدراج والحذف |
| Position in the wordالموضع في الكلمة | Beginning, middle or endالبداية أو الوسط أو النهاية | Brill and Moore estimate P(f|ph) separately at the start of a wordيقدّر Brill and Moore الاحتمال P(f|ph) بشكل منفصل في بداية الكلمة |
| Nearby keysالمفاتيح المجاورة | Physical adjacency on the keyboardالتجاور المادي على لوحة المفاتيح | Typing r or w for eكتابة r أو w بدل e |
| Keyboard homologyالتماثل في لوحة المفاتيح (keyboard homology) | Same finger on the mirrored handالإصبع نفسه في اليد المقابلة | Typing i for e, both pressed by a middle fingerكتابة i بدل e، وكلاهما يُضغط بالإصبع الأوسط |
| Pronunciationالنطق | How the word soundsكيف تُنطق الكلمة | Writing f for ph, or nite for knightكتابة f بدل ph، أو nite بدل knight |
| Morpheme transformationsتحولات المورفيمات (morphemes) | Likely changes at morpheme boundariesالتغيرات المحتملة عند حدود المورفيمات | -ent written as -ant, -able written as -ible-ent مكتوبة -ant، و-able مكتوبة -ible |
Two of these are about the physical keyboard. Keyboard adjacency: most Typographical errors hit a key next to the intended one, so a Substitution of r for e is far likelier than p for e. Keyboard homology: the same finger on the other hand presses the mirrored key, so e (left middle finger) and i (right middle finger) get confused even though they are far apart. A channel that knows the layout can put probability mass exactly where fingers slip.
اثنان من هذه العوامل يتعلقان بلوحة المفاتيح المادية. تجاور المفاتيح (keyboard adjacency): معظم الأخطاء المطبعية (typographical errors) تصيب مفتاحًا مجاورًا للمفتاح المقصود، لذلك يكون استبدال (substitution) r مكان e أرجح بكثير من p مكان e. التماثل في لوحة المفاتيح (keyboard homology): الإصبع نفسه في اليد الأخرى يضغط المفتاح المقابل له كالمرآة، لذلك يحدث الخلط بين e (الإصبع الأوسط الأيسر) وi (الإصبع الأوسط الأيمن) رغم تباعدهما. والقناة التي تعرف ترتيب لوحة المفاتيح تستطيع أن تضع الكتلة الاحتمالية بالضبط حيث تنزلق الأصابع.
Recall
What can the Brill and Moore channel model represent that a single-edit Damerau-Levenshtein model cannot?ما الذي يستطيع نموذج القناة لـ Brill and Moore تمثيله ولا يستطيعه نموذج Damerau-Levenshtein ذو التعديل الواحد؟
Multi-letter substitutions such as ph → f, ent → ant and le → al as single learned edits, each with its own probability conditioned on position in the word. A single-edit model must spell these as several unrelated letter edits.
الاستبدالات متعددة الحروف مثل ph → f وent → ant وle → al بوصفها تعديلات مفردة متعلَّمة، لكل منها احتمالها الخاص المشروط بالموضع في الكلمة. أما نموذج التعديل الواحد فعليه أن يكتبها على شكل عدة تعديلات حرفية غير مترابطة.
"I don't know weather to go." Every word is in the dictionary, so lookup is silent. The noisy channel with a bigram prior can catch it, but there is a more direct tool: a model trained for exactly this pair.
«I don't know weather to go.» كل كلمة هنا موجودة في القاموس، لذلك يبقى البحث في القاموس صامتًا. القناة المشوشة مع احتمال مسبق من نوع bigram تستطيع التقاط الخطأ، لكن هناك أداة أكثر مباشرة: نموذج مدرَّب على هذا الزوج تحديدًا.
One classifier per confusable pairمصنّف واحد لكل زوج قابل للالتباس
For Real-word errors between a small set of words, often Homophones such as whether and weather, piece and peace, or affect and effect, we can train a Confusion-set classifier. Instead of combining a channel score with a language model score, it reads many features of the context and outputs one of the two words. For whether and weather the slide's features are:
بالنسبة لأخطاء الكلمات الحقيقية (real-word errors) بين مجموعة صغيرة من الكلمات، وغالبًا ما تكون كلمات متشابهة في النطق (homophones) مثل whether وweather، أو piece وpeace، أو affect وeffect، يمكننا تدريب مصنّف مجموعة الالتباس (confusion-set classifier). بدل دمج درجة القناة مع درجة نموذج اللغة، يقرأ هذا المصنّف سمات كثيرة من السياق ويُخرج إحدى الكلمتين. وبالنسبة لـ whether وweather، فإن سمات الشريحة هي:
- "cloudy" within ±10 words: a context word that votes for weather.«cloudy» ضمن ±10 كلمات: كلمة سياقية تصوّت لصالح weather.
- ___ to VERB: a pattern mixing a word and a part-of-speech tag that votes for whether (whether to go).___ to VERB: نمط يمزج كلمة مع وسم نوع الكلمة (part-of-speech tag) ويصوّت لصالح whether (whether to go).
- ___ or not: a collocation that votes for whether.___ or not: تلازم لفظي (collocation) يصوّت لصالح whether.
Each feature is weak alone; a learned classifier weighs them together. Because the decision covers only two words, such classifiers reach very high accuracy, and Golding and Roth showed that a Winnow-based learner over many context features outperformed an earlier Bayesian method. The cost is coverage: you need one classifier and one training set per pair. The slide's final bullet, an end-to-end deep learning system, removes hand-built features: a neural model reads the sentence and outputs the corrected text directly, learning its own features from data.
كل سمة ضعيفة وحدها؛ والمصنّف المتعلَّم يزنها معًا. ولأن القرار يغطي كلمتين فقط، تصل هذه المصنّفات إلى دقة عالية جدًا، وقد أظهر Golding وRoth أن متعلّمًا مبنيًا على Winnow ويعمل على سمات سياقية كثيرة تفوّق على طريقة بايزية (Bayesian) سابقة. الثمن هو التغطية: تحتاج مصنّفًا واحدًا ومجموعة تدريب واحدة لكل زوج. والنقطة الأخيرة في الشريحة، وهي نظام تعلّم عميق من طرف إلى طرف (end-to-end deep learning)، تستغني عن السمات المصنوعة يدويًا: يقرأ نموذج عصبي الجملة ويُخرج النص المصحَّح مباشرة، متعلمًا سماته الخاصة من البيانات.
| Noisy channel with n-gram priorقناة مشوشة مع احتمال مسبق من نوع n-gram | Confusion-set classifierمصنّف مجموعة الالتباس | |
|---|---|---|
| Coverageالتغطية | Any word, via candidate setsأي كلمة، عبر مجموعات المرشحين | Only the pairs it was trained forالأزواج التي دُرّب عليها فقط |
| Evidenceالدليل | Edit probability and a short n-gram windowاحتمال التعديل ونافذة n-gram قصيرة | Many features: distant words, tags, collocationsسمات كثيرة: كلمات بعيدة، ووسوم، وتلازمات لفظية |
| Strengthنقطة القوة | General, one model for everythingعام، نموذج واحد لكل شيء | Very accurate on its pairدقيق جدًا على زوجه |
Quick checkاختبار سريع
In 'I wonder ___ or not to go', which feature points a whether/weather classifier to whether?في 'I wonder ___ or not to go'، أي سمة توجّه مصنّف whether/weather نحو whether؟
Recall
Give the three whether/weather features from the slide and say which word each supports.اذكر سمات whether/weather الثلاث من الشريحة، وحدّد الكلمة التي تدعمها كل سمة.
"cloudy" within ±10 words supports weather. ___ to VERB supports whether. ___ or not supports whether.
«cloudy» ضمن ±10 كلمات تدعم weather. و___ to VERB تدعم whether. و___ or not تدعم whether.
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- The interface follows a confidence ladder: autocorrect only when very confident, then one suggestion, then a list, and only flag when unconfident.تتبع الواجهة سلّم ثقة: تصحيح تلقائي (autocorrect) فقط عند الثقة العالية جدًا، ثم اقتراح واحد، ثم قائمة، ولا تكتفي بالتمييز (flag) إلا عند غياب الثقة.
- Real systems never just multiply prior and channel. They score argmax over w ∈ V of P(x|w) P(w)^λ, or log P(x|w) + λ log P(w), with λ tuned on a development test set.الأنظمة الحقيقية لا تضرب الاحتمال المسبق في القناة ضربًا مباشرًا أبدًا. بل تحسب argmax على w ∈ V لـ P(x|w) P(w)^λ، أو log P(x|w) + λ log P(w)، مع ضبط λ على مجموعة اختبار تطويرية (development test set).
- On acress with a unigram prior, across beats actress at λ = 1 by about 3%. Above λ ≈ 0.99 across wins, below it actress wins, and only context makes actress win robustly.في acress مع احتمال مسبق من نوع unigram، تتفوق across على actress عند λ = 1 بنحو 3%. فوق λ ≈ 0.99 تفوز across، وتحتها تفوز actress، والسياق وحده هو ما يجعل actress تفوز بشكل متين.
- Metaphone (used by GNU aspell) maps words to a sound key with rules such as dropping KN's K. Aspell keeps words whose key is 1 or 2 edits away and scores them by letter and sound edit distance.Metaphone (الذي يستخدمه GNU aspell) يحوّل الكلمات إلى مفتاح صوتي بقواعد مثل حذف K من KN. ويحتفظ aspell بالكلمات التي يبعد مفتاحها تعديلًا واحدًا أو تعديلين، ويقيّمها بمسافة التعديل على الحروف وعلى الصوت.
- Brill and Moore (2000) allow multi-letter edits (ent→ant, ph→f, le→al) conditioned on position. Toutanova and Moore (2002) add pronunciation to the channel.يسمح Brill and Moore (2000) بتعديلات متعددة الحروف (ent→ant، ph→f، le→al) مشروطة بالموضع. وأضاف Toutanova and Moore (2002) النطق إلى القناة.
- P(x|w) depends on source and target letters, surrounding letters, position, nearby keys, keyboard homology, pronunciation and morpheme transformations.يعتمد P(x|w) على الحرفين المصدر والهدف، والحروف المحيطة، والموضع، والمفاتيح المجاورة، والتماثل في لوحة المفاتيح (keyboard homology)، والنطق، وتحولات المورفيمات (morphemes).
- For a confusable pair, a dedicated classifier uses context features such as cloudy within ±10 words, ___ to VERB, and ___ or not. End-to-end neural models are the modern alternative.لزوج قابل للالتباس، يستخدم مصنّف مخصص سمات سياقية مثل cloudy ضمن ±10 كلمات، و___ to VERB، و___ or not. والنماذج العصبية من طرف إلى طرف (end-to-end) هي البديل الحديث.
Sourcesالمصادر
- Speech and Language Processing, Appendix B: Spelling Correction and the Noisy Channel (Jurafsky and Martin)BookStanford, draft of 21 September 2021Section B.3: autocorrect versus flagging, non-commensurate probabilities and equations B.9 and B.10 with λ tuned on a development set, confusion-set classifiers, Brill and Moore partitions, aspell and Metaphone.القسم B.3: التصحيح التلقائي مقابل التمييز، والاحتمالات غير المتكافئة في المقياس، والمعادلتان B.9 وB.10 مع ضبط λ على مجموعة تطوير، ومصنّفات مجموعات الالتباس، وتقسيمات Brill and Moore، وaspell وMetaphone.(opens in a new tab)(يفتح في تبويب جديد)
- An Improved Error Model for Noisy Channel Spelling Correction (Brill and Moore)PaperACL 2000Multi-letter, position-conditioned edits such as ph → f.تعديلات متعددة الحروف مشروطة بالموضع مثل ph → f.(opens in a new tab)(يفتح في تبويب جديد)
- Pronunciation Modeling for Improved Spelling Correction (Toutanova and Moore)PaperACL 2002Adds a pronunciation-based model to the letter-based channel.يضيف نموذجًا مبنيًا على النطق إلى القناة المبنية على الحروف.(opens in a new tab)(يفتح في تبويب جديد)
- GNU Aspell manual: How Aspell WorksDocsGNU AspellSoundslike (Metaphone) key, candidates within one or two edits, score from weighted letter edit distance and soundslike distance.مفتاح soundslike (Metaphone)، والمرشحون ضمن تعديل واحد أو تعديلين، والدرجة من مسافة تعديل الحروف الموزونة ومسافة soundslike.(opens in a new tab)(يفتح في تبويب جديد)
- MetaphoneArticleWikipediaPhilips (1990) and the original rule list, including the three rules on the slide.Philips (1990) وقائمة القواعد الأصلية، بما فيها القواعد الثلاث الواردة في الشريحة.(opens in a new tab)(يفتح في تبويب جديد)
- A Winnow-Based Approach to Context-Sensitive Spelling Correction (Golding and Roth)PaperMachine Learning, 1999Classifiers for confusable real-word pairs using context features.مصنّفات لأزواج الكلمات الحقيقية القابلة للالتباس باستخدام سمات السياق.(opens in a new tab)(يفتح في تبويب جديد)