ICS 582Lecture 05المحاضرة 05Referenceالمرجع
Reference sheetالورقة المرجعية
Spelling correction compressed onto one page: the definitions, formulas and numbers to have in your head before a quiz or exam.محاضرة «التصحيح الإملائي» مضغوطة في صفحة واحدة: التعريفات والمعادلات والأرقام التي يجب أن تكون حاضرة في ذهنك قبل الاختبار القصير أو الامتحان.
Two kinds of errorsنوعان من الأخطاء
Detection asks whether a token is wrong; correction asks what was meant. Real-word errors split into typographical (finger slip) and cognitive (wrong spelling of a sound). Part 01: Spelling tasks and error types
الكشف (detection) يسأل هل الكلمة خاطئة، والتصحيح (correction) يسأل ماذا كان المقصود. وتنقسم أخطاء الكلمات الحقيقية إلى أخطاء مطبعية (typographical، أي زلة إصبع) وأخطاء إدراكية (cognitive، أي تهجئة خاطئة لصوت). الجزء 01: مهام التدقيق الإملائي وأنواع الأخطاء
| Questionالسؤال | Non-word errorخطأ كلمة غير موجودة | Real-word errorخطأ كلمة حقيقية |
|---|---|---|
| In the dictionary?هل الكلمة في القاموس؟ | Noلا | Yesنعم |
| Found by lookup?هل يكشفها البحث في القاموس؟ | Yes, by definitionنعم، بحكم التعريف | No, needs contextلا، تحتاج إلى السياق |
| Where is the error?أين الخطأ؟ | The one token that failed lookupالكلمة الوحيدة التي فشل البحث عنها في القاموس | Unknown: every word is a suspectغير معروف: كل كلمة مشتبه بها |
| Typed word in the candidate set?هل الكلمة المكتوبة ضمن مجموعة المرشحين؟ | No, it cannot be the answerلا، لا يمكن أن تكون هي الإجابة | Yes, it is usually rightنعم، وهي غالبًا الصحيحة |
| Unit of searchوحدة البحث | One wordكلمة واحدة | The whole sentenceالجملة كاملة |
| Examplesأمثلة | graffe for giraffe, hte for thegraffe بدلًا من giraffe، وhte بدلًا من the | there for three (typo), piece for peace (cognitive)there بدلًا من three (خطأ مطبعي)، وpiece بدلًا من peace (خطأ إدراكي) |
Error rates depend on the input conditionمعدلات الخطأ تعتمد على ظروف الإدخال
- Web queriesاستعلامات الويب
- 26% (Wang et al. 2003); the textbook gives 10 to 15%26% (Wang et al. 2003)، ويذكر الكتاب المقرر من 10 إلى 15%
- Retyping, no backspaceإعادة الكتابة دون مفتاح الحذف
- 13% (Whitelaw et al. 2009, measured 10.8% English, 12.5% German)13% (Whitelaw et al. 2009، والقيم المقيسة 10.8% للإنجليزية و12.5% للألمانية)
- Phone-sized keyboardلوحة مفاتيح بحجم الهاتف
- 7% made and corrected, 2% left (Soukoreff and MacKenzie 2003)7% أخطاء ارتُكبت ثم صُححت، و2% بقيت دون تصحيح (Soukoreff and MacKenzie 2003)
- Careful retypingإعادة الكتابة بعناية
- 1 to 2% (Kane and Wobbrock 2007; Grudin 1983)من 1 إلى 2% (Kane and Wobbrock 2007؛ Grudin 1983)
- Real-word shareنسبة أخطاء الكلمات الحقيقية
- 25 to 40% of spelling errors are real words (Kukich 1992)من 25 إلى 40% من الأخطاء الإملائية كلمات حقيقية (Kukich 1992)
The noisy channel modelنموذج القناة المشوشة
The writer meant w, the channel distorted it, we observe x. P(x) is the same for every candidate, so it cannot change the argmax. Part 02: The noisy channel model
الكاتب قصد w، والقناة شوّهتها، ونحن نرى x. قيمة P(x) واحدة لكل المرشحين، لذلك لا يمكن أن تغيّر نتيجة argmax. الجزء 02: نموذج القناة المشوشة
| Factorالعامل | Nameالاسم | Knowsماذا يعرف | Learned fromمصدر تعلّمه |
|---|---|---|---|
| P(x|w)P(x|w) | Channel or error model, the likelihoodنموذج القناة أو نموذج الخطأ، أي الاحتمال المشروط (likelihood) | How typing turns w into xكيف تحوّل الكتابة w إلى x | Error corpora, confusion matricesمدونات الأخطاء، ومصفوفات الالتباس |
| P(w)P(w) | Language model, the priorالنموذج اللغوي، أي الاحتمال المسبق (prior) | How likely w is as textما احتمال ظهور w في النص | Plain text: unigram or bigram countsنص عادي: أعداد الأحادي (unigram) أو الثنائي (bigram) |
| Taskالمهمة | Observedالمُشاهَد | Hiddenالخفي | Channelالقناة | Priorالاحتمال المسبق |
|---|---|---|---|---|
| Spellingالتدقيق الإملائي | Typed string xالسلسلة المكتوبة x | Intended word wالكلمة المقصودة w | P(x|w)P(x|w) | P(w)P(w) |
| Speech recognitionالتعرف على الكلام | Audioالصوت | Word sequenceسلسلة الكلمات | P(audio|words)P(audio|words) | P(words)P(words) |
| Machine translationالترجمة الآلية | French fالفرنسية f | English eالإنجليزية e | Pr(f|e)Pr(f|e) | Pr(e)Pr(e) |
Candidate generationتوليد المرشحين
Candidates are real words within a small edit distance in spelling or in pronunciation. About 80% of errors are one edit away and almost all within two. Space and hyphen edits catch thisidea and inlaw. Part 03: Generating candidates
المرشحون كلمات حقيقية تقع ضمن مسافة تعديل صغيرة في التهجئة أو في النطق. حوالي 80% من الأخطاء تبعد تعديلًا واحدًا، وكلها تقريبًا ضمن تعديلين. وتعديلات المسافة والشرطة تلتقط thisidea وinlaw. الجزء 03: توليد المرشحين
| Editالتعديل | What the typist didماذا فعل الكاتب | Quick testاختبار سريع | acress exampleمثال acress |
|---|---|---|---|
| Deletionالحذف (Deletion) | Typist left a letter outالكاتب أسقط حرفًا | Intended is longerالكلمة المقصودة أطول | acress from actress (t)acress من actress (t) |
| Insertionالإدراج (Insertion) | Typist added a letterالكاتب أضاف حرفًا | Intended is shorterالكلمة المقصودة أقصر | acress from cress (a)acress من cress (a) |
| Substitutionالاستبدال (Substitution) | One letter typed for anotherكُتب حرف مكان حرف آخر | Same lengthالطول نفسه | acress from across (e for o)acress من across (e مكان o) |
| Transpositionالتبديل (Transposition) | Two adjacent letters swappedتبادل حرفان متجاوران موضعيهما | Same length, swapped pairالطول نفسه، مع زوج متبادل | acress from caress (ac for ca)acress من caress (ac مكان ca) |
| LevenshteinLevenshtein | Damerau-LevenshteinDamerau-Levenshtein | |
|---|---|---|
| Operationsالعمليات | Insertion, deletion, substitutionالإدراج، والحذف، والاستبدال | The same three plus adjacent transpositionالعمليات الثلاث نفسها، مع تبديل الحرفين المتجاورين |
| Distance acress to caressالمسافة من acress إلى caress | 22 | 11 |
| Used inتُستخدم في | Lecture 2, minimum edit distanceالمحاضرة 2، الحد الأدنى لمسافة التعديل | This lecture, candidate generationهذه المحاضرة، توليد المرشحين |
- acress has six candidates in seven rows: acres appears twice, an extra s at position 4 (es|e) or 5 (ss|s).لـ acress ستة مرشحين في سبعة صفوف: تظهر acres مرتين، بحرف s زائد في الموضع 4 (es|e) أو في الموضع 5 (ss|s).
- Excluding same-letter replacements turns 26n into 25n, giving 343 for acress.استبعاد الاستبدال بالحرف نفسه يحوّل 26n إلى 25n، فيصبح العدد 343 لـ acress.
The prior and the channel modelالاحتمال المسبق ونموذج القناة
Any language model can supply the prior; the unigram one is a count over the corpus size. The channel is the probability of the single edit, read as typed given intended. Part 04: The prior and the channel model
أي نموذج لغوي يمكن أن يعطي الاحتمال المسبق، والنموذج الأحادي (unigram) هو عدد مرات الكلمة مقسومًا على حجم المدونة. أما القناة فهي احتمال التعديل الواحد، ويُقرأ على أنه المكتوب بشرط المقصود. الجزء 04: الاحتمال المسبق ونموذج القناة
Unigram priors for the acress candidatesالاحتمالات المسبقة الأحادية لمرشحي acress
- Corpusالمدونة
- COCA, N = 404,253,213 word tokensCOCA، وN = 404,253,213 وحدة كلمة (word tokens)
- actress
- 9,321 / N = .0000231
- across
- 120,844 / N = .000299, about 13× actress120,844 / N = .000299، أي حوالي 13× قيمة actress
- access
- 37,038 / N = .0000916
- acres
- 12,874 / N = .0000318
- caress, cress
- 686 and 220 counts, .00000170 and .000000544العددان 686 و220، والاحتمالان .00000170 و.000000544
The four confusion matrices (Kernighan, Church and Gale 1990)مصفوفات الالتباس الأربع (Kernighan وChurch وGale، 1990)
- del[x,y]
- count(xy typed as x): the y after x was left outعدد مرات كتابة xy على شكل x: سقط الحرف y الذي يلي x
- ins[x,y]
- count(x typed as xy): an extra y typed after xعدد مرات كتابة x على شكل xy: كُتب حرف y زائد بعد x
- sub[x,y]
- count(y typed as x): typed letter first, intended secondعدد مرات كتابة y على شكل x: الحرف المكتوب أولًا، والمقصود ثانيًا
- trans[x,y]
- count(xy typed as yx): adjacent letters swappedعدد مرات كتابة xy على شكل yx: تبادل حرفان متجاوران موضعيهما
- Word startبداية الكلمة
- The symbol #, so cress uses ins[#,a] / count[#]الرمز #، لذلك تستخدم cress الصيغة ins[#,a] / count[#]
- Zero countsالأعداد الصفرية
- Smoothed before use: sub[r,c] = 0 still gives P(r|c) = .000000209تُنعَّم قبل الاستخدام: sub[r,c] = 0 ومع ذلك تعطي P(r|c) = .000000209
Scoring acressحساب درجات acress
Multiply the channel column by the prior column, then rank. Part 05: Scoring acress
اضرب عمود القناة في عمود الاحتمال المسبق، ثم رتّب. الجزء 05: حساب درجات acress
| ww | x|wx|w | Editالتعديل | Cell / denominatorالخلية / المقام | P(x|w)P(x|w) | P(w)P(w) | 10⁹ × product10⁹ × حاصل الضرب |
|---|---|---|---|---|---|---|
| actressactress | c|ctc|ct | deletionحذف | del[c,t] / count[ct]del[c,t] / count[ct] | .000117.000117 | .0000231.0000231 | 2.702.70 |
| cresscress | a|#a|# | insertionإدراج | ins[#,a] / count[#]ins[#,a] / count[#] | .00000144.00000144 | .000000544.000000544 | .00078.00078 |
| caresscaress | ac|caac|ca | transpositionتبديل | trans[c,a] / count[ca]trans[c,a] / count[ca] | .00000164.00000164 | .00000170.00000170 | .0028.0028 |
| accessaccess | r|cr|c | substitutionاستبدال | sub[r,c] / count[c]sub[r,c] / count[c] | .000000209.000000209 | .0000916.0000916 | .019.019 |
| acrossacross | e|oe|o | substitutionاستبدال | sub[e,o] / count[o]sub[e,o] / count[o] | .0000093.0000093 | .000299.000299 | 2.782.78 |
| acresacres | es|ees|e | insertionإدراج | ins[e,s] / count[e]ins[e,s] / count[e] | .0000321.0000321 | .0000318.0000318 | 1.021.02 |
| acresacres | ss|sss|s | insertionإدراج | ins[s,s] / count[s]ins[s,s] / count[s] | .0000342.0000342 | .0000318.0000318 | 1.091.09 |
- Unigram winner: across (2.78) over actress (2.70), about 3%. Summed acres is about 2.11, still third. Wrong in context.الفائز مع الاحتمال الأحادي: across (2.78) على actress (2.70)، بفارق حوالي 3%. ومجموع صفّي acres حوالي 2.11، فتبقى ثالثة. والنتيجة خاطئة في السياق.
- Prior favors across about 13×; channel favors actress about 12.6×. They nearly cancel.الاحتمال المسبق يفضّل across بحوالي 13×، والقناة تفضّل actress بحوالي 12.6×. فيكاد كل منهما يلغي الآخر.
| Unigram priorاحتمال مسبق أحادي | Bigram contextسياق ثنائي | |
|---|---|---|
| Prior factorعامل الاحتمال المسبق | P(w)P(w) | P(w|versatile) × P(whose|w)P(w|versatile) × P(whose|w) |
| actressactress | 2.70 × 10⁻⁹2.70 × 10⁻⁹ | .000117 × .000021 × .0010 = 2.46 × 10⁻¹².000117 × .000021 × .0010 = 2.46 × 10⁻¹² |
| acrossacross | 2.78 × 10⁻⁹2.78 × 10⁻⁹ | .0000093 × .000021 × .000006 = 1.17 × 10⁻¹⁵.0000093 × .000021 × .000006 = 1.17 × 10⁻¹⁵ |
| Decisionالقرار | across, by about 3%across، بفارق حوالي 3% | actress, by about 2,100 timesactress، بفارق حوالي 2,100 مرة |
Evaluate on real misspellings held out from tuning: Wikipedia's list, the Aspell list, the Birkbeck corpus and Norvig's bundle, split into train, dev and test. Norvig's corrector drops from 75% on dev to 68% on test.
قيّم النظام على أخطاء إملائية حقيقية محجوزة عن الضبط: قائمة Wikipedia، وقائمة Aspell، ومدونة Birkbeck، ومجموعة Norvig، مقسّمة إلى تدريب وتطوير واختبار (train, dev, test). تنخفض دقة مصحح Norvig من 75% على مجموعة التطوير إلى 68% على مجموعة الاختبار.
Real-word errorsأخطاء الكلمات الحقيقية
Lookup passes every real-word error, so every word is a suspect and the search moves to the whole sentence. Part 06: Real-word spelling errors
البحث في القاموس يمرّر كل خطأ كلمة حقيقية، لذلك تصبح كل كلمة مشتبهًا بها وينتقل البحث إلى الجملة كاملة. الجزء 06: أخطاء الكلمات الحقيقية
| Typedالمكتوب | Intendedالمقصود | Editالتعديل |
|---|---|---|
| minuetsminuets | minutesminutes | Transposition of t and eتبديل t وe |
| anan | andand | Deletion of dحذف d |
| lavelave | leaveleave | Deletion of the first eحذف أول e |
| bebe | byby | Substitution of e for yاستبدال e مكان y |
The lattice, one error, and αالشبكة، والخطأ الواحد، وα
Stack candidate sets in columns; each left-to-right path is a sentence. Assume at most one error to keep the search linear. Part 07: The candidate lattice and P(w|w)
رصّ مجموعات المرشحين في أعمدة، فيكون كل مسار من اليسار إلى اليمين جملة. افترض خطأً واحدًا على الأكثر ليبقى البحث خطيًا. الجزء 07: شبكة المرشحين وP(w|w)
Counting candidate sentencesعدّ الجمل المرشحة
- Candidate setمجموعة المرشحين
- The word itself, its one-edit dictionary neighbors, its homophonesالكلمة نفسها، وجيرانها في القاموس على بعد تعديل واحد، والكلمات المتجانسة معها صوتيًا (homophones)
- two of thew
- Set sizes 4, 3, 4أحجام المجموعات 4, 3, 4
- Full latticeالشبكة الكاملة
- Product: 4 × 3 × 4 = 48 sentencesحاصل الضرب: 4 × 3 × 4 = 48 جملة
- One error per sentenceخطأ واحد في كل جملة
- Sum: 1 + 3 + 2 + 3 = 9 sentencesالمجموع: 1 + 3 + 2 + 3 = 9 جمل
- Best pathأفضل مسار
- two of thetwo of the
| αα | Errorsالأخطاء | 1 − α1 − α |
|---|---|---|
| .90.90 | 1 in 10خطأ واحد من كل 10 | 0.100.10 |
| .95.95 | 1 in 20خطأ واحد من كل 20 | 0.050.05 |
| .99.99 | 1 in 100خطأ واحد من كل 100 | 0.010.01 |
| .995.995 | 1 in 200خطأ واحد من كل 200 | 0.0050.005 |
| ww | x|wx|w | Editالتعديل | P(x|w)P(x|w) | P(w)P(w) | 10⁹ × product10⁹ × حاصل الضرب |
|---|---|---|---|---|---|
| thethe | ew|eew|e | Insertionإدراج | 0.0000070.000007 | 0.020.02 | 140140 |
| thewthew | noneلا يوجد | No editبلا تعديل | α = 0.95α = 0.95 | 0.000000090.00000009 | 85.585.5 |
| thawthaw | e|ae|a | Substitutionاستبدال | 0.0010.001 | 0.00000070.0000007 | 0.70.7 |
| threwthrew | h|hrh|hr | Deletionحذف | 0.0000080.000008 | 0.0000040.000004 | 0.0320.032 |
| thwethwe | ew|weew|we | Transpositionتبديل | 0.0000030.000003 | 0.000000040.00000004 | 0.000120.00012 |
State-of-the-art systemsالأنظمة الحديثة المتقدمة
Part 08: State-of-the-art spelling systems
الجزء 08: أنظمة التدقيق الإملائي الحديثة المتقدمة
| Confidenceالثقة | Actionالإجراء |
|---|---|
| Very confidentثقة عالية جدًا | Autocorrect silentlyصحّح تلقائيًا دون إشعار |
| Less confidentثقة أقل | Offer the single best correctionاعرض أفضل تصحيح واحد |
| Less confident stillثقة أقل من ذلك | Offer a ranked listاعرض قائمة مرتبة |
| Unconfidentلا ثقة | Just flag the tokenاكتفِ بتمييز الكلمة |
| λλ | Winnerالفائز | Marginالفارق |
|---|---|---|
| 00 | actressactress | actress by about 12.6×actress بفارق حوالي 12.6× |
| 0.50.5 | actressactress | actress by about 3.5×actress بفارق حوالي 3.5× |
| 11 | acrossacross | across by about 1.03×across بفارق حوالي 1.03× |
| 22 | acrossacross | across by about 13×across بفارق حوالي 13× |
- Crossover at λ ≈ 0.989: above it across wins, below it actress wins.نقطة التقاطع عند λ ≈ 0.989: فوقها تفوز across، وتحتها تفوز actress.
- Metaphone rules: drop duplicate adjacent letters except C; drop the first letter of initial KN, GN, PN, AE, WR; drop final B after M. knight and nite both become NT.قواعد Metaphone: احذف الحروف المتجاورة المكررة ما عدا C، واحذف الحرف الأول من البدايات KN وGN وPN وAE وWR، واحذف B الأخيرة بعد M. تصبح knight وnite كلتاهما NT.
- GNU aspell: convert to the Metaphone key, keep words whose key is 1 or 2 edits away, score by letter and sound edit distance.GNU aspell: حوّل الكلمة إلى مفتاح Metaphone، واحتفظ بالكلمات التي يبعد مفتاحها 1 أو 2 تعديل، ثم قيّمها بمسافة التعديل في الحروف وفي الأصوات.
- Brill and Moore 2000: multi-letter edits such as ph → f, ent → ant, le → al, conditioned on position. Toutanova and Moore 2002 add pronunciation.Brill وMoore عام 2000: تعديلات متعددة الحروف مثل ph → f وent → ant وle → al، مشروطة بالموضع في الكلمة. ويضيف Toutanova وMoore عام 2002 النطق.
- Confusion-set classifier for whether and weather: cloudy within ±10 words, ___ to VERB, ___ or not. End-to-end neural models are the modern alternative.مصنّف مجموعة الالتباس لـ whether وweather: وجود cloudy ضمن ±10 كلمات، والنمط ___ to VERB، والنمط ___ or not. والنماذج العصبية من الطرف إلى الطرف (end-to-end neural models) هي البديل الحديث.
| Factorالعامل | Exampleمثال |
|---|---|
| Source and target lettersالحرفان المصدر والهدف | e|o in acresse|o في acress |
| Surrounding lettersالحروف المحيطة | Doubled letters invite insertionsالحروف المضاعفة تستدعي أخطاء الإدراج |
| Position in the wordالموضع في الكلمة | P(f|ph) at word startP(f|ph) في بداية الكلمة |
| Nearby keysالمفاتيح المجاورة | r or w typed for eكتابة r أو w مكان e |
| Keyboard homologyتماثل لوحة المفاتيح (Keyboard homology) | i typed for e, same finger on the other handكتابة i مكان e، بالإصبع نفسه في اليد الأخرى |
| Pronunciationالنطق | f written for ph, nite for knightكتابة f مكان ph، وnite مكان knight |
| Morpheme transformationsتحويلات المورفيمات | -ant written for -ent, -ible for -ableكتابة -ant مكان -ent، و-ible مكان -able |
Slide errataأخطاء الشرائح
Answer with the corrected fact, and say when you compute from the numbers given. Each correction is explained in the part that covers the slide.
أجب بالمعلومة المصححة، واذكر متى تحسب من الأرقام المعطاة. كل تصحيح مشروح في الجزء الذي يغطي الشريحة.
What the slides get wrongما تخطئ فيه الشرائح
- Slides 4, 5الشريحتان 4 و5
- Arrows are private-use glyphs lost on copy. three → there runs intended to typo; the other pairs run typo to fix.الأسهم رموز من النطاق الخاص (private-use glyphs) تضيع عند النسخ. السهم في three → there يتجه من المقصود إلى الخطأ، أما بقية الأزواج فتتجه من الخطأ إلى التصحيح.
- Slide 6الشريحة 6
- Gruden should be Grudin. Soukoreff and MacKenzie count characters, not words. Whitelaw measured 10.8% and 12.5%, not 13%.صوابها Grudin لا Gruden. ويعدّ Soukoreff وMacKenzie الحروف لا الكلمات. وقاس Whitelaw القيمتين 10.8% و12.5%، لا 13%.
- Slide 12الشريحة 12
- Mays, Damerau and Mercer is volume 27(5), not 23(5).ورقة Mays وDamerau وMercer في المجلد 27(5)، لا 23(5).
- Slide 18الشريحة 18
- COCA is the Corpus of Contemporary American English.COCA هي مدونة الإنجليزية الأمريكية المعاصرة (Corpus of Contemporary American English).
- Slide 20الشريحة 20
- sub[x,y] is count(y typed as x): typed letter first, as slides 21 and 23 use it.sub[x,y] هو عدد مرات كتابة y على شكل x: الحرف المكتوب أولًا، كما تستخدمه الشريحتان 21 و23.
- Slide 25الشريحة 25
- acres via ss|s is 1.09, so 1.1, not 1.0.درجة acres عبر ss|s هي 1.09، أي 1.1 لا 1.0.
- Slide 27الشريحة 27
- .000021 × .000006 = 1.26 × 10⁻¹⁰, shown as 1 × 10⁻¹⁰. Context ratio is about 167, not 210..000021 × .000006 = 1.26 × 10⁻¹⁰، وتظهر في الشريحة 1 × 10⁻¹⁰. ونسبة السياق حوالي 167، لا 210.
- Slide 32الشريحة 32
- Title says real-world; it means real-word.العنوان يقول real-world، والمقصود real-word.
- Slide 33الشريحة 33
- Maximize P(X|W) P(W), not P(W) alone.المطلوب تعظيم P(X|W) P(W)، لا P(W) وحدها.
- Slides 34, 35الشريحتان 34 و35
- The bottom node under thew repeats thaw; it should be thew.العقدة السفلى تحت thew تكرر thaw، وصوابها thew.
- Slide 39الشريحة 39
- Inputs give 140 and 85.5, not 144 and 90; ranking unchanged.المدخلات تعطي 140 و85.5، لا 144 و90، والترتيب لا يتغير.
- Slide 42الشريحة 42
- Lost symbols: the exponent λ on P(w) and the ∈ in w ∈ V.رموز ضائعة: الأس λ على P(w)، والرمز ∈ في w ∈ V.