Majid Al-RaimiFull guideالشرح الكامل

ICS 582Lecture 05المحاضرة 05Full guideالشرح الكامل

Spelling correctionالتصحيح الإملائي

The whole lecture on one page, taught concept by concept. Work through the parts in order, mark each concept once you understand it, and open the slide chips when you want the original slides.المحاضرة كاملة في صفحة واحدة، مشروحة مفهومًا مفهومًا. امشِ على الأجزاء بالترتيب، وعلّم كل مفهوم بعد أن تفهمه، وافتح أزرار الشرائح عندما تريد الرجوع إلى الشرائح الأصلية.

Partsالأجزاء
8
Conceptsالمفاهيم
30
Slidesالشرائح
48
Readingمدة القراءة
180 min180 دقيقة
Understoodما فهمته
0/30 conceptsمفاهيم

Part 01: Spelling tasks and the two kinds of errorsمهام الإملاء ونوعا الأخطاء

Where spelling correction shows up, detection versus correction, the non-word versus real-word split, how often people actually misspell, and the outline of how each kind of error is fixed.أين يظهر التصحيح الإملائي، والاكتشاف مقابل التصحيح، والتقسيم بين أخطاء الكلمات غير الموجودة وأخطاء الكلمات الحقيقية، وكم مرة يخطئ الناس فعلا في الإملاء، وخطوط عريضة لكيفية إصلاح كل نوع.

6 concepts6 مفاهيم, ، slides 1-8الشرائح 1-8

Why this part mattersلماذا يهمّ هذا الجزء

Spelling correction is the first NLP application most people ever met, and it is the cleanest place to learn the noisy channel model that the rest of this lecture builds. Before any probabilities appear, you need a sharp picture of the problem: what the system is asked to do, and what makes some errors easy and others nearly invisible.

The whole part is one argument. The task splits into detection and correction. How hard both are depends on a single question: does the error land outside the dictionary, or inside it? An error outside the dictionary is caught by simple lookup. An error inside the dictionary passes lookup untouched and can only be caught by reading the context. Everything else in this lecture (candidates, edit distance, priors, channel models, lattices) is machinery for answering that question well. For the exam, expect to classify errors, to say which ones a dictionary can detect, and to justify the design of each pipeline.

تصحيح الإملاء هو أول تطبيق من تطبيقات معالجة اللغات الطبيعية (NLP) يصادفه معظم الناس، وهو أوضح مكان لتعلّم نموذج القناة المشوشة (noisy channel model) الذي تبني عليه بقية هذه المحاضرة. وقبل أن تظهر أي احتمالات، تحتاج إلى صورة حادة للمشكلة: ما المطلوب من النظام أن يفعله، وما الذي يجعل بعض الأخطاء سهلة وبعضها شبه خفي.

هذا الجزء كله حجة واحدة. تنقسم المهمة إلى كشف وتصحيح، وصعوبة كل منهما تتوقف على سؤال واحد: هل يقع الخطأ خارج القاموس أم داخله؟ الخطأ الواقع خارج القاموس يُكتشف بمجرد البحث فيه. أما الخطأ الواقع داخل القاموس فيمرّ من البحث دون أن يُمسّ، ولا يمكن اكتشافه إلا بقراءة السياق. وكل ما يأتي بعد ذلك في هذه المحاضرة (المرشحون candidates، ومسافة التحرير edit distance، والاحتمالات المسبقة priors، ونماذج القناة channel models، والشبكات lattices) هو أدوات للإجابة عن هذا السؤال إجابة جيدة. وفي الاختبار، توقّع أن يُطلب منك تصنيف الأخطاء، وتحديد ما يستطيع القاموس كشفه منها، وتبرير تصميم كل مسار.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Split spelling work into detection and correction, and place autocorrect, a single suggestion and a suggestion list on a ladder of confidence.تقسيم عمل الإملاء إلى كشف وتصحيح، ووضع التصحيح التلقائي (autocorrect) والاقتراح الواحد وقائمة الاقتراحات على سلّم الثقة.
  2. Classify any misspelling as a non-word error or a real-word error, and split real-word errors into typographical and cognitive.تصنيف أي خطأ إملائي على أنه خطأ كلمة غير موجودة (non-word error) أو خطأ كلمة حقيقية (real-word error)، وتقسيم أخطاء الكلمات الحقيقية إلى أخطاء طباعية (typographical) وأخطاء معرفية (cognitive).
  3. Explain why dictionary lookup detects non-word errors and is blind to real-word errors.شرح لماذا يكشف البحث في القاموس أخطاء الكلمات غير الموجودة، ولماذا لا يرى أخطاء الكلمات الحقيقية إطلاقا.
  4. Read published error rates as properties of the input condition, from 1 to 2% for careful retyping to 26% for web queries.قراءة معدلات الأخطاء المنشورة على أنها خصائص لظروف الإدخال، من 1 إلى 2% عند إعادة الكتابة بعناية حتى 26% في استعلامات البحث على الويب.
  5. Outline the two correction pipelines, and say why the real-word candidate set must contain the typed word itself.عرض الخطوط العامة لمسارَي التصحيح، وبيان لماذا يجب أن تحتوي مجموعة المرشحين لأخطاء الكلمات الحقيقية على الكلمة المكتوبة نفسها.

Look at three screenshots from the lecture before reading any definitions. Each one shows a different system doing a different job, and together they already contain the whole taxonomy of this part.

انظر إلى ثلاث لقطات شاشة من المحاضرة قبل قراءة أي تعريفات. كل واحدة منها تُظهر نظاما مختلفا يؤدي مهمة مختلفة، وهي معا تحتوي مسبقا على التصنيف الكامل لهذا الجزء.

  • Microsoft Word underlines the sentence This is bigger then that ofcourse. It flags then and offers the single fix than. That is remarkable: then is a perfectly good English word, so Word could only have caught it by reading bigger ... that around it. It also flags ofcourse, which is not a word at all; the writer simply left out a space.يضع Microsoft Word خطا تحت الجملة This is bigger then that ofcourse. فهو يعلّم then ويعرض إصلاحا واحدا هو than. وهذا لافت للنظر: then كلمة إنجليزية صحيحة تماما، فلم يكن بإمكان Word أن يكتشفها إلا بقراءة bigger ... that من حولها. ويعلّم أيضا ofcourse، وهي ليست كلمة أصلا؛ فالكاتب ببساطة نسي مسافة.
  • A web search engine receives natural langage processing and answers Showing results for natural language processing, with a link to search the original instead. langage is not an English word, so the engine knew something was wrong and was confident enough to act on its fix.محرك بحث على الويب يستقبل natural langage processing فيجيب Showing results for natural language processing (أي: تُعرض نتائج natural language processing)، مع رابط للبحث عن النص الأصلي بدلا من ذلك. كلمة langage ليست كلمة إنجليزية، لذلك عرف المحرك أن هناك خطأ، وكان واثقا بما يكفي ليطبّق إصلاحه مباشرة.
  • A phone keyboard shows I will check it ther and offers three buttons: there, the, they. It is sure ther is wrong but not sure what was meant, so it hands the choice back to the user.لوحة مفاتيح الهاتف تعرض I will check it ther وتقدّم ثلاثة أزرار: there وthe وthey. فهي متأكدة أن ther خاطئة، لكنها غير متأكدة مما كان مقصودا، لذلك تعيد قرار الاختيار إلى المستخدم.

Notice the two separate questions each tool answers. First: is there an error here at all? Second: what was intended, and how sure am I? The second question also decides how the fix is shown: replaced silently, offered once, or offered as a list. And notice the difference between the errors themselves. langage, ther and ofcourse are not words. then is a word, just the wrong one. That difference is the spine of the rest of the part.

لاحظ السؤالين المنفصلين اللذين تجيب عنهما كل أداة. الأول: هل يوجد خطأ هنا أصلا؟ الثاني: ما الذي كان مقصودا، وما مدى تأكدي؟ والسؤال الثاني يحدد أيضا طريقة عرض الإصلاح: يُستبدل بصمت، أو يُعرض مرة واحدة، أو يُعرض كقائمة. ولاحظ أيضا الفرق بين الأخطاء نفسها. langage وther وofcourse ليست كلمات. أما then فهي كلمة، لكنها الكلمة الخطأ. وهذا الفرق هو العمود الفقري لبقية هذا الجزء.

Recall

Which of the four errors in the slide 3 screenshots would a pure word-list checker miss, and why?أيّ الأخطاء الأربعة في لقطات الشريحة 3 سيفوت مدققا يعتمد على قائمة الكلمات فقط، ولماذا؟

Only then for than. The other three (ofcourse, langage, ther) are not in any English word list, so lookup flags them. then is a valid word, so lookup passes it; only the comparative context bigger ... that shows it is wrong.

فقط then بدلا من than. الثلاثة الأخرى (ofcourse وlangage وther) غير موجودة في أي قائمة كلمات إنجليزية، لذلك يعلّمها البحث في القاموس. أما then فكلمة صحيحة، فيمرّرها البحث؛ والذي يكشف أنها خاطئة هو سياق المقارنة bigger ... that وحده.

Type hte on a phone and it becomes the before you look up. Type ther and you get three buttons instead. Both systems detected the error. They differ in how much they trusted their correction.

اكتب hte على الهاتف فتتحول إلى the قبل أن ترفع نظرك. واكتب ther فتحصل بدلا من ذلك على ثلاثة أزرار. كلا النظامين اكتشف الخطأ، والفرق بينهما هو مقدار ثقتهما في التصحيح.

This is the first split. Spelling error detection decides whether a token is misspelled and nothing more; the red underline is detection. Spelling error correction proposes what the writer meant. Detection can exist without correction (a plain underline), but correction always needs detection first, because you cannot fix what you did not notice.

هذا هو التقسيم الأول. Spelling error detection (كشف الخطأ الإملائي) يقرر هل الكلمة مكتوبة خطأ أم لا، ولا شيء أكثر من ذلك؛ والخط الأحمر تحت الكلمة هو الكشف. أما Spelling error correction (تصحيح الخطأ الإملائي) فيقترح ما كان الكاتب يقصده. يمكن أن يوجد الكشف دون تصحيح (خط تحت الكلمة فقط)، لكن التصحيح يحتاج دائما إلى الكشف أولا، لأنك لا تستطيع إصلاح ما لم تلاحظه.

Correction comes in three strengths, and they form a ladder:

يأتي التصحيح بثلاث درجات من القوة، وهي تشكّل سلّما:

  1. Autocorrect: replace the word without asking, as hte to the, or as the search engine does when it runs natural language processing straight away and leaves only a Search instead for link back. Only safe when the system is very confident, because a wrong silent change is worse than no change.Autocorrect (التصحيح التلقائي): استبدال الكلمة دون سؤال، كما في hte إلى the، أو كما يفعل محرك البحث حين يشغّل البحث عن natural language processing مباشرة ولا يترك إلا رابط Search instead for للعودة إلى النص الأصلي. وهو آمن فقط حين يكون النظام واثقا جدا، لأن التغيير الصامت الخاطئ أسوأ من عدم التغيير.
  2. Suggest a correction: show one fix and let the user accept it, as Word does when its right-click menu offers than above Ignore.اقتراح تصحيح: عرض إصلاح واحد وترك المستخدم يقبله، كما يفعل Word حين تعرض قائمة النقر بالزر الأيمن than فوق خيار Ignore (تجاهل).
  3. Suggestion list: show several fixes ranked by likelihood, as the keyboard does with there, the, they. Used when the top candidates are close.قائمة اقتراحات: عرض عدة إصلاحات مرتبة حسب الاحتمال، كما تفعل لوحة المفاتيح مع there وthe وthey. وتُستخدم حين تكون المرشحات الأولى متقاربة.
The more confident the system is in its top candidate, the more it is allowed to act on its ownكلما زادت ثقة النظام في المرشح الأول، زاد ما يُسمح له بفعله من تلقاء نفسه

Why hte is safe to autocorrect and ther is not: hte has one overwhelmingly likely source, the most frequent word in English, one swap away. ther sits one edit away from there, the, they, then and her, several of them very common. The lecture returns to this policy at the end as the Confidence ladder, once you can compute the confidence it depends on.

لماذا يكون التصحيح التلقائي لـhte آمنا ولـther غير آمن: لـhte مصدر واحد مرجّح بفارق ساحق، وهو أكثر الكلمات تكرارا في الإنجليزية، على بُعد تبديل واحد. أما ther فتقع على بُعد تعديل واحد من there وthe وthey وthen وher، وكثير منها شائع جدا. وتعود المحاضرة إلى هذه السياسة في نهايتها باسم Confidence ladder (سلّم الثقة)، بعد أن تصبح قادرا على حساب الثقة التي تعتمد عليها.

Take three slips. Someone types graffe for giraffe. Someone types there when they meant three. Someone writes piece in a sentence about a peace treaty. All three are spelling errors, and they are three different problems.

خذ ثلاث زلات. شخص يكتب graffe بدلا من giraffe. وشخص يكتب there وهو يقصد three. وشخص يكتب piece في جملة عن معاهدة peace (سلام). الثلاثة كلها أخطاء إملائية، لكنها ثلاث مشكلات مختلفة.

Where the error lands decides everythingالمكان الذي يقع فيه الخطأ يحدد كل شيء

graffe is a Non-word error: the typed string is not in the dictionary. That one fact makes it easy to detect, since any lookup fails. there and piece are real-word errors: the slip happened to land on another valid word. Lookup succeeds, so the error is invisible to it. The only evidence left is that the word does not fit its neighbours: I bought there tickets is odd English, I bought three tickets is not.

graffe هي Non-word error (خطأ كلمة غير موجودة): النص المكتوب ليس في القاموس. وهذه الحقيقة وحدها تجعل كشفه سهلا، لأن أي بحث في القاموس سيفشل. أما there وpiece فهما real-word errors (أخطاء كلمات حقيقية): وقعت الزلة صدفة على كلمة صحيحة أخرى. فالبحث في القاموس ينجح، ولذلك يكون الخطأ خفيا عنه. والدليل الوحيد الباقي هو أن الكلمة لا تتلاءم مع جاراتها: I bought there tickets إنجليزية غريبة، أما I bought three tickets فليست كذلك.

Dictionary lookup flags graffe but lets there and piece through; only context can catch thoseالبحث في القاموس يعلّم graffe لكنه يمرّر there وpiece؛ والسياق وحده يستطيع اكتشافهما

Two ways to land on the wrong wordطريقتان للوقوع على الكلمة الخطأ

Real-word errors split again by what went wrong in the writer:

تنقسم أخطاء الكلمات الحقيقية مرة أخرى بحسب ما الذي أخفق عند الكاتب:

  • A Typographical error is a slip of the fingers. The writer knows how to spell three; two keys were pressed in the wrong order and produced there. These errors look like keyboard accidents: one letter inserted, dropped, swapped or replaced, often by a neighbouring key.Typographical error (الخطأ الطباعي) زلة أصابع. الكاتب يعرف كيف يتهجى three، لكنه ضغط مفتاحين بترتيب خاطئ فنتجت there. وتبدو هذه الأخطاء كحوادث لوحة مفاتيح: حرف واحد يُدرج أو يُحذف أو يُبدَّل موضعه أو يُستبدل، وكثيرا ما يكون ذلك بمفتاح مجاور.
  • A Cognitive error is a slip of knowledge. The writer believes piece is how the word for the absence of war is spelled. The typical case is a Homophone: words that sound the same and are spelled differently, such as piece and peace, too and two. These errors are close in sound, not necessarily close in letters.Cognitive error (الخطأ المعرفي) زلة معرفة. الكاتب يعتقد أن piece هي تهجئة الكلمة التي تعني غياب الحرب. والحالة النموذجية هي Homophone (الكلمات المتجانسة صوتيا): كلمات تُنطق بالطريقة نفسها وتُكتب بشكل مختلف، مثل piece وpeace، وtoo وtwo. هذه الأخطاء قريبة في الصوت، وليست بالضرورة قريبة في الحروف.

The split is not just labels. It tells you where to look for the intended word. For a typo, search words a few keystrokes away. For a cognitive error, search words that sound alike. Slide 8 builds exactly those two searches.

هذا التقسيم ليس مجرد تسميات، بل يخبرك أين تبحث عن الكلمة المقصودة. في الخطأ الطباعي، ابحث في الكلمات التي تبعد بضع ضغطات مفاتيح. وفي الخطأ المعرفي، ابحث في الكلمات المتشابهة في النطق. والشريحة 8 تبني هذين البحثين بالضبط.

QuestionالسؤالNon-word errorخطأ كلمة غير موجودة (non-word error)Real-word errorخطأ كلمة حقيقية (real-word error)
Typed token is in the dictionary?هل الكلمة المكتوبة موجودة في القاموس؟NoلاYesنعم
Detectable by dictionary lookup?هل يمكن كشفه بالبحث في القاموس؟Yes, by definitionنعم، بحكم التعريفNo, lookup says it is fineلا، البحث يقول إنها سليمة
Needs context to detect?هل يحتاج كشفه إلى السياق؟NoلاYes, the surrounding words are the only evidenceنعم، الكلمات المحيطة هي الدليل الوحيد
Examplesأمثلةgraffe for giraffe, hte for the, langagegraffe بدلا من giraffe، وhte بدلا من the، وlangagethere for three, piece for peace, then for thanthere بدلا من three، وpiece بدلا من peace، وthen بدلا من than
Which words are checked?ما الكلمات التي تُفحص؟Only the flagged tokensالكلمات المعلَّمة فقطEvery word in the sentenceكل كلمة في الجملة
Candidate set includes the typed word?هل تتضمن مجموعة المرشحين الكلمة المكتوبة؟No, it is known to be wrongلا، فمن المعروف أنها خاطئةYes, the typed word may be rightنعم، فقد تكون الكلمة المكتوبة صحيحة
Non-word versus real-word errorsأخطاء الكلمات غير الموجودة مقابل أخطاء الكلمات الحقيقية

Worked exampleمثال محلول

How much a dictionary-only checker missesكم يفوّت المدقق الذي يعتمد على القاموس وحده

  1. Take the textbook's estimateخذ تقدير الكتاب المقرر

    Studies summarised by Kukich and quoted in Jurafsky and Martin put real-word errors at 25% to 40% of all spelling errors.

    الدراسات التي لخّصها Kukich ونقلها Jurafsky وMartin تقدّر أخطاء الكلمات الحقيقية بنسبة 25% إلى 40% من جميع الأخطاء الإملائية.

  2. Apply it to 100 errorsطبّقه على 100 خطأ

    Out of 100 misspellings in a document, between 25 and 40 are valid words.

    من بين 100 خطأ إملائي في مستند ما، يكون ما بين 25 و40 منها كلمات صحيحة.

  3. Ask what lookup catchesاسأل ماذا يكتشف البحث في القاموس

    Lookup flags only the non-words: 60 to 75 of the 100.

    البحث يعلّم الكلمات غير الموجودة فقط: من 60 إلى 75 من أصل 100.

  4. Resultالنتيجة

    Even with a perfect dictionary, a lookup-only checker has a detection recall of at most 60% to 75%. The missing quarter or more is exactly the real-word class.
    حتى مع قاموس مثالي، يكون استدعاء الكشف (detection recall) للمدقق الذي يعتمد على البحث وحده 60% إلى 75% في أحسن الأحوال. والربع المفقود أو أكثر هو بالضبط فئة أخطاء الكلمات الحقيقية.
SimulatorمحاكيError-type sorter: which kind of misspelling is this?مصنِّف أنواع الأخطاء: ما نوع هذا الخطأ الإملائي؟

We saw a graffe at the zoo.

Ask two questions: is the typed token in the dictionary, and did the fingers slip or did the writer not know the spelling?اسأل سؤالين: هل الكلمة المكتوبة موجودة في القاموس؟ وهل انزلقت الأصابع، أم أن الكاتب لا يعرف التهجئة الصحيحة؟

Example1 / 8
Score0 / 0

Quick checkاختبار سريع

A student writes 'a peace of cake' when they meant 'a piece of cake'. What kind of error is it?كتب طالب 'a peace of cake' وهو يقصد 'a piece of cake'. ما نوع هذا الخطأ؟

Quick checkاختبار سريع

Which kind of error can dictionary lookup never detect, however large the dictionary is?أي نوع من الأخطاء لا يستطيع البحث في القاموس كشفه أبدا، مهما كان القاموس كبيرا؟

How common are spelling errors? The lecture lists five numbers from 1% to 26%. They are not contradictory measurements of one quantity. Each one describes a different way of typing.

ما مدى شيوع الأخطاء الإملائية؟ تسرد المحاضرة خمسة أرقام من 1% إلى 26%. وهي ليست قياسات متناقضة لكمية واحدة، بل كل رقم منها يصف طريقة مختلفة في الكتابة.

Published error rates, ordered by input condition; the spread is about the setting, not the typistمعدلات الأخطاء المنشورة مرتبة حسب ظروف الإدخال؛ والتفاوت سببه الظروف، لا الشخص الذي يكتب
  • 26% of web queries contain an error (Wang et al., 2003). Queries are typed fast, with no review, and full of names and rare terms.26% من استعلامات البحث على الويب تحتوي على خطأ (Wang et al., 2003). فالاستعلامات تُكتب بسرعة، دون مراجعة، وهي مليئة بالأسماء والمصطلحات النادرة.
  • 13% when people retype text without using backspace (Whitelaw et al., 2009). The paper measured 10.8% misspelled tokens for 25 English typists and 12.5% for German, typing at a normal pace and avoiding backspace and delete.13% حين يعيد الناس كتابة نص دون استخدام زر المسح backspace (Whitelaw et al., 2009). قاست الورقة 10.8% من الكلمات المكتوبة خطأ لدى 25 كاتبا بالإنجليزية، و12.5% بالألمانية، وهم يكتبون بسرعة عادية ويتجنبون زرَّي backspace وdelete.
  • 7% errors made and then corrected, and 2% left uncorrected, when retyping on a phone-sized organizer (Soukoreff and MacKenzie, 2003).7% أخطاء ارتُكبت ثم صُحّحت، و2% بقيت دون تصحيح، عند إعادة الكتابة على منظِّم شخصي بحجم الهاتف (Soukoreff and MacKenzie, 2003).
  • 1% to 2% for careful retyping of printed text on a normal keyboard (Kane and Wobbrock, 2007; Grudin, 1983).من 1% إلى 2% عند إعادة كتابة نص مطبوع بعناية على لوحة مفاتيح عادية (Kane and Wobbrock, 2007؛ Grudin, 1983).

Read the list as a set of input conditions: device size, speed, whether errors may be fixed, and when they are counted. Take away backspace and the rate rises because nothing gets fixed. Shrink the keyboard and fingers land on neighbouring keys. Count errors before the user fixes them, and you see the 7%; count after, and only the 2% that survived. The same person can produce all of these numbers in one afternoon.

اقرأ القائمة على أنها مجموعة من ظروف الإدخال: حجم الجهاز، والسرعة، وهل يُسمح بإصلاح الأخطاء، ومتى تُحسب. انزع زر المسح فيرتفع المعدل لأن شيئا لا يُصلَح. صغّر لوحة المفاتيح فتقع الأصابع على المفاتيح المجاورة. احسب الأخطاء قبل أن يصلحها المستخدم فترى 7%؛ واحسبها بعد ذلك فلا ترى إلا 2% التي نجت من الإصلاح. والشخص نفسه يمكن أن ينتج كل هذه الأرقام في عصر يوم واحد.

Worked exampleمثال محلول

Why per-query and per-word rates look so differentلماذا يبدو المعدل لكل استعلام مختلفا جدا عن المعدل لكل كلمة

  1. Assume a per-word rateافترض معدلا لكل كلمة

    Suppose each word in a query is misspelled independently with probability p = 0.10.

    لنفترض أن كل كلمة في الاستعلام تُكتب خطأ باستقلال عن غيرها باحتمال p = 0.10.

  2. Compute the chance a 3-word query is cleanاحسب احتمال أن يكون استعلام من 3 كلمات خاليا من الأخطاء

    (1−p)3=0.93=0.729(1-p)^3 = 0.9^3 = 0.729

    (1−p)3=0.93=0.729(1-p)^3 = 0.9^3 = 0.729

  3. Take the complementخذ الاحتمال المكمّل

    1−0.729=0.2711 - 0.729 = 0.271, so about 27% of queries contain at least one error.

    1−0.729=0.2711 - 0.729 = 0.271، إذن نحو 27% من الاستعلامات تحتوي على خطأ واحد على الأقل.

  4. Resultالنتيجة

    A per-word rate near 10% and a per-query rate near 26% are compatible. Always check the unit of a rate (character, word, query) before comparing it with another. This is an illustration of the arithmetic, not a claim about how Wang et al. counted.
    معدل لكل كلمة قريب من 10% ومعدل لكل استعلام قريب من 26% متوافقان. تحقّق دائما من وحدة المعدل (حرف، كلمة، استعلام) قبل مقارنته بمعدل آخر. وهذا توضيح للحساب، وليس ادعاء عن الطريقة التي عدّ بها Wang et al. الأخطاء.

Recall

Why is it wrong to say that 26% and 1 to 2% contradict each other?لماذا من الخطأ القول إن 26% و1 إلى 2% يتناقضان؟

They measure different input conditions (hurried web queries against careful retyping of printed text) and often different units (whole queries against words or characters). The spread is explained by the setting and the counting, not by different kinds of people.

لأنهما يقيسان ظروف إدخال مختلفة (استعلامات ويب مكتوبة على عجل مقابل إعادة كتابة نص مطبوع بعناية)، وكثيرا ما يقيسان بوحدات مختلفة (استعلامات كاملة مقابل كلمات أو حروف). والتفاوت تفسّره الظروف وطريقة العدّ، لا اختلاف أنواع الناس.

Back to graffe. A dictionary says it is not a word, so it is an error. Now what should replace it: giraffe, gaffe, graf, grail, craft?

لنعد إلى graffe. القاموس يقول إنها ليست كلمة، إذن هي خطأ. والآن، ما الذي يجب أن يحل محلها: giraffe أم gaffe أم graf أم grail أم craft؟

Detection: anything not in the dictionaryالكشف: كل ما ليس في القاموس

For non-word errors, detection is a lookup. Any token not in the dictionary is flagged. The slide adds that the larger the dictionary the better, and modern systems indeed use huge word lists harvested from the web, so that names, product names and new words are not flagged as errors.

في أخطاء الكلمات غير الموجودة، الكشف مجرد بحث في القاموس: تُعلَّم أي كلمة غير موجودة فيه. وتضيف الشريحة أنه كلما كبر القاموس كان أفضل، والأنظمة الحديثة تستخدم فعلا قوائم كلمات ضخمة مجموعة من الويب، حتى لا تُعلَّم الأسماء وأسماء المنتجات والكلمات الجديدة على أنها أخطاء.

Correction: generate, then chooseالتصحيح: ولّد ثم اختر

Correction has two steps. Candidate generation produces the real words that are similar to the error, usually all dictionary words within one or two edits. Then the system ranks them and picks the best, in one of two ways:

للتصحيح خطوتان. Candidate generation (توليد المرشحين) ينتج الكلمات الحقيقية المشابهة للخطأ، وعادة تكون كل كلمات القاموس التي تبعد تعديلا واحدا أو تعديلين. ثم يرتّبها النظام ويختار أفضلها بإحدى طريقتين:

  • Shortest weighted edit distance. Use Edit distance from the previous lecture, but weight each edit by how plausible it is: swapping two adjacent letters, or hitting a neighbouring key, should cost less than an arbitrary substitution. giraffe is one insertion from graffe; grail needs two substitutions and a deletion.أقصر مسافة تحرير موزونة. استخدم Edit distance (مسافة التحرير) من المحاضرة السابقة، لكن زِن كل تعديل بحسب معقوليته: تبديل حرفين متجاورين، أو ضغط مفتاح مجاور، يجب أن يكلّف أقل من استبدال عشوائي. giraffe تبعد إدراجا واحدا عن graffe؛ أما grail فتحتاج إلى استبدالين وحذف واحد.
  • Highest noisy channel probability. Score each candidate by how likely that word is to have been typed as graffe, times how common the word is. This is the Noisy channel model, the subject of the next part.أعلى احتمال في القناة المشوشة. قيّم كل مرشح بمدى احتمال أن تكون تلك الكلمة قد كُتبت على شكل graffe، مضروبا في مدى شيوع الكلمة. وهذا هو Noisy channel model (نموذج القناة المشوشة)، موضوع الجزء التالي.
w^=argmax⁡w∈C(x)  P(x∣w) P(w)\hat{w} = \underset{w \in C(x)}{\operatorname{argmax}}\; P(x \mid w)\, P(w)
Preview: pick the candidate w that best explains the typed string xلمحة: اختر المرشح w الذي يفسر السلسلة المكتوبة x على أفضل وجه

The noisy channel is the stronger choice because it also uses frequency: gaffe and giraffe are both one edit from graffe, and only probabilities can say which one people actually mean more often.

القناة المشوشة هي الخيار الأقوى لأنها تستخدم التكرار أيضا: gaffe وgiraffe كلتاهما تبعد تعديلا واحدا عن graffe، والاحتمالات وحدها هي التي تستطيع أن تقول أيّهما يقصدها الناس فعلا أكثر.

Recall

State the non-word pipeline in two lines.اذكر مسار أخطاء الكلمات غير الموجودة في سطرين.

Detection: flag any token not in the dictionary. Correction: generate dictionary words similar to the error, then choose the one with the smallest weighted edit distance or the highest noisy channel probability.

الكشف: علّم أي كلمة غير موجودة في القاموس. التصحيح: ولّد كلمات من القاموس مشابهة للخطأ، ثم اختر صاحبة أصغر مسافة تحرير موزونة أو أعلى احتمال في القناة المشوشة.

Now take I bought there tickets. Nothing is flagged, because every word is in the dictionary. Which word should the system even look at?

خذ الآن I bought there tickets. لا شيء يُعلَّم، لأن كل كلمة موجودة في القاموس. فأي كلمة يجب أن ينظر إليها النظام أصلا؟

All of them. Since a Real-word error cannot be detected by lookup, real-word correction folds detection and correction into one step and runs it on every word w in the sentence. For each word it builds a Candidate set from three sources:

كلها. فبما أن Real-word error (خطأ الكلمة الحقيقية) لا يمكن كشفه بالبحث في القاموس، فإن تصحيح الكلمات الحقيقية يدمج الكشف والتصحيح في خطوة واحدة ويطبّقها على كل كلمة w في الجملة. ولكل كلمة يبني Candidate set (مجموعة المرشحين) من ثلاثة مصادر:

  1. Words with similar pronunciation, which catches cognitive errors: peace for piece, two and to for too.كلمات متشابهة في النطق، وهي تلتقط الأخطاء المعرفية: peace بدلا من piece، وtwo وto بدلا من too.
  2. Words with similar spelling, which catches typographical errors: three and where for there.كلمات متشابهة في التهجئة، وهي تلتقط الأخطاء الطباعية: three وwhere بدلا من there.
  3. The word w itself.الكلمة w نفسها.

Then it chooses the best candidate in context, either with the Noisy channel model (now with a language model that looks at the neighbouring words) or with a Confusion-set classifier trained for one confusable pair such as there and three.

ثم يختار أفضل مرشح في ضوء السياق، إما باستخدام Noisy channel model (وهذه المرة مع نموذج لغوي ينظر إلى الكلمات المجاورة)، وإما باستخدام Confusion-set classifier (مصنِّف مجموعة الالتباس) مدرَّب على زوج واحد من الكلمات التي يُخلط بينها مثل there وthree.

Why the typed word must stay in the raceلماذا يجب أن تبقى الكلمة المكتوبة في السباق

The third source is the important one. Almost every word in normal text is correct. If the candidate set for there held only three, where and their, the system would be forced to change a word in every position of every sentence. Keeping w lets it answer the detection question: if w wins, there was no error. In over there, there wins; in bought there tickets, three should win. Later the lecture gives the typed word its own probability, P(w|w), the Probability of no error.

المصدر الثالث هو الأهم. فكل كلمة تقريبا في النص العادي صحيحة. لو احتوت مجموعة المرشحين لـthere على three وwhere وtheir فقط، لاضطر النظام إلى تغيير كلمة في كل موضع من كل جملة. إبقاء w يسمح له بالإجابة عن سؤال الكشف: إذا فازت w فلم يكن هناك خطأ. في over there تفوز there؛ وفي bought there tickets يجب أن تفوز three. ولاحقا تعطي المحاضرة الكلمة المكتوبة احتمالها الخاص P(w|w)، وهو Probability of no error (احتمال عدم وجود خطأ).

Recall

Name the three sources of the real-word candidate set and the error type each one targets.سمِّ المصادر الثلاثة لمجموعة المرشحين في أخطاء الكلمات الحقيقية، ونوع الخطأ الذي يستهدفه كل منها.

Similar pronunciation targets cognitive (homophone) errors. Similar spelling targets typographical errors. The word itself covers the most common case: no error at all.

التشابه في النطق يستهدف الأخطاء المعرفية (الكلمات المتجانسة صوتيا). والتشابه في التهجئة يستهدف الأخطاء الطباعية. والكلمة نفسها تغطي الحالة الأكثر شيوعا: عدم وجود خطأ على الإطلاق.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • Spelling work has two tasks: detection (is this token wrong?) and correction (what was meant?). Correction is delivered as autocorrect, one suggestion or a suggestion list, depending on confidence.لعمل الإملاء مهمتان: الكشف (هل هذه الكلمة خاطئة؟) والتصحيح (ماذا كان المقصود؟). ويُقدَّم التصحيح بثلاث صور حسب درجة الثقة: تصحيح تلقائي، أو اقتراح واحد، أو قائمة اقتراحات.
  • A non-word error lands outside the dictionary (graffe for giraffe), so lookup detects it.خطأ الكلمة غير الموجودة يقع خارج القاموس (graffe بدلا من giraffe)، لذلك يكشفه البحث في القاموس.
  • A real-word error lands on another valid word, so lookup is blind to it. Typographical: a finger slip (there for three). Cognitive: the writer picks the wrong spelling of a sound (piece for peace, too for two).خطأ الكلمة الحقيقية يقع على كلمة صحيحة أخرى، لذلك لا يراه البحث في القاموس. الطباعي: زلة أصابع (there بدلا من three). المعرفي: يختار الكاتب تهجئة خاطئة لصوت ما (piece بدلا من peace، وtoo بدلا من two).
  • Error rates run from 1 to 2% for careful retyping to 26% for web queries. The spread comes from the input condition (device, speed, whether backspace is allowed, whether errors are counted before or after fixing), not from the typist.تتراوح معدلات الأخطاء من 1 إلى 2% عند إعادة الكتابة بعناية حتى 26% في استعلامات الويب. وهذا التفاوت سببه ظروف الإدخال (الجهاز، والسرعة، والسماح بزر المسح backspace أو منعه، وهل تُحسب الأخطاء قبل إصلاحها أم بعده)، لا الشخص الذي يكتب.
  • Non-word pipeline: flag tokens not in the dictionary, generate similar real words, pick by smallest weighted edit distance or highest noisy channel probability.مسار الكلمات غير الموجودة: علّم الكلمات غير الموجودة في القاموس، ثم ولّد كلمات حقيقية مشابهة، ثم اختر صاحبة أصغر مسافة تحرير موزونة (weighted edit distance) أو أعلى احتمال في نموذج القناة المشوشة (noisy channel).
  • Real-word pipeline: for every word w, gather candidates by similar spelling and similar pronunciation, add w itself, pick by noisy channel or a classifier. Keeping w lets the system decide the word was right.مسار الكلمات الحقيقية: لكل كلمة w اجمع مرشحين متشابهين في التهجئة ومتشابهين في النطق، وأضف w نفسها، ثم اختر بنموذج القناة المشوشة أو بمصنِّف (classifier). إبقاء w يسمح للنظام بأن يقرر أن الكلمة كانت صحيحة.

Sourcesالمصادر

Part 02: The noisy channel modelنموذج القناة المشوشة (Noisy channel)

Treat the misspelling as a correct word sent through a noisy channel, then decode with Bayes' rule: pick the word that maximizes channel probability times prior.نعامل الخطأ الإملائي على أنه كلمة صحيحة أُرسلت عبر قناة مشوشة، ثم نفك الترميز بقاعدة Bayes: نختار الكلمة التي تعظّم احتمال القناة مضروبا في الاحتمال المسبق (prior).

3 concepts3 مفاهيم, ، slides 9-12الشرائح 9-12

Why this part mattersلماذا يهمّ هذا الجزء

Part 01 split spelling errors into non-words and real words. This part gives you the single idea that powers almost every correction method in the rest of the lecture: treat the misspelling as a damaged copy of the word the writer meant, and ask which intended word most probably produced that damage.

The ideas build in order. First the picture: a word goes into a noisy channel and comes out wrong, and a decoder works backwards. Second the mathematics: one line of Bayes' rule, one cancellation, and the formula you must be able to derive in an exam. Third the context: who proposed it, and why the very same equation appears in speech recognition and machine translation. Every later part of this lecture (candidate generation, the confusion matrices, the acress scores, real-word errors) is just a way of filling in one factor of this formula.

قسّم الجزء 01 الأخطاء الإملائية إلى أخطاء ينتج عنها ما ليس بكلمة (non-words) وأخطاء ينتج عنها كلمات حقيقية (real words). أما هذا الجزء فيعطيك الفكرة الواحدة التي تقوم عليها تقريبًا كل طرق التصحيح في بقية المحاضرة: تعامل مع الخطأ الإملائي على أنه نسخة تالفة من الكلمة التي قصدها الكاتب، ثم اسأل: أي كلمة مقصودة هي الأرجح أن تكون قد أنتجت هذا التلف؟

تُبنى الأفكار بالترتيب. أولًا الصورة: كلمة تدخل قناة مشوّشة (noisy channel) وتخرج خاطئة، وفاكّ ترميز (decoder) يعمل بالاتجاه المعاكس. ثانيًا الرياضيات: سطر واحد من قاعدة بايز (Bayes' rule)، وحذف واحد، والصيغة التي يجب أن تستطيع اشتقاقها في الاختبار. ثالثًا السياق: من اقترحها، ولماذا تظهر المعادلة نفسها تمامًا في التعرف على الكلام والترجمة الآلية. وكل جزء لاحق في هذه المحاضرة (توليد المرشحين، ومصفوفات الالتباس، ودرجات acress، وأخطاء الكلمات الحقيقية) ما هو إلا طريقة لملء أحد عاملَي هذه الصيغة.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Describe spelling correction as decoding: a correct word w passes through a noisy channel and comes out as the observed string x.أن تصف تصحيح الإملاء بأنه عملية فك ترميز (decoding): كلمة صحيحة w تمر عبر قناة مشوّشة (noisy channel) فتخرج على شكل النص المُلاحَظ x.
  2. Derive the noisy channel rule line by line, from argmax P(w|x) through Bayes' rule to argmax P(x|w) P(w).أن تشتق قاعدة القناة المشوّشة سطرًا بسطر، من argmax P(w|x) مرورًا بقاعدة بايز (Bayes' rule) وصولًا إلى argmax P(x|w) P(w).
  3. Explain exactly why P(x) can be dropped, and why the answer does not change when it is.أن تشرح بدقة لماذا يمكن حذف P(x)، ولماذا لا تتغير الإجابة عند حذفه.
  4. Name the two factors (channel or error model, and language model prior) and say what data each one is learned from.أن تسمّي العاملين (نموذج القناة أو نموذج الخطأ، والاحتمال المسبق من نموذج اللغة) وتذكر من أي بيانات يُتعلَّم كل منهما.
  5. Place the model in history (Kernighan, Church and Gale 1990; Mays, Damerau and Mercer 1991) and recognise it in speech recognition and machine translation.أن تضع النموذج في سياقه التاريخي (Kernighan وChurch وGale سنة 1990؛ Mays وDamerau وMercer سنة 1991) وأن تتعرّف عليه في التعرف على الكلام والترجمة الآلية.

Someone types acress. You know at once that this is not an English word. But what did they mean? Maybe actress with the t dropped, maybe across with an e in place of the o, maybe acres with an extra s. You cannot see inside the writer's head. All you have is the damaged string and your knowledge of how people type and what people usually write.

يكتب شخص ما acress. تعرف فورًا أنها ليست كلمة إنجليزية. لكن ماذا قصد؟ ربما actress وقد سقط منها حرف t، وربما across مع e مكان o، وربما acres مع s زائدة. لا يمكنك أن ترى ما في رأس الكاتب. كل ما لديك هو النص التالف، ومعرفتك بكيف يكتب الناس وبما يكتبونه عادةً.

The channel distorts, the decoder reasons backwardsالقناة تشوّه، وفاكّ الترميز يستنتج بالاتجاه المعاكس

The noisy channel model turns that intuition into a model. Imagine the writer's intended word as a clean message. On its way to the page it passes through a channel: tired fingers, a cramped keyboard, a shaky memory of the spelling. The channel adds noise in the form of substituted, inserted, deleted or swapped letters. What arrives is the observed string, which we call xx. The word that was sent we call ww.

يحوّل noisy channel model (نموذج القناة المشوّشة) هذا الحدس إلى نموذج. تخيّل الكلمة التي قصدها الكاتب رسالةً نظيفة. في طريقها إلى الورق تمر عبر قناة: أصابع متعبة، ولوحة مفاتيح ضيقة، وذاكرة مهزوزة للتهجئة. تضيف القناة تشويشًا على شكل حروف مستبدلة أو مُدرجة أو محذوفة أو متبادلة المواقع. وما يصل هو النص المُلاحَظ، ونسمّيه xx. أما الكلمة التي أُرسلت فنسمّيها ww.

Correction runs the picture in reverse. The decoder takes each hypothesis word from the vocabulary, imagines sending it through a model of the same channel, and asks how likely that word is to come out looking like acress. It also asks how likely the word was to be written in the first place. The hypothesis that best explains the noise, weighed by how common it is, becomes the guess. So there are two directions: the channel runs forward from intention to typing, and the decoder runs backward from the typed string to the intention, pushing every hypothesis through its own copy of the channel to see which noisy output matches.

التصحيح يشغّل الصورة بالعكس. يأخذ decoder (فاكّ الترميز) كل كلمة فرضية من المفردات، ويتخيّل إرسالها عبر نموذج للقناة نفسها، ويسأل: ما مدى احتمال أن تخرج هذه الكلمة على شكل acress؟ ويسأل أيضًا: ما مدى احتمال أن تُكتب هذه الكلمة أصلًا؟ والفرضية التي تفسّر التشويش أفضل تفسير، موزونةً بمدى شيوعها، تصبح هي التخمين. إذن هناك اتجاهان: القناة تسير إلى الأمام من النية إلى الكتابة، وفاكّ الترميز يسير إلى الخلف من النص المكتوب إلى النية، فيدفع كل فرضية عبر نسخته الخاصة من القناة ليرى أي مخرج مشوّش يطابق ما رأيناه.

Original word wالكلمة الأصلية w
actress

What the writer meant. Hidden from us.

ما قصده الكاتب، وهو مخفي عنا.

sentتُرسَل
Noisy channelالقناة المشوِّشة
typing, memory, keyboardالكتابة، الذاكرة، لوحة المفاتيح

Adds noise: a letter is dropped, added, replaced or swapped.

تضيف تشويشًا: يُحذف حرف أو يُضاف أو يُستبدل أو يُبدَّل موضعه مع جاره.

observedتُرصَد
Observed xالمرصود x
acress

The only thing the corrector actually sees.

الشيء الوحيد الذي يراه المصحِّح فعلًا.

decodeفكّ الترميز
Guessed word ŵالكلمة المخمَّنة ŵ
argmax over V

The decoder tries each w in V, scores P(x|w) P(w), and keeps the best: our estimate of the hidden word.

يجرّب فاكّ الترميز كل w في V، ويحسب P(x|w) P(w)، ويحتفظ بالأفضل: وهو تقديرنا للكلمة المخفية.

Forward the channel corrupts the word; backward the decoder tries every candidate and keeps the best explanationإلى الأمام تُفسد القناة الكلمة، وإلى الخلف يجرّب فاكّ الترميز كل مرشح ويحتفظ بأفضل تفسير

Notice what the decoder needs. It needs a list of hypotheses to try, which in practice is not the whole vocabulary but a short list of nearby words (that is candidate generation, part 03). It needs a model of the channel, so it can say how likely each hypothesis is to turn into xx. And it needs a sense of which words people actually use. The next concept shows that these last two needs are exactly the two factors that fall out of Bayes' rule.

لاحظ ما يحتاجه فاكّ الترميز. يحتاج قائمة فرضيات يجرّبها، وهي في الواقع ليست المفردات كلها بل قائمة قصيرة من الكلمات القريبة (وهذا هو candidate generation، أي توليد المرشحين، في الجزء 03). ويحتاج نموذجًا للقناة، ليقول ما مدى احتمال أن تتحول كل فرضية إلى xx. ويحتاج إحساسًا بالكلمات التي يستخدمها الناس فعلًا. والمفهوم التالي يبيّن أن هاتين الحاجتين الأخيرتين هما بالضبط العاملان اللذان يخرجان من قاعدة بايز.

Forward through the channel, then back: each hypothesis is pushed through a model of the channel and scored, and the best score becomes ŵإلى الأمام عبر القناة ثم العودة: تُدفع كل فرضية عبر نموذج للقناة وتُعطى درجة، وأفضل درجة تصبح ŵ

Recall

In the noisy channel picture, what is hidden, what is observed, and what does the decoder do?في صورة القناة المشوّشة، ما الخفي، وما المُلاحَظ، وماذا يفعل فاكّ الترميز؟

The intended word w is hidden; the typed string x is observed. The decoder takes each candidate w, runs it through a model of the channel to see how likely it is to produce x, weighs that by how likely w is to be written at all, and returns the best one as ŵ.
الكلمة المقصودة w خفية، والنص المكتوب x مُلاحَظ. يأخذ فاكّ الترميز كل مرشح w، ويمرّره عبر نموذج للقناة ليرى ما مدى احتمال أن ينتج x، ثم يزن ذلك بمدى احتمال أن تُكتب w أصلًا، ويعيد أفضلها على أنه ŵ.

Return to acress. If you could read off, for each candidate word, the probability that it was the intended word given that we saw acress, you would just pick the biggest. That probability is P(w∣x)P(w \mid x), and the whole derivation on slide 11 is about turning it into things we can actually estimate.

عُد إلى acress. لو استطعت أن تقرأ لكل كلمة مرشحة احتمال أن تكون هي الكلمة المقصودة بشرط أننا رأينا acress، لاخترت الأكبر ببساطة. هذا الاحتمال هو P(w∣x)P(w \mid x)، والاشتقاق كله في الشريحة 11 يدور حول تحويله إلى أشياء نستطيع تقديرها فعلًا.

Step 1: state the goalالخطوة 1: حدّد الهدف

Out of every word ww in the vocabulary VV, pick the one with the highest probability given the observation xx. The hat on w^\hat{w} means “our estimate of the correct word”, and argmax means “the argument that makes this largest”, so it returns a word, not a probability.

من بين كل الكلمات ww في المفردات VV، اختر الكلمة ذات الاحتمال الأعلى بشرط الملاحظة xx. القبعة فوق w^\hat{w} تعني «تقديرنا للكلمة الصحيحة»، وargmax تعني «القيمة (المُدخَل) التي تجعل هذا المقدار أكبر ما يمكن»، لذلك فهي تعيد كلمة لا احتمالًا.

w^=argmax⁡w∈VP(w∣x)\hat{w} = \operatorname{argmax}_{w \in V} P(w \mid x)
The goal: the most probable intended word given what was typedالهدف: الكلمة المقصودة الأكثر احتمالًا بمعلومية ما كُتب

Step 2: apply Bayes' ruleالخطوة 2: طبّق قاعدة بايز

Bayes' rule rewrites any conditional probability by flipping it: P(a∣b)=P(b∣a) P(a)/P(b)P(a \mid b) = P(b \mid a)\,P(a) / P(b). With a=wa = w and b=xb = x, the posterior we cannot estimate directly becomes a product of two things we can, divided by a third.

تعيد Bayes' rule (قاعدة بايز) كتابة أي احتمال شرطي بقلبه: P(a∣b)=P(b∣a) P(a)/P(b)P(a \mid b) = P(b \mid a)\,P(a) / P(b). ومع a=wa = w وb=xb = x، يصبح الاحتمال اللاحق (posterior) الذي لا نستطيع تقديره مباشرةً حاصلَ ضرب شيئين نستطيع تقديرهما، مقسومًا على شيء ثالث.

w^=argmax⁡w∈VP(w∣x)=argmax⁡w∈VP(x∣w) P(w)P(x)=argmax⁡w∈VP(x∣w) P(w)\hat{w} = \operatorname{argmax}_{w \in V} P(w \mid x) = \operatorname{argmax}_{w \in V} \frac{P(x \mid w)\,P(w)}{P(x)} = \operatorname{argmax}_{w \in V} P(x \mid w)\,P(w)
The noisy channel rule, exactly as derived on slide 11قاعدة القناة المشوشة، تمامًا كما اشتُقت في الشريحة 11

Step 3: drop P(x), and know whyالخطوة 3: احذف P(x)، واعرف السبب

The denominator P(x)P(x) is the probability of the observed string itself. When we compare candidates, we compare them for the same xx: we are always asking which word best explains acress, never a different string. So P(x)P(x) is one fixed positive number, shared by every candidate. Dividing every score by the same positive number shrinks or stretches all of them equally; it cannot change which one is largest. The argmax is unchanged, so we drop the denominator.

المقام P(x)P(x) هو احتمال النص المُلاحَظ نفسه. عندما نقارن المرشحين، نقارنهم على xx نفسه: نحن نسأل دائمًا أي كلمة تفسّر acress أفضل تفسير، ولا نسأل أبدًا عن نص آخر. إذن P(x)P(x) عدد موجب ثابت واحد يشترك فيه كل المرشحين. وقسمة كل الدرجات على العدد الموجب نفسه تصغّرها أو تكبّرها جميعًا بالنسبة نفسها، ولا يمكن أن تغيّر أيّها الأكبر. قيمة argmax لا تتغير، لذلك نحذف المقام.

There is a practical bonus. Computing P(x)P(x) properly would mean summing P(x∣w) P(w)P(x \mid w)\,P(w) over every possible ww. Dropping it saves that whole sum. The price is that the remaining scores are no longer probabilities that add to one; they are only useful for ranking. That is all the corrector needs.

وهناك فائدة عملية إضافية. حساب P(x)P(x) بشكل صحيح يعني جمع P(x∣w) P(w)P(x \mid w)\,P(w) على كل ww ممكنة. وحذفه يوفّر هذا المجموع كله. والثمن أن الدرجات المتبقية لم تعد احتمالات مجموعها واحد؛ فهي مفيدة للترتيب فقط. وهذا كل ما يحتاجه المصحّح.

Dividing every candidate's score by the same P(x) rescales the bars but leaves the tallest bar, and the whole order, unchangedقسمة درجة كل مرشح على P(x) نفسه تغيّر مقياس الأعمدة، لكنها تُبقي العمود الأطول، والترتيب كله، دون تغيير

Worked exampleمثال محلول

Check the cancellation with real numbers for acressتحقّق من الحذف بأرقام حقيقية لـ acress

  1. Take three candidates and their scoresخذ ثلاثة مرشحين ودرجاتهم

    Jurafsky and Martin (Appendix D, Fig. D.5) give, for acress with a unigram prior: actress has P(x∣w)=0.000117P(x \mid w) = 0.000117 and P(w)=0.0000231P(w) = 0.0000231, so the product is 2.7 × 10⁻⁹. across has 0.0000093 × 0.000299 ≈ 2.8 × 10⁻⁹. access has 0.000000209 × 0.0000916 ≈ 0.019 × 10⁻⁹.
    يعطي Jurafsky وMartin (الملحق D، الشكل D.5) القيم التالية لـ acress مع احتمال مسبق أحادي (unigram prior): actress لها P(x∣w)=0.000117P(x \mid w) = 0.000117 وP(w)=0.0000231P(w) = 0.0000231، فحاصل الضرب 2.7 × 10⁻⁹. وacross لها 0.0000093 × 0.000299 ≈ 2.8 × 10⁻⁹. وaccess لها 0.000000209 × 0.0000916 ≈ 0.019 × 10⁻⁹.
  2. Rank by the product aloneرتّب بحاصل الضرب وحده

    2.8 > 2.7 > 0.019, so the ranking is across, then actress, then access.
    2.8 > 2.7 > 0.019، إذن الترتيب: across أولًا، ثم actress، ثم access.
  3. Now divide by P(x)الآن اقسم على P(x)

    Restrict attention to these three words for illustration, so P(x) ≈ 2.7 + 2.8 + 0.019 = 5.519 × 10⁻⁹. The posteriors become 2.7 / 5.519 ≈ 0.489, 2.8 / 5.519 ≈ 0.507 and 0.019 / 5.519 ≈ 0.003.
    اقصر الانتباه على هذه الكلمات الثلاث للتوضيح، فيكون P(x) ≈ 2.7 + 2.8 + 0.019 = 5.519 × 10⁻⁹. وتصبح الاحتمالات اللاحقة 2.7 / 5.519 ≈ 0.489 و2.8 / 5.519 ≈ 0.507 و0.019 / 5.519 ≈ 0.003.
  4. Resultالنتيجة

    The posteriors sum to one and are easier to read, but the order is identical: across still wins. Dividing by P(x)P(x) changed every number and no ranking. (That across beats the intended actress here is a weakness of the unigram prior, not of the rule; part 05 fixes it with context.)
    مجموع الاحتمالات اللاحقة واحد، وهي أسهل في القراءة، لكن الترتيب مطابق تمامًا: across ما زالت تفوز. القسمة على P(x)P(x) غيّرت كل الأرقام ولم تغيّر أي ترتيب. (وفوز across هنا على الكلمة المقصودة actress نقطة ضعف في الاحتمال المسبق الأحادي unigram، لا في القاعدة؛ والجزء 05 يصلح ذلك بالسياق.)

Name the two factorsسمِّ العاملين

What survives is a product of two very different pieces of knowledge. Learn the names; exams use all of them interchangeably.

ما يتبقى هو حاصل ضرب نوعين مختلفين جدًا من المعرفة. احفظ الأسماء؛ فالاختبارات تستخدمها كلها بالتبادل.

FactorالعاملNamesالأسماءWhat it knowsما الذي يعرفهLearned fromيُتعلَّم من
P(x | w)P(x | w)Channel model, also called the error model or likelihoodنموذج القناة، ويسمّى أيضًا نموذج الخطأ (error model) أو الاحتمال الشرطي (likelihood)How the writer turns an intended word into typed letters: slips, swapped keys, dropped lettersكيف يحوّل الكاتب الكلمة المقصودة إلى حروف مكتوبة: الزلّات، والمفاتيح المتبادلة، والحروف الساقطةError corpora, such as lists of misspellings paired with their correctionsمدوّنات الأخطاء (error corpora)، مثل قوائم الأخطاء الإملائية مقرونةً بتصحيحاتها
P(w)P(w)Language model, the priorنموذج اللغة، أي الاحتمال المسبق (prior)How often the word, or the word in this context, appears in the languageمدى تكرار الكلمة في اللغة، أو مدى تكرارها في هذا السياقPlain text, for example unigram or bigram counts from a large corpusالنص العادي، مثل أعداد unigram أو bigram من مدوّنة نصية كبيرة
The two factors of the noisy channel ruleعاملا قاعدة القناة المشوّشة

P(x∣w)P(x \mid w) is the channel model, also called the error model, and in Bayesian language the likelihood. It is about typing: how likely is a writer who meant actress to produce acress? Part 04 estimates it from a confusion matrix of real typing mistakes. P(w)P(w) is the prior probability, supplied by a language model. It is about the language: how common is actress as a word, or after the word that precedes it? This is exactly the n-gram machinery of lecture 03; a unigram prior uses single-word counts, a bigram language model brings in the previous word.

الحد P(x∣w)P(x \mid w) هو channel model (نموذج القناة)، ويسمّى أيضًا نموذج الخطأ (error model)، وفي لغة بايز هو الاحتمال الشرطي (likelihood). موضوعه الكتابة: ما مدى احتمال أن يكتب شخص قصد actress النص acress؟ والجزء 04 يقدّره من confusion matrix (مصفوفة الالتباس) لأخطاء كتابة حقيقية. أما P(w)P(w) فهو prior probability (الاحتمال المسبق)، ويوفّره نموذج لغة. موضوعه اللغة: ما مدى شيوع actress كلمةً، أو بعد الكلمة التي تسبقها؟ وهذه بالضبط آلية n-gram من المحاضرة 03؛ فـ unigram prior يستخدم أعداد الكلمات المفردة، وbigram language model يُدخل الكلمة السابقة في الحساب.

Two independent sources of evidence: a model of typing slips supplies P(x|w), a model of written text supplies P(w), and the score is their productمصدران مستقلان للدليل: نموذج لزلّات الكتابة يوفّر P(x|w)، ونموذج للنص المكتوب يوفّر P(w)، والدرجة هي حاصل ضربهما

Recall

Which factor knows about typing, and which knows about the language?أي العاملين يعرف عن الكتابة على لوحة المفاتيح، وأيهما يعرف عن اللغة؟

P(x|w), the channel or error model, knows about typing: which letters get dropped, added, swapped or replaced. P(w), the language model prior, knows about the language: how frequent the word is, or how well it fits its context.
P(x|w)، أي نموذج القناة أو نموذج الخطأ، يعرف عن الكتابة: أي الحروف تُحذف أو تُضاف أو تتبادل مواقعها أو تُستبدل. وP(w)، أي الاحتمال المسبق من نموذج اللغة، يعرف عن اللغة: ما مدى تكرار الكلمة، أو ما مدى ملاءمتها لسياقها.

Recall

Without looking, derive ŵ from argmax P(w|x) and justify each step.دون أن تنظر، اشتقّ ŵ من argmax P(w|x) وبرّر كل خطوة.

ŵ = argmax over w in V of P(w|x). By Bayes' rule this is argmax P(x|w) P(w) / P(x). The observation x is the same for every candidate, so P(x) is a shared positive constant; dividing all scores by it cannot change the winner. Therefore ŵ = argmax P(x|w) P(w).
ŵ = argmax over w in V of P(w|x). وبقاعدة بايز يساوي هذا argmax P(x|w) P(w) / P(x). الملاحظة x هي نفسها لكل مرشح، إذن P(x) ثابت موجب مشترك؛ وقسمة كل الدرجات عليه لا يمكن أن تغيّر الفائز. لذلك ŵ = argmax P(x|w) P(w).

Quick checkاختبار سريع

Why can P(x) be dropped when choosing the best correction for a typo?لماذا يمكن حذف P(x) عند اختيار أفضل تصحيح لخطأ إملائي؟

Quick checkاختبار سريع

A phone keyboard replaces a laptop keyboard. Which term of ŵ = argmax P(x|w)P(w) must be re-estimated?استُبدلت لوحة مفاتيح الحاسوب المحمول بلوحة مفاتيح هاتف. أي حد في ŵ = argmax P(x|w)P(w) يجب إعادة تقديره؟

The noisy channel did not start with spelling. Shannon modelled communication as a source passing through a noisy channel in 1948, and IBM researchers combined a prior with a likelihood for optical character recognition in the 1960s. Spelling correction adopted the full prior times likelihood recipe around 1990, at two labs almost at the same time.

لم تبدأ القناة المشوّشة مع الإملاء. فقد نمذج Shannon الاتصال على أنه مصدر يمر عبر قناة مشوّشة سنة 1948، وجمع باحثو IBM بين احتمال مسبق واحتمال شرطي في التعرف الضوئي على الحروف (OCR) في 1960s (الستينيات). وتبنّى تصحيح الإملاء الوصفة الكاملة، الاحتمال المسبق مضروبًا في الاحتمال الشرطي، نحو سنة 1990، في مختبرين في الوقت نفسه تقريبًا.

  • AT&T Bell Labs. Kernighan, Church and Gale, “A spelling correction program based on a noisy channel model”, COLING 1990. They scored candidates for non-word errors with a channel model built from confusion counts, the Kernighan, Church and Gale channel model you will compute in part 04 for the acress example.AT&T Bell Labs. Kernighan وChurch وGale، «A spelling correction program based on a noisy channel model»، COLING 1990. أعطوا درجات للمرشحين في أخطاء الكلمات غير الموجودة (non-word errors) باستخدام نموذج قناة مبني من أعداد الالتباس (confusion counts)، وهو Kernighan, Church and Gale channel model الذي ستحسبه في الجزء 04 لـ acress example.
  • IBM. Mays, Damerau and Mercer, “Context based spelling correction”, Information Processing and Management 27(5), 517 to 522, 1991. They generated candidate sentences by editing each word, scored them with a word language model as the prior, and so applied the channel idea to every word in a sentence. That is how real-word errors are handled in part 06.IBM. Mays وDamerau وMercer، «Context based spelling correction»، Information Processing and Management 27(5), 517 to 522، 1991. ولّدوا جملًا مرشحة بتعديل كل كلمة، وأعطوها درجات باستخدام نموذج لغة على مستوى الكلمات بوصفه الاحتمال المسبق، فطبّقوا بذلك فكرة القناة على كل كلمة في الجملة. وهكذا تُعالَج real-word errors (أخطاء الكلمات الحقيقية) في الجزء 06.

One equation, three fieldsمعادلة واحدة، ثلاثة مجالات

Strip away the word “spelling” and the rule says: to recover a hidden source from a noisy observation, multiply a model of how the source gets distorted by a model of what sources are likely. That recipe is the backbone of classical speech recognition and of the IBM statistical machine translation models. Brown, Della Pietra, Della Pietra and Mercer (1993) call e^=argmax⁡ePr⁡(e) Pr⁡(f∣e)\hat{e} = \operatorname{argmax}_e \Pr(e)\,\Pr(f \mid e) the Fundamental Equation of Machine Translation, derived exactly as on slide 11: Bayes' rule, then drop the denominator because it does not depend on ee.

انزع كلمة «إملاء» وستجد القاعدة تقول: لاستعادة مصدر خفي من ملاحظة مشوّشة، اضرب نموذجًا لكيفية تشوّه المصدر في نموذج لما هو مرجّح من المصادر. هذه الوصفة هي العمود الفقري للتعرف على الكلام الكلاسيكي ولنماذج الترجمة الآلية الإحصائية من IBM. ويسمّي Brown وDella Pietra وDella Pietra وMercer (1993) الصيغة e^=argmax⁡ePr⁡(e) Pr⁡(f∣e)\hat{e} = \operatorname{argmax}_e \Pr(e)\,\Pr(f \mid e) «المعادلة الأساسية للترجمة الآلية» (Fundamental Equation of Machine Translation)، وتُشتق تمامًا كما في الشريحة 11: قاعدة بايز، ثم حذف المقام لأنه لا يعتمد على ee.

TaskالمهمةObservedالمُلاحَظHidden sourceالمصدر الخفيChannel modelنموذج القناةPriorالاحتمال المسبق
Spelling correctionتصحيح الإملاءTyped string xالنص المكتوب xIntended word wالكلمة المقصودة wP(x | w)P(x | w)P(w)P(w)
Speech recognitionالتعرف على الكلامAudio signalالإشارة الصوتيةWord sequenceتسلسل الكلماتAcoustic model P(audio | words)النموذج الصوتي P(audio | words)Language model P(words)نموذج اللغة P(words)
Machine translationالترجمة الآليةFrench sentence fالجملة الفرنسية fEnglish sentence eالجملة الإنجليزية eTranslation model Pr(f | e)نموذج الترجمة Pr(f | e)Language model Pr(e)نموذج اللغة Pr(e)
The same noisy channel decomposition in three tasksتفكيك القناة المشوّشة نفسه في ثلاث مهام

In all three, the prior is a language model, the very n-gram model from lecture 03. That is why one good language model can be reused across spelling, speech and translation, while each task brings its own channel. It also explains how this lecture is organised: parts 03 and 04 build the channel side, parts 04 and 05 the language model side, and parts 06 to 08 extend the same product to context and to real systems.

في المهام الثلاث كلها، الاحتمال المسبق نموذج لغة، وهو نموذج n-gram نفسه من المحاضرة 03. ولهذا يمكن إعادة استخدام نموذج لغة جيد واحد في الإملاء والكلام والترجمة، بينما تأتي كل مهمة بقناتها الخاصة. وهذا يفسّر أيضًا تنظيم هذه المحاضرة: الجزآن 03 و04 يبنيان جانب القناة، والجزآن 04 و05 جانب نموذج اللغة، والأجزاء من 06 إلى 08 توسّع حاصل الضرب نفسه ليشمل السياق والأنظمة الحقيقية.

Recall

In speech recognition, what plays the role of P(x|w) and what plays the role of P(w)?في التعرف على الكلام، ما الذي يؤدي دور P(x|w)، وما الذي يؤدي دور P(w)؟

The acoustic model, P(audio | words), is the channel: it says how a word sequence sounds once spoken. The language model, P(words), is the prior. The recogniser picks the word sequence that maximises their product.
النموذج الصوتي (acoustic model)، P(audio | words)، هو القناة: يقول كيف يبدو تسلسل الكلمات صوتيًا عند نطقه. ونموذج اللغة، P(words)، هو الاحتمال المسبق. ويختار المُعرِّف تسلسل الكلمات الذي يجعل حاصل ضربهما أكبر ما يمكن.

Quick checkاختبار سريع

In statistical translation from French f into English e, what plays the role of P(w)?في الترجمة الإحصائية من الفرنسية f إلى الإنجليزية e، ما الذي يؤدي دور P(w)؟

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • The noisy channel view: the writer meant a correct word w, the typing process distorted it, and we observe x. Correction means recovering w from x.منظور القناة المشوّشة: قصد الكاتب كلمة صحيحة w، فشوّهتها عملية الكتابة، ونحن نلاحظ x. التصحيح يعني استعادة w من x.
  • The decoder runs every hypothesis w through a model of the channel and keeps the one most likely to have produced x.يمرّر فاكّ الترميز (decoder) كل فرضية w عبر نموذج للقناة، ويحتفظ بالفرضية الأرجح أن تكون قد أنتجت x.
  • Start from ŵ = argmax over w in V of P(w|x). Bayes' rule rewrites P(w|x) as P(x|w) P(w) / P(x).نبدأ من ŵ = argmax على كل w في V لـ P(w|x). قاعدة بايز تعيد كتابة P(w|x) على شكل P(x|w) P(w) / P(x).
  • P(x) is the same number for every candidate, because x is fixed. Dividing every score by the same positive number cannot change which one is largest, so P(x) is dropped.قيمة P(x) هي العدد نفسه لكل مرشح، لأن x ثابت. وقسمة كل الدرجات على العدد الموجب نفسه لا يمكن أن تغيّر أيّها الأكبر، لذلك نحذف P(x).
  • Final rule: ŵ = argmax P(x|w) P(w). P(x|w) is the channel or error model (likelihood, knows about typing). P(w) is the language model (prior, knows about the language).القاعدة النهائية: ŵ = argmax P(x|w) P(w). الحد P(x|w) هو نموذج القناة أو نموذج الخطأ (الاحتمال الشرطي likelihood، ويعرف عن الكتابة على لوحة المفاتيح). والحد P(w) هو نموذج اللغة (الاحتمال المسبق prior، ويعرف عن اللغة).
  • We estimate the two factors separately because each is learned from different data: error corpora for P(x|w), plain text for P(w).نقدّر العاملين كلًّا على حدة لأن كل واحد منهما يُتعلَّم من بيانات مختلفة: مدوّنات الأخطاء (error corpora) لـ P(x|w)، والنص العادي لـ P(w).
  • The same decomposition drives speech recognition and statistical machine translation. For spelling it was proposed around 1990 at AT&T Bell Labs and IBM.التفكيك نفسه هو ما يقود التعرف على الكلام والترجمة الآلية الإحصائية. وفي الإملاء اقتُرح نحو سنة 1990 في مختبرات AT&T Bell Labs وفي IBM.

Sourcesالمصادر

Part 03: Generating candidates with edit distanceتوليد المرشحين بمسافة التحرير

Turning a misspelling like acress into a short list of real words: Damerau-Levenshtein edits of distance one, the four edit types, and why distance one or two is enough.تحويل خطأ مثل acress إلى قائمة قصيرة من الكلمات الحقيقية: تعديلات Damerau-Levenshtein بمسافة واحد، وأنواع التعديل الأربعة، ولماذا تكفي المسافة واحد أو اثنان.

3 concepts3 مفاهيم, ، slides 13-16الشرائح 13-16

Why this part mattersلماذا يهمّ هذا الجزء

The noisy channel model from the previous part says: pick the word that maximizes channel probability times prior. That rule has a hidden precondition. Before you can take an argmax, you need a set of words to take it over, and scoring every word in a dictionary of hundreds of thousands of entries for every typo would be wasteful and mostly pointless. This part builds that set.

The idea is short to state: the intended word is almost always a few keystrokes away from what was typed, so generate every string a small number of edits away and keep the ones that are real words. The details are where exam marks live: which edits count, how each one is named, how many strings the generator produces, and why a radius of one or two edits is enough. One running example carries the whole part, the misspelling acress.

يقول نموذج القناة المشوشة من الجزء السابق: اختر الكلمة التي تعظّم حاصل ضرب احتمال القناة في الاحتمال المسبق (prior). لهذه القاعدة شرط مسبق خفي. قبل أن تأخذ argmax تحتاج إلى مجموعة من الكلمات تأخذه عليها، وحساب درجة كل كلمة في قاموس يضم مئات الآلاف من المدخلات مع كل خطأ إملائي سيكون هدرًا وبلا فائدة في معظمه. هذا الجزء يبني تلك المجموعة.

الفكرة قصيرة في صياغتها: الكلمة المقصودة تبعد دائمًا تقريبًا بضع ضغطات مفاتيح عمّا كُتب، لذلك نولّد كل سلسلة تبعد عددًا صغيرًا من التعديلات ونحتفظ بما هو كلمات حقيقية منها. أما التفاصيل فهي حيث تكمن درجات الامتحان: أي التعديلات تُحتسب، وكيف يُسمّى كل منها، وكم سلسلة يولّدها المولّد، ولماذا يكفي نصف قطر من تعديل واحد أو تعديلين. مثال واحد مستمر يحمل الجزء كله، وهو الخطأ الإملائي acress.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Explain why the noisy channel needs a short candidate list before it can score anything.تشرح لماذا يحتاج نموذج القناة المشوشة (<bdi>noisy channel</bdi>) إلى قائمة قصيرة من المرشحين قبل أن يستطيع حساب أي درجة.
  2. Name the two sources of candidates: words spelled similarly and words pronounced similarly.تسمّي مصدرَي المرشحين: كلمات متشابهة في التهجئة، وكلمات متشابهة في النطق.
  3. Classify any one-edit error as deletion, insertion, substitution or transposition, from the typist's point of view.تصنّف أي خطأ بتعديل واحد إلى حذف (deletion) أو إدراج (insertion) أو استبدال (substitution) أو تبديل مواضع (transposition)، من وجهة نظر الكاتب.
  4. Rebuild the seven-row acress table, including why acres appears twice.تعيد بناء جدول acress ذي الصفوف السبعة، بما في ذلك سبب ظهور acres مرتين.
  5. Count the edit-1 strings of a word with 54n + 25 and explain why the dictionary filter is the decisive step.تحسب عدد السلاسل على بُعد تعديل واحد من كلمة باستخدام 54n + 25، وتشرح لماذا يكون فلتر القاموس هو الخطوة الحاسمة.
  6. Justify the edit-distance radius of 1 or 2 and the extra space and hyphen edits.تبرّر نصف قطر مسافة التعديل البالغ 1 أو 2، وتعديلَي إدراج المسافة والشرطة الإضافيين.

Someone types acress. No English dictionary contains it, so this is a Non-word error: detection is a simple lookup. Correction is the hard half. What did they mean? Your mind probably offers actress or across within a second, and maybe acres. You did not search a dictionary alphabetically. You searched the neighbourhood of the typo, words that look like it.

يكتب شخص ما acress. لا يحتوي أي قاموس إنجليزي على هذه الكلمة، لذا فهذا non-word error (خطأ ينتج كلمة غير موجودة): اكتشافه مجرد بحث بسيط في القاموس. التصحيح هو النصف الصعب. ماذا كان يقصد؟ غالبًا يقترح عليك ذهنك actress أو across خلال ثانية، وربما acres. لم تبحث في القاموس أبجديًا. بل بحثت في جوار الخطأ، أي الكلمات التي تشبهه.

From a typo to a list of suspectsمن الخطأ الإملائي إلى قائمة من المشتبه بهم

Candidate generation is that neighbourhood search made explicit. It turns one observed string x into a short list of real words w, and only those words go on to the Noisy channel model, where each is scored by P(x|w)P(w). The argmax in that formula ranges over the candidate list, not over the whole vocabulary. That is the first thing to understand about this step: it decides which answers are even possible. If the right word is not generated, no amount of good scoring can recover it.

Candidate generation (توليد المرشحين) هو هذا البحث في الجوار وقد صار صريحًا. فهو يحوّل سلسلة واحدة مرصودة x إلى قائمة قصيرة من الكلمات الحقيقية w، وهذه الكلمات وحدها تنتقل إلى noisy channel model، حيث تُعطى كل منها درجة بالقيمة P(x|w)P(w). الـ argmax في هذه الصيغة يمتد على قائمة المرشحين، لا على المفردات كلها. هذا أول ما يجب فهمه عن هذه الخطوة: إنها تحدد أي الإجابات ممكنة أصلًا. إذا لم تُولَّد الكلمة الصحيحة، فلن يستطيع أي قدر من حساب الدرجات الجيد استعادتها.

w^=argmax⁡w∈C(x)  P(x∣w) P(w)\hat{w} = \underset{w \in C(x)}{\operatorname{argmax}}\; P(x \mid w)\,P(w)
The noisy channel decision, restricted to the candidate set C(x) built in this partقرار القناة المشوشة، مقيدًا بمجموعة المرشحين C(x) المبنية في هذا الجزء

The lecture names two ways a real word can be near a typo.

تذكر المحاضرة طريقتين يمكن أن تكون بهما كلمة حقيقية قريبة من خطأ إملائي.

  • Similar spelling. The word has a small Edit distance to the error: a few letters inserted, deleted, replaced or swapped turn one into the other. This catches typographical errors, slips of the fingers such as actress typed as acress.تهجئة متشابهة. للكلمة edit distance (مسافة تعديل) صغيرة إلى الخطأ: بضعة أحرف تُدرج أو تُحذف أو تُستبدل أو تُبدَّل مواضعها فتحوّل إحداهما إلى الأخرى. هذا يلتقط typographical errors (أخطاء الطباعة)، وهي زلّات الأصابع مثل كتابة actress على شكل acress.
  • Similar pronunciation. The word sounds like the error. Each string is first mapped to an approximate pronunciation, and candidates are words whose pronunciation is a small edit distance from the pronunciation of the typo. This catches cognitive errors, where the writer spells by sound, which letter edits alone can miss when the spelling is far off but the sound is close.نطق متشابه. الكلمة تبدو في صوتها مثل الخطأ. تُحوَّل كل سلسلة أولًا إلى نطق تقريبي، والمرشحون هم الكلمات التي يبعد نطقها مسافة تعديل صغيرة عن نطق الخطأ. هذا يلتقط cognitive errors (الأخطاء الإدراكية)، حين يتهجّى الكاتب الكلمة بحسب صوتها، وهي أخطاء قد تفوت تعديلات الأحرف وحدها عندما تكون التهجئة بعيدة لكن الصوت قريب.
Two neighbourhoods around acress: words one letter edit away, and words whose pronunciation is closeجواران حول acress: كلمات تبعد تعديلًا واحدًا في الأحرف، وكلمات نطقها قريب

Both routes use the same tool, edit distance, applied to different strings: letters in one case, pronunciation symbols in the other. GNU aspell, for example, generates candidates by comparing Metaphone keys, and later systems fold this into a Phonetic error model. Part 8 returns to those. For the rest of this part we work with spelling, which is what the acress example and the Kernighan, Church and Gale data use.

يستخدم الطريقان الأداة نفسها، مسافة التعديل، مطبّقة على سلاسل مختلفة: الأحرف في حالة، ورموز النطق في الأخرى. فبرنامج GNU aspell مثلًا يولّد المرشحين بمقارنة مفاتيح Metaphone، والأنظمة اللاحقة تدمج ذلك في phonetic error model (نموذج أخطاء صوتي). يعود الجزء 8 إلى هذه الأنظمة. في بقية هذا الجزء نعمل على التهجئة، وهي ما يستخدمه مثال acress وبيانات Kernighan وChurch وGale.

Recall

Why does the noisy channel need a candidate generator at all, and what happens if the generator misses the intended word?لماذا تحتاج القناة المشوشة إلى مولّد مرشحين أصلًا، وماذا يحدث إذا فاتت المولّدَ الكلمةُ المقصودة؟

The argmax has to range over some finite, small set; scoring the whole vocabulary for every typo is wasteful, and most words are absurd corrections anyway. The generator defines that set. If the intended word is not in it, the decoder cannot choose it, however good the channel model and language model are, so generation sets an upper limit on accuracy.

يجب أن يمتد الـ argmax على مجموعة ما محدودة وصغيرة؛ فحساب درجات المفردات كلها مع كل خطأ إملائي هدر، ومعظم الكلمات تصحيحات سخيفة على أي حال. المولّد هو من يحدد تلك المجموعة. إذا لم تكن الكلمة المقصودة فيها، فلا يستطيع المفكّك (decoder) اختيارها مهما كانت جودة نموذج القناة ونموذج اللغة، لذلك يضع التوليد حدًا أعلى للدقة.

Take the intended word actress and imagine the typist hurrying. Their finger skips the t, and acress comes out. Now take caress: the typist hits a before c, and acress comes out again. Six different real words can turn into the same typo with a single slip each. The table on slide 15 lists every one of them and names the slip.

خذ الكلمة المقصودة actress وتخيّل الكاتب مستعجلًا. يتخطى إصبعه الحرف t، فتخرج acress. والآن خذ caress: يضغط الكاتب a قبل c، فتخرج acress مرة أخرى. ست كلمات حقيقية مختلفة يمكن أن تتحول إلى الخطأ نفسه بزلّة واحدة لكل منها. الجدول في الشريحة 15 يسرد كل واحدة منها ويسمّي الزلّة.

Four kinds of single slipأربعة أنواع من الزلّة الواحدة

Spelling correction uses Damerau-Levenshtein distance, which counts four operations, each at cost 1:

يستخدم تصحيح التهجئة Damerau-Levenshtein distance، التي تحتسب أربع عمليات، تكلفة كل منها 1:

  • Deletion: a letter of the intended word is left out (actress becomes acress).Deletion (حذف): يُترك حرف من الكلمة المقصودة دون كتابة (actress تصبح acress).
  • Insertion: an extra letter is typed (cress becomes acress).Insertion (إدراج): يُكتب حرف زائد (cress تصبح acress).
  • Substitution: one letter is typed in place of another (across becomes acress).Substitution (استبدال): يُكتب حرف مكان حرف آخر (across تصبح acress).
  • Transposition: two adjacent letters are swapped (caress becomes acress).Transposition (تبديل مواضع): يتبادل حرفان متجاوران موضعيهما (caress تصبح acress).
Each row starts from an intended word and applies one slip to reach acress; the marked letters are the ones the slip touchedيبدأ كل صف من كلمة مقصودة ويطبّق زلّة واحدة للوصول إلى acress؛ الأحرف المعلَّمة هي التي مسّتها الزلّة

The convention that decides exam answersالاصطلاح الذي يحسم إجابات الامتحان

The type always names what the typist did to the correct word to produce the error. Read every row as intended word → typo, never the other way. That is why the columns are called correct letter and error letter: the correct letter is what should have been typed, the error letter is what was typed, and a dash means nothing. So actress has correct letter t and error letter dash: a t should have been there and nothing was typed, a deletion. cress has correct letter dash and error letter a: nothing should have been there and an a was typed, an insertion.

يسمّي النوعُ دائمًا ما فعله الكاتب بالكلمة الصحيحة لينتج الخطأ. اقرأ كل صف على أنه intended word → typo (من الكلمة المقصودة إلى الخطأ)، لا العكس أبدًا. لهذا سُمّي العمودان correct letter (الحرف الصحيح) وerror letter (الحرف الخاطئ): الحرف الصحيح هو ما كان يجب أن يُكتب، والحرف الخاطئ هو ما كُتب فعلًا، والشرطة تعني لا شيء. إذن لـ actress حرف صحيح t وحرف خاطئ شرطة: كان يجب أن يوجد t ولم يُكتب شيء، أي حذف. ولـ cress حرف صحيح شرطة وحرف خاطئ a: لم يكن يجب أن يوجد شيء وكُتب a، أي إدراج.

CandidateالمرشحCorrect letterالحرف الصحيحError letterالحرف الخاطئPositionالموضعType, from the typist's sideالنوع، من جهة الكاتب
actressactresstt--22deletion: the typist left out tحذف: أسقط الكاتب الحرف t
cresscress--aa00insertion: the typist added aإدراج: أضاف الكاتب الحرف a
caresscaresscacaacac00transposition: c and a swappedتبديل مواضع: تبادل c وa موضعيهما
accessaccessccrr22substitution: r typed for cاستبدال: كُتب r مكان c
acrossacrossooee33substitution: e typed for oاستبدال: كُتب e مكان o
acresacres--ss44insertion: extra s after e (es|e)إدراج: s زائد بعد e (es|e)
acresacres--ss55insertion: extra s after s (ss|s)إدراج: s زائد بعد s (ss|s)
Slide 15 with the reasoning spelled out. Position is the index in acress, counting from 0, as in Jurafsky and Martin, Fig. B.3الشريحة 15 مع شرح المنطق كاملًا. الموضع هو الفهرس في acress بدءًا من 0، كما في Jurafsky and Martin، الشكل B.3

Why transposition gets its own operationلماذا يحصل تبديل المواضع على عملية خاصة به

In lecture 2 you computed minimum edit distance with three operations only, insertion, deletion and substitution. That is Levenshtein distance. Under it, caress and acress are two edits apart: two substitutions, or a deletion plus an insertion. Damerau observed in 1964 that swapping two neighbouring keys is one of the commonest typing mistakes, so he counted it as a single edit. Adding that one operation is the only difference, and it is what makes caress a distance-1 candidate.

في المحاضرة 2 حسبت مسافة التعديل الدنيا (minimum edit distance) بثلاث عمليات فقط: الإدراج والحذف والاستبدال. هذه هي مسافة Levenshtein. وفقها، تبعد caress وacress تعديلين: استبدالين، أو حذفًا مع إدراج. لاحظ Damerau عام 1964 أن تبديل مفتاحين متجاورين من أكثر أخطاء الطباعة شيوعًا، فاحتسبه تعديلًا واحدًا. إضافة هذه العملية الواحدة هي الفرق الوحيد، وهي ما يجعل caress مرشحًا على مسافة 1.

LevenshteinLevenshteinDamerau-LevenshteinDamerau-Levenshtein
OperationsالعملياتInsertion, deletion, substitutionالإدراج والحذف والاستبدالThe same three plus transposition of adjacent lettersالعمليات الثلاث نفسها مع تبديل موضعَي حرفين متجاورين
Distance from acress to caressالمسافة من acress إلى caress2 (two substitutions, or a deletion plus an insertion)2 (استبدالان، أو حذف مع إدراج)11
Where you met itأين قابلتهاLecture 2, minimum edit distance with dynamic programmingالمحاضرة 2، مسافة التعديل الدنيا بالبرمجة الديناميكيةThis lecture, candidate generationهذه المحاضرة، توليد المرشحين
Why it fits hereلماذا تناسب هناGeneral string similarity and alignmentتشابه السلاسل ومحاذاتها بشكل عامSwapped neighbours are one of the commonest typing slipsتبادل حرفين متجاورين من أكثر زلّات الطباعة شيوعًا
Levenshtein (lecture 2) versus Damerau-Levenshtein (this lecture)مسافة Levenshtein (المحاضرة 2) مقابل مسافة Damerau-Levenshtein (هذه المحاضرة)

Quick checkاختبار سريع

acress was typed when the writer meant caress. Which error type is this?كُتبت acress بينما قصد الكاتب caress. ما نوع هذا الخطأ؟

Quick checkاختبار سريع

acress was typed when the writer meant actress. Which error type is this?كُتبت acress بينما قصد الكاتب actress. ما نوع هذا الخطأ؟

Recall

Why does acres appear twice in the acress table, and why should both rows be kept?لماذا تظهر acres مرتين في جدول acress، ولماذا يجب الإبقاء على الصفين؟

acress ends in two s letters, and the extra one could have been typed after e (position 4) or after the first s (position 5), written es|e and ss|s on slide 24. Those are two distinct derivations of the same candidate. They are kept because each has its own channel probability, conditioned on a different preceding letter, and the probability that acres produced acress is the sum over the ways it could have happened.

تنتهي acress بحرفَي s، والحرف الزائد قد يكون كُتب بعد e (الموضع 4) أو بعد أول s (الموضع 5)، ويُكتبان es|e وss|s في الشريحة 24. هذان اشتقاقان مختلفان للمرشح نفسه. يُبقى عليهما لأن لكل منهما احتمال قناة خاصًا به، مشروطًا بحرف سابق مختلف، واحتمال أن تكون acres قد أنتجت acress هو مجموع الاحتمالات على كل الطرق التي يمكن أن يحدث بها ذلك.

How does a program actually find those six words? It does not compare acress against every dictionary entry. It runs the four operations in reverse on the typo itself, every possible way, and then asks the dictionary which of the results exist. Peter Norvig's well-known corrector does exactly this in a few lines. The number of strings it produces is worth computing once, because it explains the whole design.

كيف يجد البرنامج هذه الكلمات الست فعلًا؟ إنه لا يقارن acress بكل مدخل في القاموس. بل يشغّل العمليات الأربع بالعكس على الخطأ نفسه، بكل طريقة ممكنة، ثم يسأل القاموس أي النتائج موجود. مصحح Peter Norvig المعروف يفعل هذا بالضبط في بضعة أسطر. عدد السلاسل التي ينتجها يستحق أن يُحسب مرة واحدة، لأنه يفسّر التصميم كله.

Worked exampleمثال محلول

How many strings lie one edit from a word of length n?كم سلسلة تقع على بُعد تعديل واحد من كلمة طولها n؟

  1. Deletionsالحذف

    Remove any one of the n letters: n strings.
    احذف أيًّا من الأحرف الـ n: n سلسلة.
  2. Transpositionsتبديل المواضع

    Swap any of the n - 1 adjacent pairs: n - 1 strings.
    بدّل أيًّا من الأزواج المتجاورة الـ n - 1: n - 1 سلسلة.
  3. Substitutionsالاستبدال

    Replace any of the n letters with any of 26 letters: 26n strings.
    استبدل أيًّا من الأحرف الـ n بأي حرف من الأحرف الـ 26: 26n سلسلة.
  4. Insertionsالإدراج

    Insert any of 26 letters into any of the n + 1 gaps, including both ends: 26(n + 1) strings.
    أدرج أيًّا من الأحرف الـ 26 في أي فجوة من الفجوات الـ n + 1، بما فيها الطرفان: 26(n + 1) سلسلة.
  5. Add them upاجمعها

    n+(n−1)+26n+26(n+1)=54n+25n + (n-1) + 26n + 26(n+1) = 54n + 25
    n+(n−1)+26n+26(n+1)=54n+25n + (n-1) + 26n + 26(n+1) = 54n + 25
  6. Plug in acressعوّض بـ acress

    With n = 6: 6 + 5 + 156 + 182 = 349 strings. If substitutions skip the letter that is already there (25n instead of 26n), it is 343. Some strings repeat, so the distinct count is 336, and one of those is acress itself (swapping the two s letters, or replacing a letter by itself, gives it back).
    مع n = 6: 6 + 5 + 156 + 182 = 349 سلسلة. إذا تخطّى الاستبدال الحرف الموجود أصلًا (25n بدلًا من 26n)، يصبح العدد 343. بعض السلاسل يتكرر، فيكون العدد المميز 336، وإحداها هي acress نفسها (تبديل حرفَي s، أو استبدال حرف بنفسه، يعيدها كما هي).
  7. Resultالنتيجة

    About 335 new strings, of which exactly six are English words: actress, cress, caress, access, across, acres. Roughly 98% of the generator's output is junk such as zcress or acrss.
    نحو 335 سلسلة جديدة، ست منها بالضبط كلمات إنجليزية: actress وcress وcaress وaccess وacross وacres. قرابة 98% من مخرجات المولّد نفايات مثل zcress أو acrss.
349 edit-1 strings of acress; only six survive the dictionary lookup349 سلسلة على بُعد تعديل واحد من acress؛ ست منها فقط تنجو من البحث في القاموس

This is why the dictionary filter, not the edit operations, is the key step. Generating strings is trivial and cheap; almost all of them are nonsense. Intersecting them with the dictionary is what turns a few hundred strings into a handful of real candidates, each with its edit type and position recorded for the channel model. Because the count is linear in n, edit-1 generation is fast for any realistic word.

لهذا السبب فإن فلتر القاموس، لا عمليات التعديل، هو الخطوة الأساسية. توليد السلاسل أمر تافه ورخيص؛ وكلها تقريبًا بلا معنى. تقاطعها مع القاموس هو ما يحوّل بضع مئات من السلاسل إلى حفنة من المرشحين الحقيقيين، مع تسجيل نوع التعديل وموضعه لكل منها لصالح نموذج القناة. ولأن العدد خطي في n، فإن توليد السلاسل على بُعد تعديل واحد سريع لأي كلمة واقعية.

Why stop at one or two editsلماذا نتوقف عند تعديل واحد أو تعديلين

The radius is set by data on real errors. Damerau's 1964 study found that more than 80% of the misspellings he examined were a single insertion, deletion, substitution or transposition, and the slide's rule follows: about 80% of errors are within edit distance 1, almost all within 2. Norvig's experiment agrees on the second half: in his development set only 3 of 270 errors were further than two edits from the correction.

يُحدَّد نصف القطر ببيانات الأخطاء الحقيقية. وجدت دراسة Damerau عام 1964 أن أكثر من 80% من الأخطاء الإملائية التي فحصها كانت إدراجًا واحدًا أو حذفًا أو استبدالًا أو تبديل مواضع، ومنها تأتي قاعدة الشريحة: نحو 80% من الأخطاء ضمن مسافة تعديل 1، وكلها تقريبًا ضمن 2. وتجربة Norvig تتفق مع الشطر الثاني: في مجموعة التطوير لديه كان 3 فقط من 270 خطأ أبعد من تعديلين عن التصحيح.

Going further is expensive and rarely useful. Applying the generator twice squares the work: for acress the edit-2 set has on the order of 335 × 349 ≈ 117,000 raw strings, and the number of real words inside that wider ring grows too, so the channel model has more distractors to separate. Norvig's corrector therefore tries distance 1 first and widens to distance 2 only when distance 1 finds no known word.

الذهاب أبعد مكلف ونادرًا ما يفيد. تطبيق المولّد مرتين يربّع العمل: لكلمة acress تضم مجموعة التعديلين ما يقارب 335 × 349 ≈ 117,000 سلسلة خام، ويزداد أيضًا عدد الكلمات الحقيقية داخل هذه الحلقة الأوسع، فيكون أمام نموذج القناة مشتّتات أكثر عليه التمييز بينها. لذلك يجرّب مصحح Norvig المسافة 1 أولًا، ولا يتوسع إلى المسافة 2 إلا عندما لا تجد المسافة 1 أي كلمة معروفة.

Space and hyphen as extra editsالمسافة والشرطة كتعديلات إضافية

Some errors are not inside a word at all. A typist who misses the space bar produces thisidea for this idea; one who drops a hyphen produces inlaw for in-law. Neither is one letter edit from a single dictionary word, so the plain generator returns nothing. Allowing the generator to insert a space or a hyphen between two letters fixes this, as long as the lookup then checks each piece. It adds only 2(n - 1) strings.

بعض الأخطاء ليست داخل كلمة أصلًا. الكاتب الذي يخطئ مفتاح المسافة ينتج thisidea بدلًا من this idea؛ ومن يُسقط شرطة ينتج inlaw بدلًا من in-law. لا يبعد أي منهما تعديل حرف واحد عن كلمة واحدة في القاموس، لذا لا يعيد المولّد العادي شيئًا. السماح للمولّد بإدراج مسافة أو شرطة بين حرفين يحل المشكلة، بشرط أن يفحص البحث بعد ذلك كل جزء على حدة. وهذا لا يضيف إلا 2(n - 1) سلسلة.

Try the generator below. Start with acress and check that the counts match the worked example and that the survivors match slide 15, both acres rows included. Then try teh, graffe, and the two run-together presets. Notice that the survivor column names the typist's error even though the generator ran the opposite operation. The run-together presets switch the space and hyphen option on; switch it on for acress too and a cress appears as an eighth row, a small reminder that every extra kind of edit also admits extra distractors.

جرّب المولّد أدناه. ابدأ بـ acress وتحقق من أن الأعداد تطابق المثال المحلول وأن الناجين يطابقون الشريحة 15، بما في ذلك صفّا acres كلاهما. ثم جرّب teh وgraffe والإعدادين المسبقين للكلمات الملتصقة. لاحظ أن عمود الناجين يسمّي خطأ الكاتب رغم أن المولّد نفّذ العملية المعاكسة. الإعدادان المسبقان للكلمات الملتصقة يفعّلان خيار المسافة والشرطة؛ فعّله مع acress أيضًا وستظهر a cress صفًا ثامنًا، تذكيرًا صغيرًا بأن كل نوع إضافي من التعديل يُدخل أيضًا مشتّتات إضافية.

InteractiveتفاعليEdit-1 candidate generatorمولّد المرشحين على بعد تعديل واحد
Delete a letter6n
Swap neighbours5n - 1
Replace a letter15626n
Insert a letter18226(n + 1)
Generated349strings
Distinct336strings
In dictionary7derivations

349 strings generated, 336 distinct, 7 dictionary derivations

CandidateCorrectErrorPositionTypist made
cress-a0insertion
acres-s4insertion
acres-s5insertion
caresscaac0transposition
accesscr2substitution
acrossoe3substitution
actresst-2deletion

The generator edits the typed word, so its operations run backwards from the typist. Deleting a letter from the typo finds a word where the typist inserted one, and inserting a letter finds a word where the typist deleted one. Position counts letters of the typed word from 0. The dictionary is a tiny demo list, not a real lexicon.يعدّل المولّد الكلمة المكتوبة، لذلك تسير عملياته في الاتجاه المعاكس لما فعله الكاتب. حذف حرف من الخطأ الإملائي يجد كلمة أدرج فيها الكاتب حرفًا زائدًا، وإدراج حرف يجد كلمة حذف منها الكاتب حرفًا. يُعدّ الموضع حروف الكلمة المكتوبة بدءًا من 0. القاموس هنا قائمة تجريبية صغيرة، وليس معجمًا حقيقيًا.

Quick checkاختبار سريع

Using 54n + 25, how many edit-1 strings does a four-letter typo generate?باستخدام 54n + 25، كم سلسلة على بُعد تعديل واحد يولّدها خطأ إملائي من أربعة أحرف؟

Recall

Why does candidate generation also allow inserting a space or hyphen?لماذا يسمح توليد المرشحين أيضًا بإدراج مسافة أو شرطة؟

Because some errors join two words: thisidea for this idea, inlaw for in-law. The run-together string is not one letter edit from any single dictionary word, so letter edits alone return nothing. Inserting a space or hyphen between two letters, then checking each piece against the dictionary, recovers these cases at a cost of only 2(n - 1) extra strings.

لأن بعض الأخطاء تدمج كلمتين: thisidea بدلًا من this idea، وinlaw بدلًا من in-law. السلسلة الملتصقة لا تبعد تعديل حرف واحد عن أي كلمة واحدة في القاموس، لذا لا تعيد تعديلات الأحرف وحدها شيئًا. إدراج مسافة أو شرطة بين حرفين، ثم فحص كل جزء في القاموس، يستعيد هذه الحالات بتكلفة لا تتجاوز 2(n - 1) سلسلة إضافية.

Recall

Of the 349 edit-1 strings of acress, how many survive, and what does that say about where the work happens?من بين 349 سلسلة على بُعد تعديل واحد من acress، كم منها ينجو، وماذا يخبرنا ذلك عن موضع العمل الحقيقي؟

Six distinct words (seven derivations, because acres arises twice). Nearly everything the generator makes is not a word, so the dictionary lookup does the real filtering; generation itself is cheap and blind.

ست كلمات مميزة (سبعة اشتقاقات، لأن acres تنشأ مرتين). كل ما يصنعه المولّد تقريبًا ليس كلمة، لذا فالبحث في القاموس هو من يقوم بالتصفية الحقيقية؛ أما التوليد نفسه فرخيص وأعمى.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • The noisy channel scores candidates, it does not invent them. Candidate generation hands it a short list of real words near the typo.القناة المشوشة تعطي المرشحين درجات ولا تخترعهم. توليد المرشحين يسلّمها قائمة قصيرة من الكلمات الحقيقية القريبة من الخطأ.
  • Candidates come from small edit distance in spelling, and from small edit distance between pronunciations.يأتي المرشحون من مسافة تعديل صغيرة في التهجئة، ومن مسافة تعديل صغيرة بين طريقتَي النطق.
  • Spelling edits are Damerau-Levenshtein: insertion, deletion, substitution, and transposition of two adjacent letters, each costing 1.تعديلات التهجئة هي تعديلات Damerau-Levenshtein: الإدراج والحذف والاستبدال وتبديل موضعَي حرفين متجاورين، وتكلفة كل منها 1.
  • The type names what the typist did to the intended word: actress to acress is a deletion of t, cress to acress is an insertion of a.يسمّي النوعُ ما فعله الكاتب بالكلمة المقصودة: من actress إلى acress حذفٌ للحرف t، ومن cress إلى acress إدراجٌ للحرف a.
  • acress has six candidates in seven rows: acres arises twice, from an extra s typed at position 4 or at position 5.لكلمة acress ستة مرشحين في سبعة صفوف: تظهر acres مرتين، من حرف s زائد كُتب في الموضع 4 أو في الموضع 5.
  • A word of length n has n + (n - 1) + 26n + 26(n + 1) = 54n + 25 edit-1 strings: 349 for acress, of which only six are words.للكلمة ذات الطول n عدد n + (n - 1) + 26n + 26(n + 1) = 54n + 25 من السلاسل على بُعد تعديل واحد: 349 لكلمة acress، ستّ منها فقط كلمات حقيقية.
  • About 80 percent of errors are within one edit and almost all within two. Space and hyphen insertion handle run-together words like thisidea and inlaw.نحو 80 بالمئة من الأخطاء تقع ضمن تعديل واحد، وكلها تقريبًا ضمن تعديلين. إدراج المسافة والشرطة يعالج الكلمات الملتصقة مثل thisidea وinlaw.

Sourcesالمصادر

Part 04: The prior and the channel modelالاحتمال المسبق (Prior) ونموذج القناة

Estimating the two factors: P(w) from corpus counts, and P(x|w) from the Kernighan, Church and Gale confusion matrices for deletion, insertion, substitution and transposition.تقدير العاملين: P(w) من عدّ المدونة، وP(x|w) من مصفوفات الالتباس لـ Kernighan وChurch وGale للحذف والإدراج والاستبدال والتبديل (transposition).

3 concepts3 مفاهيم, ، slides 17-24الشرائح 17-24

Why this part mattersلماذا يهمّ هذا الجزء

The Noisy channel model picks the candidate w that maximizes a product of two numbers, the prior P(w) and the channel probability P(x|w). Part 03 produced the candidates for acress. This part fills in both numbers for every one of them, using corpus counts for the prior and the Kernighan, Church and Gale confusion matrices for the channel. Expect an exam question that hands you a count and asks for one of these probabilities, and expect the hard part to be picking the right denominator.
يختار noisy channel model المرشح w الذي يعظّم حاصل ضرب عددين: الاحتمال المسبق P(w) واحتمال القناة P(x|w). أنتج الجزء 03 المرشحين للكلمة acress. وهذا الجزء يملأ العددين لكل واحد منهم، مستخدمًا عدّات المدوّنة للاحتمال المسبق، ومصفوفات الالتباس الخاصة بـ Kernighan وChurch وGale للقناة. توقّع في الامتحان سؤالًا يعطيك عدًّا ويطلب أحد هذين الاحتمالين، وتوقّع أن يكون الجزء الصعب هو اختيار المقام الصحيح.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Compute a unigram prior P(w) = C(w)/N from corpus counts and explain why any n-gram model can supply the prior.تحسب الاحتمال المسبق أحادي الكلمة P(w) = C(w)/N من عدّات المدوّنة، وتشرح لماذا يمكن لأي نموذج n-gram أن يوفّر هذا الاحتمال المسبق.
  2. State what each of the four confusion matrices del, ins, sub and trans counts, and read a cell of the substitution matrix in the right direction.تذكر ما تعدّه كل مصفوفة من مصفوفات الالتباس الأربع del وins وsub وtrans، وتقرأ خلية في مصفوفة الاستبدال بالاتجاه الصحيح.
  3. Write the Kernighan, Church and Gale formula for P(x|w) from memory, with the correct numerator and denominator for each edit type.تكتب صيغة Kernighan وChurch وGale للاحتمال P(x|w) من الذاكرة، مع البسط والمقام الصحيحين لكل نوع من أنواع التعديل.
  4. Map every acress candidate to its matrix cell and denominator, and explain why a zero count still gives a nonzero probability.تربط كل مرشح من مرشحي acress بخليته في المصفوفة وبمقامه، وتشرح لماذا يعطي العدّ الصفري مع ذلك احتمالًا غير صفري.

Before looking at how acress could have been mistyped, ask a simpler question: if you pick a random word from a large body of English, how likely is it to be actress? In the COCA sample of 404,253,213 words, actress appears 9,321 times, so about 23 words in every million are actress. Across appears 120,844 times, about 299 per million. Without knowing anything about the typo, across is roughly 13 times more likely to be the word the writer meant.

قبل أن ننظر في الطريقة التي ربما كُتبت بها acress خطأً، اطرح سؤالًا أبسط: لو اخترت كلمة عشوائية من نص إنجليزي ضخم، فما احتمال أن تكون actress؟ في عيّنة COCA المكوّنة من 404,253,213 كلمة، تظهر actress عدد 9,321 مرة، أي قرابة 23 كلمة من كل مليون. وتظهر across عدد 120,844 مرة، أي قرابة 299 في المليون. فمن دون معرفة أي شيء عن الخطأ الإملائي، تكون across أرجح بنحو 13 مرة لأن تكون الكلمة التي قصدها الكاتب.

That number is the Prior probability, P(w): how plausible a candidate is as a piece of text before the typed string is taken into account. The noisy channel does not care where it comes from. Any language model from lecture 03 can provide it: a unigram, a Bigram language model that looks at the previous word, or a trigram that looks at two. The simplest choice, used on this slide, is the Unigram prior: the relative frequency of the word in a corpus.

هذا العدد هو prior probability أي الاحتمال المسبق P(w): مدى معقولية المرشح بوصفه قطعة من نص قبل أخذ السلسلة المكتوبة في الحسبان. ولا تهتم القناة الصاخبة بمصدره. فأي نموذج لغوي من المحاضرة 03 يمكنه توفيره: نموذج unigram، أو bigram language model الذي ينظر إلى الكلمة السابقة، أو نموذج trigram الذي ينظر إلى كلمتين. وأبسط خيار، وهو المستخدم في هذه الشريحة، هو unigram prior: التكرار النسبي للكلمة في مدوّنة.

P(w)=C(w)NP(w) = \frac{C(w)}{N}
Unigram prior: corpus count of w over the total number of word tokens Nالاحتمال المسبق بنموذج unigram: عدّ w في المدونة مقسومًا على إجمالي رموز الكلمات N

Worked exampleمثال محلول

Verify P(actress) from the COCA countsتحقّق من P(actress) باستخدام عدّات COCA

  1. Read the countsاقرأ العدّات

    C(actress) = 9,321 and N = 404,253,213 word tokens.
    C(actress) = 9,321 وN = 404,253,213 وحدة كلمة (word tokens).
  2. Divideاقسم

    9,321 / 404,253,213 = 0.0000230573, which is 2.31 × 10⁻⁵.
    9,321 / 404,253,213 = 0.0000230573، أي 2.31 × 10⁻⁵.
  3. Sanity check against a neighborتحقّق منطقي بالمقارنة مع مرشح مجاور

    120,844 / 404,253,213 = 0.000298931 for across, and the ratio 120,844 / 9,321 ≈ 12.96 matches the ratio of the two probabilities, as it must, because they share N.
    120,844 / 404,253,213 = 0.000298931 للكلمة across، والنسبة 120,844 / 9,321 ≈ 12.96 تطابق النسبة بين الاحتمالين، وهذا لا بد منه لأنهما يشتركان في N.
  4. Resultالنتيجة

    P(actress) = 2.31 × 10⁻⁵, the first row of the table below.
    P(actress) = 2.31 × 10⁻⁵، وهو الصف الأول في الجدول أدناه.
Bars proportional to each candidate's COCA count: across dwarfs the others, and cress and caress barely registerأعمدة تتناسب مع عدّ كل مرشح في COCA: تتضاءل أمام across بقية المرشحين، ولا تكاد cress وcaress تظهران

The full table of priors for the six candidates of acress:

الجدول الكامل للاحتمالات المسبقة لمرشحي acress الستة:

Candidate wالمرشح wC(w)C(w)P(w)P(w)
actressactress9,3219,321.0000230573.0000230573
cresscress220220.0000005442.0000005442
caresscaress686686.0000016969.0000016969
accessaccess37,03837,038.0000916207.0000916207
acrossacross120,844120,844.0002989314.0002989314
acresacres12,87412,874.0000318463.0000318463
Unigram priors from 404,253,213 COCA words (slide 18)الاحتمالات المسبقة أحادية الكلمة من 404,253,213 كلمة في COCA (الشريحة 18)

Notice what this table cannot know. The original sentence was about a stellar and versatile acress, and any human reads actress at once. A unigram prior has no access to that sentence, so it ranks the candidates purely by how common they are in general. That is the weakness part 05 fixes by swapping in a bigram prior, which is exactly the flexibility slide 17 promises: the channel stays the same and only the language model changes.

لاحظ ما لا يستطيع هذا الجدول معرفته. كانت الجملة الأصلية عن acress «متألقة ومتعددة المواهب»، وأي إنسان يقرؤها actress فورًا. أما الاحتمال المسبق أحادي الكلمة فلا يصل إلى تلك الجملة، لذا يرتّب المرشحين فقط بحسب مدى شيوعهم عمومًا. وهذا هو الضعف الذي يعالجه الجزء 05 باستبدال احتمال مسبق من نوع bigram به، وهي بالضبط المرونة التي تعد بها الشريحة 17: تبقى القناة كما هي ويتغير النموذج اللغوي وحده.

Priors at web scaleالاحتمالات المسبقة على نطاق الويب

A search engine correcting queries has n-gram counts over hundreds of billions of words. Properly smoothed models such as Kneser-Ney are expensive to estimate at that size, so the slide points to Stupid backoff: use the relative frequency of the longest n-gram that was seen, and multiply by a fixed 0.4 each time you back off to a shorter one. The result is a score rather than a true probability, but the decoder only compares candidates, so a consistent score is enough. The full recipe and a worked example are in lecture 03, backoff and stupid backoff.

محرك البحث الذي يصحّح الاستعلامات يملك عدّات n-gram على مئات المليارات من الكلمات. والنماذج المنعّمة تنعيمًا سليمًا مثل Kneser-Ney مكلفة التقدير عند هذا الحجم، لذلك تشير الشريحة إلى stupid backoff: استخدم التكرار النسبي لأطول n-gram شوهد، واضرب في قيمة ثابتة 0.4 في كل مرة تتراجع فيها إلى n-gram أقصر. والنتيجة درجة وليست احتمالًا حقيقيًا، لكن المفكّك (decoder) يقارن المرشحين فقط، فتكفي درجة متّسقة. والوصفة الكاملة مع مثال محلول موجودة في المحاضرة 03، backoff وstupid backoff.

Recall

Why can the noisy channel corrector use a unigram, bigram or trigram prior without any other change?لماذا يستطيع مصحّح القناة الصاخبة استخدام احتمال مسبق من نوع unigram أو bigram أو trigram دون أي تغيير آخر؟

The prior and channel are separate factors in P(x|w) P(w). The prior only has to score how plausible w is as text, so any language model that assigns a score to w (in context or not) can be plugged in while the channel model stays the same.
لأن الاحتمال المسبق والقناة عاملان منفصلان في P(x|w) P(w). فالاحتمال المسبق عليه فقط أن يقدّر مدى معقولية w بوصفها نصًّا، لذا يمكن تركيب أي نموذج لغوي يعطي w درجة (ضمن سياق أو من دونه) بينما يبقى نموذج القناة كما هو.

Take the candidate across. To get acress from it, the writer must have typed e where o was intended. How often does that happen? Kernighan, Church and Gale counted it over a large set of real typos from newswire text: e was typed for o 93 times. That single number, divided by how often o occurs at all, is the probability of the edit. This is the whole idea of the Channel model, also called the error model or edit probability.

خذ المرشح across. لكي نحصل منه على acress، لا بد أن الكاتب كتب e حيث كان يقصد o. فكم مرة يحدث ذلك؟ عدّه Kernighan وChurch وGale على مجموعة كبيرة من الأخطاء الإملائية الحقيقية في نصوص الأخبار: كُتب e بدلًا من o عدد 93 مرة. هذا العدد الواحد، مقسومًا على عدد مرات ظهور o أصلًا، هو احتمال التعديل. وهذه هي الفكرة الكاملة لـ channel model، ويُسمّى أيضًا نموذج الخطأ (error model) أو احتمال التعديل (edit probability).

Fix the notation from slide 19. The typed, misspelled word is x = x₁ x₂ … xₘ and the intended, correct word is w = w₁ w₂ … wₙ, both as sequences of letters. Every candidate from part 03 differs from the typo by a single edit, so P(x|w) is just the probability of that one edit: a Deletion, an Insertion, a Substitution or a Transposition. A perfect error model would condition on the typist, the keyboard and the time of day. This one conditions only on the letters involved and, for insertion and deletion, the letter just before, which is local enough to estimate from data.

ثبّت الرموز من الشريحة 19. الكلمة المكتوبة الخاطئة هي x = x₁ x₂ … xₘ والكلمة المقصودة الصحيحة هي w = w₁ w₂ … wₙ، وكلتاهما متتالية من الحروف. كل مرشح من الجزء 03 يختلف عن الخطأ الإملائي بتعديل واحد، لذا فإن P(x|w) هو ببساطة احتمال ذلك التعديل الواحد: حذف deletion، أو إدراج insertion، أو استبدال substitution، أو تبديل transposition. نموذج الخطأ المثالي كان سيشترط على الكاتب ولوحة المفاتيح ووقت اليوم. أما هذا النموذج فيشترط فقط على الحروف المعنية، وفي حالتي الإدراج والحذف على الحرف السابق مباشرة، وهذا محلي بما يكفي لتقديره من البيانات.

Four intended words reach the same typo acress through four different edits; each edit names the confusion-matrix cell that prices itأربع كلمات مقصودة تصل إلى الخطأ الإملائي نفسه acress عبر أربعة تعديلات مختلفة؛ وكل تعديل يسمّي خلية مصفوفة الالتباس التي تحدد احتماله

The four tablesالجداول الأربعة

A Confusion matrix is a table of counts of how often one thing was mistaken for another. The Kernighan, Church and Gale channel model uses four of them, one per edit type, each indexed by a pair of letters.

confusion matrix أو مصفوفة الالتباس هي جدول عدّات لعدد المرات التي أُخذ فيها شيء على أنه شيء آخر. ويستخدم Kernighan, Church and Gale channel model أربعًا منها، واحدة لكل نوع تعديل، وكل منها مفهرسة بزوج من الحروف.

The four confusion matrices (slide 20, read consistently with slides 21 and 23)مصفوفات الالتباس الأربع (الشريحة 20، مقروءة بما يتّسق مع الشريحتين 21 و23)

del[x,y]
count(xy typed as x): the y after an x was left outcount(xy كُتبت x): سقط الحرف y الذي يأتي بعد x
ins[x,y]
count(x typed as xy): an extra y was typed after an xcount(x كُتبت xy): كُتب حرف y زائد بعد x
sub[x,y]
count(y typed as x): x was typed where y was intended (see the errata below)count(y كُتبت x): كُتب x حيث كان المقصود y (انظر التصويب أدناه)
trans[x,y]
count(xy typed as yx): two adjacent letters were swappedcount(xy كُتبت yx): تبادل حرفان متجاوران موقعيهما

Insertion and deletion are conditioned on the previous character. Dropping the t in actress is recorded as del[c,t], a t lost after a c, not as a bare t lost anywhere. That matters, because some letters vanish far more easily in certain neighborhoods, such as one letter of a doubled pair. The same choice gives insertion its first index: the extra s in acress, read as acres plus an s, is ins[e,s] or ins[s,s] depending on which s you call the extra one, and both readings appear on slide 24.

الإدراج والحذف مشروطان بالحرف السابق. فإسقاط t من actress يُسجَّل على أنه del[c,t]، أي t ضاع بعد c، لا مجرد t ضاع في أي مكان. وهذا مهم، لأن بعض الحروف تختفي بسهولة أكبر بكثير في جوار معيّن، مثل أحد حرفي زوج مكرر. والاختيار نفسه يعطي الإدراج فهرسه الأول: فالحرف s الزائد في acress، إذا قرأناها acres مضافًا إليها s، يكون ins[e,s] أو ins[s,s] بحسب أي s تعدّه الزائد، والقراءتان كلتاهما تظهران في الشريحة 24.

Reading the substitution matrixقراءة مصفوفة الاستبدال

Slide 21 prints the substitution table from the original paper. Rows are X, the letter typed; columns are Y, the letter intended. So the cell in row e, column o is sub[e,o] = 93: e typed for o. The big numbers cluster among the vowels: sub[e,a] = 388, sub[a,e] = 342, sub[i,e] = 146, sub[o,e] = 116. Vowels sound alike in unstressed syllables, so writers who spell by ear confuse them constantly. Among consonants the standout is sub[m,n] = 180, two letters that are both similar in sound and adjacent on the keyboard.

تطبع الشريحة 21 جدول الاستبدال من الورقة الأصلية. الصفوف هي X، الحرف المكتوب؛ والأعمدة هي Y، الحرف المقصود. لذا فالخلية في الصف e والعمود o هي sub[e,o] = 93: كُتب e بدلًا من o. وتتجمع الأعداد الكبيرة بين حروف العلة: sub[e,a] = 388، sub[a,e] = 342، sub[i,e] = 146، sub[o,e] = 116. فحروف العلة تتشابه في النطق داخل المقاطع غير المنبورة، ولذلك يخلط بينها باستمرار من يكتبون بحسب السمع. ومن بين الحروف الساكنة يبرز sub[m,n] = 180، وهما حرفان متشابهان في الصوت ومتجاوران على لوحة المفاتيح معًا.

The vowel corner of the substitution matrix, shaded by count; the outlined cell is sub[e,o] = 93, the edit behind acrossركن حروف العلة في مصفوفة الاستبدال، مظلَّل بحسب العدّ؛ والخلية المحاطة بإطار هي sub[e,o] = 93، التعديل الذي يقف خلف across

Where the counts come fromمن أين تأتي العدّات

You need a list of real misspellings paired with their corrections, such as the Wikipedia list of common misspellings, Roger Mitton's Birkbeck corpus, or Peter Norvig's collection. Align each pair, find the single edit, and add one to the matching cell. Slide 22 points to Norvig's file of counts of single-edit errors, which already does this: it lists edits such as e|i with a count, ready to drop into the four tables. Kernighan, Church and Gale had no such list, so they bootstrapped: start with uniform matrices, correct a corpus of rejected words with the current model, recount the edits the corrections imply, and repeat. That loop is an instance of the EM algorithm.

تحتاج إلى قائمة بأخطاء إملائية حقيقية مقرونة بتصحيحاتها، مثل قائمة ويكيبيديا للأخطاء الإملائية الشائعة، أو مدوّنة Birkbeck الخاصة بـ Roger Mitton، أو مجموعة Peter Norvig. حاذِ كل زوج، وجد التعديل الواحد، وأضف واحدًا إلى الخلية المطابقة. وتشير الشريحة 22 إلى ملف Norvig لعدّات أخطاء التعديل الواحد، الذي يقوم بهذا مسبقًا: فهو يسرد تعديلات مثل e|i مع عدّها، جاهزة للإدخال في الجداول الأربعة. لم يكن لدى Kernighan وChurch وGale قائمة كهذه، فبدؤوا من الصفر بطريقة تمهيدية (bootstrapping): ابدأ بمصفوفات منتظمة، وصحّح مدوّنة من الكلمات المرفوضة بالنموذج الحالي، وأعد عدّ التعديلات التي تقتضيها التصحيحات، ثم كرّر. وهذه الحلقة مثال على خوارزمية EM.

Quick checkاختبار سريع

Which statement correctly reads the cell sub[e,o] = 93 on slide 21?أي عبارة تقرأ الخلية sub[e,o] = 93 في الشريحة 21 قراءة صحيحة؟

Recall

State what del[x,y], ins[x,y] and trans[x,y] count, and say what insertion and deletion are conditioned on.اذكر ما تعدّه del[x,y] وins[x,y] وtrans[x,y]، وقل على أي شيء يُشترط الإدراج والحذف.

del[x,y]: xy typed as x. ins[x,y]: x typed as xy. trans[x,y]: xy typed as yx. Insertion and deletion are conditioned on the previous character, x.
del[x,y]: xy كُتبت x. ins[x,y]: x كُتبت xy. trans[x,y]: xy كُتبت yx. والإدراج والحذف مشروطان بالحرف السابق، x.

Back to across. The count sub[e,o] = 93 on its own is not a probability: it would be large simply because o is a common letter. The fair question is: of all the times a writer meant to type o, how often did e come out? In the training text of Kernighan, Church and Gale, the letter o occurred roughly 10,000,000 times, so P(e|o) = 93 / 10,000,000 = .0000093, the across row of slide 24.

لنعد إلى across. العدّ sub[e,o] = 93 وحده ليس احتمالًا: فقد يكون كبيرًا لمجرد أن o حرف شائع. والسؤال المنصف هو: من بين كل المرات التي قصد فيها الكاتب كتابة o، كم مرة خرج e؟ في نص التدريب الخاص بـ Kernighan وChurch وGale، ظهر الحرف o قرابة 10,000,000 مرة، لذا P(e|o) = 93 / 10,000,000 = .0000093، وهو صف across في الشريحة 24.

The general rule repeats that move for each edit: divide the confusion count by the number of times the intended context occurred. The context is whatever the matrix was indexed on in the correct word, so the denominator always counts letters of w, never of x.

القاعدة العامة تكرر هذه الخطوة لكل تعديل: اقسم عدّ الالتباس على عدد مرات ظهور السياق المقصود. والسياق هو ما فُهرست عليه المصفوفة في الكلمة الصحيحة، لذا فإن المقام يعدّ دائمًا حروف w، ولا يعدّ أبدًا حروف x.

P(x∣w)={del[wi−1,wi]count[wi−1wi]if deletionins[wi−1,xi]count[wi−1]if insertionsub[xi,wi]count[wi]if substitutiontrans[wi,wi+1]count[wiwi+1]if transpositionP(x \mid w) = \begin{cases} \dfrac{\text{del}[w_{i-1}, w_i]}{\text{count}[w_{i-1} w_i]} & \text{if deletion} \\[3mm] \dfrac{\text{ins}[w_{i-1}, x_i]}{\text{count}[w_{i-1}]} & \text{if insertion} \\[3mm] \dfrac{\text{sub}[x_i, w_i]}{\text{count}[w_i]} & \text{if substitution} \\[3mm] \dfrac{\text{trans}[w_i, w_{i+1}]}{\text{count}[w_i w_{i+1}]} & \text{if transposition} \end{cases}
Channel model of Kernighan, Church and Gale (1990), slide 23; wᵢ is the ith letter of the intended word, xᵢ of the typoنموذج القناة لـ Kernighan وChurch وGale (1990)، الشريحة 23؛ wᵢ هو الحرف رقم i في الكلمة المقصودة، وxᵢ في الكلمة الخاطئة
  • Deletion divides by count[wᵢ₋₁ wᵢ], the number of times the pair that was supposed to appear actually appears, because each occurrence was a chance to drop its second letter.الحذف يقسم على count[wᵢ₋₁ wᵢ]، أي عدد مرات ظهور الزوج الذي كان يُفترض أن يظهر، لأن كل ظهور له كان فرصة لإسقاط حرفه الثاني.
  • Insertion divides by count[wᵢ₋₁], a single letter, because each occurrence of it was a chance to type something extra afterwards. The numerator ins[wᵢ₋₁, xᵢ] names the extra typed letter xᵢ.الإدراج يقسم على count[wᵢ₋₁]، أي حرف واحد، لأن كل ظهور له كان فرصة لكتابة شيء زائد بعده. والبسط ins[wᵢ₋₁, xᵢ] يسمّي الحرف الزائد المكتوب xᵢ.
  • Substitution divides by count[wᵢ], the intended letter that got replaced.الاستبدال يقسم على count[wᵢ]، أي الحرف المقصود الذي استُبدل.
  • Transposition divides by count[wᵢ wᵢ₊₁], the intended pair that got swapped.التبديل يقسم على count[wᵢ wᵢ₊₁]، أي الزوج المقصود الذي تبادل حرفاه موقعيهما.

Mapping the acress table to the formulaربط جدول acress بالصيغة

Candidateالمرشحx|wx|wEditالتعديلCell / denominatorالخلية / المقامP(x|w)P(x|w)
actressactressc|ctc|ctdeletionحذفdel[c,t] / count[ct]del[c,t] / count[ct].000117.000117
cresscressa|#a|#insertionإدراجins[#,a] / count[#]ins[#,a] / count[#].00000144.00000144
caresscaressac|caac|catranspositionتبديلtrans[c,a] / count[ca]trans[c,a] / count[ca].00000164.00000164
accessaccessr|cr|csubstitutionاستبدالsub[r,c] / count[c]sub[r,c] / count[c].000000209.000000209
acrossacrosse|oe|osubstitutionاستبدالsub[e,o] / count[o]sub[e,o] / count[o].0000093.0000093
acresacreses|ees|einsertionإدراجins[e,s] / count[e]ins[e,s] / count[e].0000321.0000321
acresacresss|sss|sinsertionإدراجins[s,s] / count[s]ins[s,s] / count[s].0000342.0000342
Each row of slide 24 as a matrix cell over a denominatorكل صف من الشريحة 24 على شكل خلية مصفوفة مقسومة على مقام

Two rows need a closer look. For cress, the a at the start of acress is the extra letter, and there is no previous letter to condition on. The model uses a word-boundary symbol #, so the entry is a|#, priced as ins[#,a] / count[#], where count[#] is the number of word starts. Acres appears twice because there are two ways to read the extra s: inserted after e (es|e) or after the existing s (ss|s). Both are valid single edits, and in the original paper each row is scored as its own transformation; the two scores for acres are kept separate rather than merged.

صفّان يحتاجان إلى نظرة أدق. في cress، يكون الحرف a في بداية acress هو الحرف الزائد، ولا يوجد حرف سابق يُشترط عليه. فيستخدم النموذج رمز حدّ الكلمة #، فيصبح المدخل a|#، ويُحسب احتماله بـ ins[#,a] / count[#]، حيث count[#] هو عدد بدايات الكلمات. وتظهر acres مرتين لأن هناك طريقتين لقراءة s الزائد: مُدرج بعد e (es|e) أو بعد s الموجود أصلًا (ss|s). كلاهما تعديل واحد صالح، وفي الورقة الأصلية يُقيَّم كل صف بوصفه تحويلًا مستقلًا؛ فتبقى درجتا acres منفصلتين ولا تُدمجان.

Worked exampleمثال محلول

Compute P(x|w) for actress and acres from the paper's countsاحسب P(x|w) للكلمتين actress وacres من عدّات الورقة

  1. actress, deletion c|ctactress، حذف c|ct

    The t after c was dropped, so look up del[c,t] = 55. The pair ct occurred about 470,000 times. P(c|ct) = 55 / 470,000 = 1.17 × 10⁻⁴ = .000117.
    سقط الحرف t بعد c، فابحث عن del[c,t] = 55. ظهر الزوج ct قرابة 470,000 مرة. P(c|ct) = 55 / 470,000 = 1.17 × 10⁻⁴ = .000117.
  2. acres, insertion es|eacres، إدراج es|e

    An s was typed after e, so look up ins[e,s] = 417. The letter e occurred about 13,000,000 times. P(es|e) = 417 / 13,000,000 = 3.21 × 10⁻⁵ = .0000321.
    كُتب s بعد e، فابحث عن ins[e,s] = 417. ظهر الحرف e قرابة 13,000,000 مرة. P(es|e) = 417 / 13,000,000 = 3.21 × 10⁻⁵ = .0000321.
  3. acres, insertion ss|sacres، إدراج ss|s

    An s was typed after s: ins[s,s] = 205 over count[s] ≈ 6,000,000 gives 3.42 × 10⁻⁵ = .0000342.
    كُتب s بعد s: ins[s,s] = 205 مقسومًا على count[s] ≈ 6,000,000 يعطي 3.42 × 10⁻⁵ = .0000342.
  4. Resultالنتيجة

    The deletion for actress is about 3.4 to 3.6 times more probable than the acres insertions, and about 12.6 times more probable than the substitution for across.
    الحذف في actress أرجح بنحو 3.4 إلى 3.6 مرة من إدراجَي acres، وأرجح بنحو 12.6 مرة من الاستبدال في across.
InteractiveتفاعليConfusion-matrix lookup for acressالبحث في مصفوفة الالتباس لكلمة acress
Pick a candidate and its editاختر مرشحًا وتعديله

P(c|ct) = del[c,t] / count[ct] = 55 / 470,000

Editdeletion
Confusion count55del[c,t]
Letter count470,000count[ct]
P(x|w)1.17e-4slide .000117

actress: del[c,t] over count[ct] gives 1.17e-4

Counts are as printed by Kernighan, Church and Gale (1990). The letter counts are rounded in the paper, yet every quotient still reproduces the value on slide 24.الأعداد كما نشرها Kernighan وChurch وGale (1990). أعداد الحروف مقرّبة في الورقة، ومع ذلك يعيد كل ناتج قسمة القيمةَ نفسها الموجودة في الشريحة 24.

Zero counts are smoothedالعدّات الصفرية تُنعَّم

Look up sub[r,c] in slide 21: row r, column c is 0. Nobody in the training data typed r for c. Yet slide 24 gives access a channel probability of .000000209, not zero. The reason is that the matrices are smoothed before use; the paper uses Good-Turing, which turns the zero into a small fractional count, about .98, over count[c] ≈ 4,700,000. Caress shows the same pattern, with a fractional count of about .95 over count[ca] ≈ 580,000. Without smoothing, one unseen confusion would veto a candidate no matter how strong its prior, which is the same zero problem n-gram models had in lecture 03.

ابحث عن sub[r,c] في الشريحة 21: الصف r والعمود c قيمته 0. لم يكتب أحد في بيانات التدريب r بدلًا من c. ومع ذلك تعطي الشريحة 24 الكلمة access احتمال قناة قدره .000000209، لا صفرًا. والسبب أن المصفوفات تُنعَّم قبل استخدامها؛ إذ تستخدم الورقة Good-Turing، الذي يحوّل الصفر إلى عدّ كسري صغير، قرابة .98، مقسومًا على count[c] ≈ 4,700,000. وتُظهر caress النمط نفسه، بعدّ كسري يقارب .95 مقسومًا على count[ca] ≈ 580,000. ومن دون تنعيم، فإن التباسًا واحدًا لم يُشاهَد سيُسقط المرشح مهما كان احتماله المسبق قويًا، وهي مشكلة الصفر نفسها التي واجهتها نماذج n-gram في المحاضرة 03.

Quick checkاختبار سريع

For the candidate acres with x|w = ss|s, which denominator does the channel formula use?للمرشح acres حيث x|w = ss|s، ما المقام الذي تستخدمه صيغة القناة؟

Quick checkاختبار سريع

Why does slide 24 give access a nonzero P(r|c) when sub[r,c] is printed as 0?لماذا تعطي الشريحة 24 الكلمة access احتمالًا P(r|c) غير صفري مع أن sub[r,c] مطبوعة 0؟

Recall

Write the denominator for each of the four edit types in the Kernighan, Church and Gale formula.اكتب المقام لكل نوع من أنواع التعديل الأربعة في صيغة Kernighan وChurch وGale.

Deletion: count[wᵢ₋₁ wᵢ]. Insertion: count[wᵢ₋₁]. Substitution: count[wᵢ]. Transposition: count[wᵢ wᵢ₊₁]. All count letters of the intended word.
الحذف: count[wᵢ₋₁ wᵢ]. الإدراج: count[wᵢ₋₁]. الاستبدال: count[wᵢ]. التبديل: count[wᵢ wᵢ₊₁]. وكلها تعدّ حروف الكلمة المقصودة.

Recall

For cress, why is the entry written a|# and what is its denominator?في cress، لماذا يُكتب المدخل a|# وما مقامه؟

The extra a sits at the start of the word, so there is no previous letter; the word-boundary symbol # plays that role. It is an insertion, ins[#,a] / count[#], where count[#] is the number of word starts.
الحرف a الزائد يقع في بداية الكلمة، فلا يوجد حرف سابق؛ ويؤدي رمز حدّ الكلمة # هذا الدور. وهو إدراج، ins[#,a] / count[#]، حيث count[#] هو عدد بدايات الكلمات.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • The prior P(w) comes from any language model; the unigram version is C(w)/N, for example P(actress) = 9,321 / 404,253,213 = .0000231.يأتي الاحتمال المسبق P(w) من أي نموذج لغوي؛ ونسخته أحادية الكلمة هي C(w)/N، فمثلًا P(actress) = 9,321 / 404,253,213 = .0000231.
  • Unigram priors ignore context, so across (120,844) beats actress (9,321) by a factor of about 13 before the typo is even considered.الاحتمالات المسبقة أحادية الكلمة تتجاهل السياق، لذلك تتفوق across (120,844) على actress (9,321) بعامل يقارب 13 قبل أن يُنظر إلى الخطأ الإملائي أصلًا.
  • The channel model P(x|w) is the probability of the single edit that turns the intended word w into the typed string x.نموذج القناة P(x|w) هو احتمال التعديل الواحد الذي يحوّل الكلمة المقصودة w إلى السلسلة المكتوبة x.
  • del[x,y] = count(xy typed as x), ins[x,y] = count(x typed as xy), trans[x,y] = count(xy typed as yx); insertion and deletion are conditioned on the previous character.del[x,y] = count(xy كُتبت x)، وins[x,y] = count(x كُتبت xy)، وtrans[x,y] = count(xy كُتبت yx)؛ والإدراج والحذف مشروطان بالحرف السابق.
  • sub[x,y] is indexed typed letter first, intended letter second: sub[e,o] = 93 means e was typed where o was meant.تُفهرس sub[x,y] بالحرف المكتوب أولًا ثم الحرف المقصود ثانيًا: sub[e,o] = 93 تعني أن e كُتب حيث كان المقصود o.
  • P(x|w) = confusion count / count of the intended context: count[w_{i-1} w_i] for deletion, count[w_{i-1}] for insertion, count[w_i] for substitution, count[w_i w_{i+1}] for transposition.P(x|w) = عدّ الالتباس / عدّ السياق المقصود: count[w_{i-1} w_i] للحذف، وcount[w_{i-1}] للإدراج، وcount[w_i] للاستبدال، وcount[w_i w_{i+1}] للتبديل.
  • Word start is the symbol #, so cress gives a|# = ins[#,a] / count[#].بداية الكلمة هي الرمز #، لذلك تعطي cress القيمة a|# = ins[#,a] / count[#].
  • Confusion counts are smoothed before use, which is why sub[r,c] = 0 in the matrix still yields P(r|c) = .000000209.تُنعَّم عدّات الالتباس قبل استخدامها، ولهذا فإن sub[r,c] = 0 في المصفوفة تعطي مع ذلك P(r|c) = .000000209.

Sourcesالمصادر

Part 05: Scoring acress: unigram vs bigram contextتقييم acress: سياق unigram مقابل bigram

Multiply channel and prior for every candidate, see the unigram model pick across, then watch a bigram context flip the answer to actress, and how such systems are evaluated.نضرب احتمال القناة في الاحتمال المسبق لكل مرشح، فنرى نموذج unigram يختار across، ثم نشاهد سياق bigram يقلب الإجابة إلى actress، وكيف تُقيَّم مثل هذه الأنظمة.

3 concepts3 مفاهيم, ، slides 25-29الشرائح 25-29

Why this part mattersلماذا يهمّ هذا الجزء

Parts 03 and 04 built the two halves of the noisy channel for the misspelling acress: a list of six candidate words, a channel probability for each edit, and a prior for each word. This part finally multiplies them together. The result is a lesson every NLP student remembers: the model, done carefully, picks the wrong word, and a single bigram of context is enough to fix it.

The ideas come in three steps. First, score every candidate with a unigram prior and see across beat actress by a hair. Second, swap the unigram for a bigram language model and watch the context word whose pull actress far ahead. Third, see how such correctors are measured on public lists of real misspellings. For the exam, the skill is arithmetic with very small numbers: write every factor, multiply, keep the powers of ten straight, and compare.

بنى الجزءان 03 و04 نصفَي القناة المشوشة للخطأ الإملائي acress: قائمة من ستة مرشّحين، واحتمال قناة لكل تعديل، واحتمال مسبق لكل كلمة. وفي هذا الجزء نضربهما معًا أخيرًا. والنتيجة درس يتذكره كل طالب NLP: النموذج، حتى حين يُطبَّق بعناية، يختار الكلمة الخاطئة، وbigram واحد من السياق يكفي لإصلاح ذلك.

تأتي الأفكار في ثلاث خطوات. أولًا، نقيّم كل مرشّح باحتمال مسبق أحادي الكلمة (unigram) فنرى across تتفوق على actress بفارق شعرة. ثانيًا، نستبدل الـ unigram بنموذج لغة ثنائي الكلمات (bigram) ونشاهد كلمة السياق whose تسحب actress بعيدًا إلى الأمام. ثالثًا، نرى كيف تُقاس هذه المصحّحات على قوائم عامة من أخطاء إملائية حقيقية. والمهارة المطلوبة في الامتحان هي الحساب بأعداد صغيرة جدًا: اكتب كل عامل، واضرب، وحافظ على قوى العشرة صحيحة، ثم قارن.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Fill in the noisy channel table for acress: multiply P(x|w) by P(w) for every candidate and rank them.تملأ جدول القناة المشوشة للكلمة acress: تضرب P(x|w) في P(w) لكل مرشّح ثم ترتّب المرشّحين.
  2. Explain why the unigram model picks across, and why that answer is wrong in context.تشرح لماذا يختار النموذج أحادي الكلمة (unigram) الكلمة across، ولماذا تكون هذه الإجابة خاطئة في السياق.
  3. Replace the unigram prior with bigram probabilities on both sides of the error and recompute the decision.تستبدل الاحتمال المسبق أحادي الكلمة باحتمالات ثنائية الكلمات (bigram) على جانبي الخطأ وتعيد حساب القرار.
  4. Combine channel and bigram scores into one product, state by what factor actress wins, and avoid counting P(w) twice.تجمع درجة القناة ودرجة الـ bigram في حاصل ضرب واحد، وتذكر بأي عامل تفوز actress، وتتجنب احتساب P(w) مرتين.
  5. Name the standard spelling error test sets and explain how to split them for training, tuning and testing.تسمّي مجموعات الاختبار القياسية لأخطاء الإملاء وتشرح كيف تُقسَّم للتدريب والضبط والاختبار.

Take the acress example. Candidate generation gave us actress, cress, caress, access, across and acres, each one edit away from the typed string. Two candidates look strong to a human: actress, if a t was dropped, and across, if an o was typed as an e. Which one should a machine choose?

خذ مثال acress. أعطانا توليد المرشّحين الكلمات actress وcress وcaress وaccess وacross وacres، وكل منها على بُعد تعديل واحد من السلسلة المكتوبة. يبدو مرشّحان قويين للإنسان: actress إذا سقط حرف t، وacross إذا كُتب حرف o على أنه e. فأيهما يجب أن تختار الآلة؟

The score is a product of two columnsالدرجة حاصل ضرب عمودين

The noisy channel model answers by Bayes. For each candidate w it multiplies two numbers. The channel model P(x|w) says how likely the typist was to produce acress when they meant w; it comes from the Kernighan, Church and Gale confusion matrices. The prior P(w) says how likely w is in the first place. Here the prior is a unigram prior: the word's count in COCA divided by the corpus size. The decision is the argmax of the product.

يجيب نموذج القناة المشوشة (noisy channel model) بقاعدة بايز. فلكل مرشّح w يضرب عددين. نموذج القناة (channel model) P(x|w) يقول ما مدى احتمال أن يكتب الكاتب acress وهو يقصد w، ويأتي من مصفوفات الالتباس (confusion matrices) عند Kernighan, Church and Gale. أما الاحتمال المسبق (prior) P(w) فيقول ما مدى احتمال w أصلًا. والاحتمال المسبق هنا احتمال مسبق أحادي الكلمة (unigram prior): عدد مرات ظهور الكلمة في COCA مقسومًا على حجم المدوّنة. والقرار هو argmax لحاصل الضرب.

w^=argmax⁡w∈C  P(x∣w) P(w)\hat{w} = \operatorname*{argmax}_{w \in C} \; P(x \mid w)\, P(w)
Unigram noisy channel decision over the candidate set Cقرار القناة المشوشة بنموذج unigram على مجموعة المرشحين C

The table below is that product for every candidate. The edit column uses the slide's x|w notation: typed letters on the left, intended letters on the right. So c|ct is a deletion (the t after c was lost), e|o is a substitution, ac|ca is a transposition, and both acres rows are an insertion of an extra s. The last column is multiplied by 10⁹ only to make the tiny products readable.

الجدول التالي هو حاصل الضرب هذا لكل مرشّح. يستخدم عمود التعديل ترميز الشريحة x|w: الحروف المكتوبة على اليسار والحروف المقصودة على اليمين. فـ c|ct هو حذف (deletion) (ضاع حرف t بعد c)، وe|o هو استبدال (substitution)، وac|ca هو تبديل مواقع (transposition)، وكلا صفَّي acres هما إدراج (insertion) لحرف s زائد. والعمود الأخير مضروب في 10⁹ فقط لتسهيل قراءة حواصل الضرب الصغيرة جدًا.

CandidateالمرشّحEdit x|wالتعديل x|wP(x|w)P(x|w)P(w)P(w)10⁹ × product10⁹ × حاصل الضرب
actressactressc|ctc|ct.000117.000117.0000231.00002312.702.70
cresscressa|#a|#.00000144.00000144.000000544.000000544.00078.00078
caresscaressac|caac|ca.00000164.00000164.00000170.00000170.0028.0028
accessaccessr|cr|c.000000209.000000209.0000916.0000916.019.019
acrossacrosse|oe|o.0000093.0000093.000299.0002992.782.78
acresacreses|ees|e.0000321.0000321.0000318.00003181.021.02
acresacresss|sss|s.0000342.0000342.0000318.00003181.091.09
Noisy channel scores for acress with a unigram prior (last column is 10⁹ × P(x|w) P(w), recomputed to three figures)درجات القناة المشوشة للكلمة acress مع احتمال مسبق أحادي الكلمة (العمود الأخير هو 10⁹ × P(x|w) P(w)، مُعاد حسابه بثلاثة أرقام)

Worked exampleمثال محلول

The two leaders, multiplied outالمتصدّران، بعد إجراء الضرب

  1. actressactress

    P(x|w) × P(w) = .000117 × .0000231. Write both in scientific form: 1.17 × 10⁻⁴ × 2.31 × 10⁻⁵ = 2.70 × 10⁻⁹. The channel term is large (dropping a t after c is a common slip) but actress is a fairly rare word.
    P(x|w) × P(w) = .000117 × .0000231. اكتب العددين بالصيغة العلمية: 1.17 × 10⁻⁴ × 2.31 × 10⁻⁵ = 2.70 × 10⁻⁹. حدّ القناة كبير (إسقاط حرف t بعد c زلّة شائعة)، لكن actress كلمة نادرة نسبيًا.
  2. acrossacross

    .0000093 × .000299 = 9.3 × 10⁻⁶ × 2.99 × 10⁻⁴ = 2.78 × 10⁻⁹. The channel term is about 12 times smaller than actress's, but across is about 13 times more frequent, so the prior almost exactly cancels the channel.
    .0000093 × .000299 = 9.3 × 10⁻⁶ × 2.99 × 10⁻⁴ = 2.78 × 10⁻⁹. حدّ القناة أصغر بنحو 12 مرة من حدّ actress، لكن across أكثر شيوعًا بنحو 13 مرة، فيكاد الاحتمال المسبق يلغي أثر القناة تمامًا.
  3. Compareالمقارنة

    2.78 / 2.70 ≈ 1.03. across leads by about 3%. Every other row scores less than half of across, so the race is between these two.
    2.78 / 2.70 ≈ 1.03. تتقدم across بنحو 3%. وكل صف آخر يحصل على أقل من نصف درجة across، فالسباق محصور بين هاتين الكلمتين.
  4. Resultالنتيجة

    The unigram noisy channel chooses across, with actress a close second.
    القناة المشوشة أحادية الكلمة تختار across، وتأتي actress في المرتبة الثانية بفارق ضئيل.
A photo finish on a log scale: across and actress end almost at the same line, acres trails at about 1, and access, caress and cress are two to three orders of magnitude behind.نهاية متقاربة على مقياس لوغاريتمي: تنتهي across و actress تقريبًا عند الخط نفسه، وتتأخر acres عند نحو 1، بينما تتأخر access و caress و cress بمرتبتين إلى ثلاث مراتب عشرية.

Why the answer is wrong, and what the model could not seeلماذا الإجابة خاطئة، وما الذي لم يستطع النموذج رؤيته

The sentence this misspelling came from reads "a stellar and versatile acress whose combination of sass and glamour". Any reader knows the writer meant actress. The model chose across because its prior asks only how common a word is in general, and across is a very common word. Nothing in P(w) looks at the neighbors. The two factors also see different evidence: the channel looks at letters, the prior at word frequency, and neither one looks at the sentence.

الجملة التي جاء منها هذا الخطأ الإملائي هي "a stellar and versatile acress whose combination of sass and glamour". وأي قارئ يعرف أن الكاتب قصد actress. اختار النموذج across لأن احتماله المسبق لا يسأل إلا عن مدى شيوع الكلمة عمومًا، وacross كلمة شائعة جدًا. لا شيء في P(w) ينظر إلى الكلمات المجاورة. كما أن العاملين يريان أدلة مختلفة: القناة تنظر إلى الحروف، والاحتمال المسبق إلى تكرار الكلمة، ولا أحد منهما ينظر إلى الجملة.

Recall

Compute 10⁹ × P(x|w)P(w) for actress and for across, and say which the unigram model picks.احسب 10⁹ × P(x|w)P(w) لكل من actress و across، وقل أيهما يختار النموذج أحادي الكلمة.

actress: .000117 × .0000231 = 2.70 × 10⁻⁹, so 2.70. across: .0000093 × .000299 = 2.78 × 10⁻⁹, so 2.78. The unigram model picks across by about 3%.
actress: .000117 × .0000231 = 2.70 × 10⁻⁹، أي 2.70. across: .0000093 × .000299 = 2.78 × 10⁻⁹، أي 2.78. يختار النموذج أحادي الكلمة across بفارق نحو 3%.

Quick checkاختبار سريع

Using only the unigram prior, which candidate does the noisy channel choose for acress?باستخدام الاحتمال المسبق أحادي الكلمة وحده، أي مرشّح تختاره القناة المشوشة للكلمة acress؟

Put acress back in its sentence: "versatile acress whose". Ask two questions a reader asks without thinking. Does the candidate follow versatile naturally? Does whose follow the candidate naturally? A versatile actress whose career is a normal phrase. A versatile across whose is not English.

أعد acress إلى جملتها: "versatile acress whose". واطرح سؤالين يطرحهما القارئ دون تفكير. هل يأتي المرشّح بعد versatile بشكل طبيعي؟ وهل تأتي whose بعد المرشّح بشكل طبيعي؟ عبارة "a versatile actress whose career" عبارة عادية، أما "a versatile across whose" فليست إنجليزية.

Replace P(w) with the bigrams on both sidesاستبدل P(w) بالـ bigrams على الجانبين

A bigram language model turns those two questions into numbers. The candidate sits between two bigrams, one with the word before it and one with the word after it, so the prior for the candidate in this position is P(w | versatile) × P(whose | w). The counts come from COCA with add-1 smoothing, so a bigram never seen in the corpus still gets a small nonzero probability.

يحوّل نموذج اللغة ثنائي الكلمات (bigram language model) هذين السؤالين إلى أرقام. يقع المرشّح بين اثنين من الـ bigrams: واحد مع الكلمة التي قبله وواحد مع الكلمة التي بعده، لذا فإن الاحتمال المسبق للمرشّح في هذا الموضع هو P(w | versatile) × P(whose | w). وتأتي الأعداد من COCA مع التنعيم بإضافة واحد (add-1 smoothing)، فيحصل حتى الـ bigram الذي لم يظهر قط في المدوّنة على احتمال صغير غير صفري.

w^=argmax⁡w∈C  P(x∣w)  P(wi=w∣wi−1)  P(wi+1∣wi=w)\hat{w} = \operatorname*{argmax}_{w \in C} \; P(x \mid w)\; P(w_i = w \mid w_{i-1})\; P(w_{i+1} \mid w_i = w)
Bigram noisy channel: the channel term times the bigrams into and out of the corrected positionالقناة المشوشة بنموذج bigram: حد القناة مضروبًا في bigrams الداخلة إلى الموضع المصحَّح والخارجة منه
  • P(actress | versatile) = .000021 and P(across | versatile) = .000021. The left bigram is a tie, so it tells the two candidates apart not at all.P(actress | versatile) = .000021 وP(across | versatile) = .000021. الـ bigram الأيسر متعادل، فلا يميّز بين المرشّحين على الإطلاق.
  • P(whose | actress) = .0010 and P(whose | across) = .000006. The right bigram is where the evidence lives: whose follows a person noun often and follows a preposition almost never.P(whose | actress) = .0010 وP(whose | across) = .000006. الـ bigram الأيمن هو مكان الدليل: تأتي whose كثيرًا بعد اسم يدل على شخص، ولا تأتي تقريبًا أبدًا بعد حرف جر.
Both candidates connect to versatile equally well. Only actress connects to whose: its right arc is thick (.0010) while across has a hairline (.000006).يرتبط المرشّحان بـ versatile بالقدر نفسه. وحدها actress ترتبط بـ whose: قوسها الأيمن سميك (.0010) بينما لـ across خيط رفيع (.000006).

Worked exampleمثال محلول

Language model alone, as on the slideنموذج اللغة وحده، كما في الشريحة

  1. actress in contextactress في السياق

    P("versatile actress whose") = .000021 × .0010 = 2.1 × 10⁻⁸ = 210 × 10⁻¹⁰.
    P("versatile actress whose") = .000021 × .0010 = 2.1 × 10⁻⁸ = 210 × 10⁻¹⁰.
  2. across in contextacross في السياق

    P("versatile across whose") = .000021 × .000006 = 1.26 × 10⁻¹⁰, which the slide rounds to 1 × 10⁻¹⁰.
    P("versatile across whose") = .000021 × .000006 = 1.26 × 10⁻¹⁰، وتقرّبها الشريحة إلى 1 × 10⁻¹⁰.
  3. Resultالنتيجة

    The context alone favors actress by 2.1 × 10⁻⁸ / 1.26 × 10⁻¹⁰ ≈ 167 times.
    السياق وحده يرجّح actress بـ 2.1 × 10⁻⁸ / 1.26 × 10⁻¹⁰ ≈ 167 مرة.

The slides stop at the language model numbers. Jurafsky and Martin's appendix, where this example comes from, adds one sentence: combining the language model with the error model, the bigram noisy channel now chooses actress. That combining step multiplies by the channel term P(x|w). Here it is.

تتوقف الشرائح عند أرقام نموذج اللغة. أما ملحق Jurafsky and Martin، الذي أُخذ منه هذا المثال، فيضيف جملة واحدة: بدمج نموذج اللغة مع نموذج الخطأ، تختار القناة المشوشة ثنائية الكلمات الآن actress. وخطوة الدمج هذه تعني الضرب في حدّ القناة P(x|w). وإليك هذه الخطوة.

Worked exampleمثال محلول

Full bigram noisy channel score, the step the slides skipالدرجة الكاملة للقناة المشوشة ثنائية الكلمات، الخطوة التي تتخطاها الشرائح

  1. actressactress

    P(x|w) × P(actress | versatile) × P(whose | actress) = .000117 × .000021 × .0010. In scientific form: 1.17 × 10⁻⁴ × 2.1 × 10⁻⁸ = 2.46 × 10⁻¹².
    P(x|w) × P(actress | versatile) × P(whose | actress) = .000117 × .000021 × .0010. وبالصيغة العلمية: 1.17 × 10⁻⁴ × 2.1 × 10⁻⁸ = 2.46 × 10⁻¹².
  2. acrossacross

    .0000093 × .000021 × .000006 = 9.3 × 10⁻⁶ × 1.26 × 10⁻¹⁰ = 1.17 × 10⁻¹⁵.
    .0000093 × .000021 × .000006 = 9.3 × 10⁻⁶ × 1.26 × 10⁻¹⁰ = 1.17 × 10⁻¹⁵.
  3. Compareالمقارنة

    2.46 × 10⁻¹² / 1.17 × 10⁻¹⁵ ≈ 2,100. That is the context ratio (≈167) times the channel ratio (.000117 / .0000093 ≈ 12.6).
    2.46 × 10⁻¹² / 1.17 × 10⁻¹⁵ ≈ 2,100. وهذا هو نسبة السياق (≈167) مضروبة في نسبة القناة (.000117 / .0000093 ≈ 12.6).
  4. Resultالنتيجة

    The bigram noisy channel chooses actress by about 2,100 times. The 3% unigram lead of across is gone.
    القناة المشوشة ثنائية الكلمات تختار actress بنحو 2,100 مرة. وقد اختفى تقدّم across البالغ 3% في النموذج أحادي الكلمة.
SimulatorمحاكيScore acress with a unigram or a bigram priorقيّم acress باحتمال مسبق unigram أو bigram

Score P(x|w) × P(w) for every candidate. Each row lists its factors, and the bar is on a log scale.احسب الدرجة P(x|w) × P(w) لكل مرشح. يعرض كل صف عوامله، والشريط على مقياس لوغاريتمي.

  1. acrosse|o2.78 × 10-9.00000930 × .000299
  2. actressc|ct2.70 × 10-9.000117 × .0000231
  3. acresss|s1.09 × 10-9.0000342 × .0000318
  4. acreses|e1.02 × 10-9.0000321 × .0000318
  5. accessr|c1.91 × 10-11.000000209 × .0000916
  6. caressac|ca2.79 × 10-12.00000164 × .00000170
  7. cressa|#7.83 × 10-13.00000144 × .000000544
Winneracross2.78 × 10-9
Runner-upactress2.70 × 10-9
Margin1.03×winner score ÷ runner-up scoreدرجة الفائز ÷ درجة الوصيف
Unigram priorالاحتمال المسبق أحادي الكلمة (unigram)Bigram contextسياق ثنائي الكلمات (bigram)
Prior factorعامل الاحتمال المسبقP(w)P(w)P(w | versatile) × P(whose | w)P(w | versatile) × P(whose | w)
What it knowsما الذي يعرفهHow common the word is anywhere in COCAمدى شيوع الكلمة في أي مكان من COCAHow well the word fits between its actual neighborsمدى اتّساق الكلمة بين جارتيها الفعليتين
actress scoreدرجة actress2.70 × 10⁻⁹2.70 × 10⁻⁹2.46 × 10⁻¹²2.46 × 10⁻¹²
across scoreدرجة across2.78 × 10⁻⁹2.78 × 10⁻⁹1.17 × 10⁻¹⁵1.17 × 10⁻¹⁵
Decisionالقرارacross, by about 3%across، بفارق نحو 3%actress, by about 2,100 timesactress، بنحو 2,100 مرة
Unigram and bigram priors on the same two candidatesالاحتمال المسبق أحادي الكلمة وثنائي الكلمات على المرشّحين أنفسهما

Recall

Which bigram decides between actress and across, and what are its two values?أي bigram يحسم الاختيار بين actress و across، وما قيمتاه؟

The right-hand bigram into whose: P(whose | actress) = .0010 against P(whose | across) = .000006. The left bigram from versatile is .000021 for both, so it cancels.
الـ bigram الأيمن الداخل إلى whose: P(whose | actress) = .0010 مقابل P(whose | across) = .000006. أما الـ bigram الأيسر من versatile فقيمته .000021 للاثنين، فيلغي أحدهما الآخر.

Recall

Compute the full bigram noisy channel score for actress and across, and the ratio.احسب الدرجة الكاملة للقناة المشوشة ثنائية الكلمات لكل من actress و across، والنسبة بينهما.

actress: .000117 × .000021 × .0010 = 2.46 × 10⁻¹². across: .0000093 × .000021 × .000006 = 1.17 × 10⁻¹⁵. actress wins by about 2,100 times, the context ratio 167 times the channel ratio 12.6.
actress: .000117 × .000021 × .0010 = 2.46 × 10⁻¹². across: .0000093 × .000021 × .000006 = 1.17 × 10⁻¹⁵. تفوز actress بنحو 2,100 مرة، وهي نسبة السياق 167 مضروبة في نسبة القناة 12.6.

Quick checkاختبار سريع

Using the unrounded bigram probabilities on slide 27, by roughly what factor does the context alone favor actress over across?باستخدام احتمالات الـ bigram غير المقرَّبة في الشريحة 27، بأي عامل تقريبًا يرجّح السياق وحده actress على across؟

One sentence about an actress proves nothing about a corrector. To know whether the bigram model is better in general, you run it on thousands of real misspellings whose intended word is known and count how often the top suggestion is right.

جملة واحدة عن ممثلة لا تثبت شيئًا عن المصحّح. ولكي تعرف هل نموذج الـ bigram أفضل بشكل عام، تشغّله على آلاف الأخطاء الإملائية الحقيقية التي تُعرف كلمتها المقصودة، وتعدّ كم مرة يكون الاقتراح الأول صحيحًا.

Where the misspellings come fromمن أين تأتي الأخطاء الإملائية

A spelling error test set is a list of pairs: what was typed, and what was meant. The slide names four public ones. They differ in size and in where the errors came from, and that matters: typing slips on a keyboard and handwritten spelling-test mistakes by schoolchildren are different error distributions, and a channel model trained on one may do poorly on the other.

مجموعة اختبار أخطاء الإملاء (spelling error test set) هي قائمة من الأزواج: ما كُتب، وما كان مقصودًا. تذكر الشريحة أربع مجموعات عامة منها. وهي تختلف في الحجم وفي مصدر الأخطاء، وهذا مهم: زلّات الكتابة على لوحة المفاتيح وأخطاء التلاميذ في اختبارات الإملاء المكتوبة بخط اليد هي توزيعات أخطاء مختلفة، ونموذج القناة المدرَّب على أحدها قد يؤدي أداءً ضعيفًا على الآخر.

Test setمجموعة الاختبارWhat it isما هيSizeالحجم
Wikipedia list of common misspellingsقائمة ويكيبيديا للأخطاء الإملائية الشائعةPairs collected by Wikipedia editors, one misspelling to one or more correctionsأزواج جمعها محررو ويكيبيديا، كل خطأ إملائي مقابل تصحيح واحد أو أكثر2,455 misspellings of 1,922 words (Mitton's processed copy)2,455 خطأ إملائيًا لـ 1,922 كلمة (النسخة المعالجة لدى Mitton)
Aspell filtered listالقائمة المفلترة عبر AspellA test set Atkinson built to test the GNU Aspell checkerمجموعة اختبار بناها Atkinson لاختبار المدقق GNU Aspell531 misspellings of 450 words531 خطأ إملائيًا لـ 450 كلمة
Birkbeck spelling error corpusمدوّنة Birkbeck لأخطاء الإملاءMitton's collection, mostly handwritten errors from school pupils, students and adult literacy learnersمجموعة Mitton، ومعظمها أخطاء مكتوبة بخط اليد من تلاميذ المدارس وطلاب الجامعات ومتعلمي محو الأمية من الكبار36,133 misspellings of 6,136 words36,133 خطأ إملائيًا لـ 6,136 كلمة
Norvig's listقائمة NorvigNorvig's bundle that includes the Wikipedia and Birkbeck data, offered for training or testingحزمة Norvig التي تتضمن بيانات ويكيبيديا وBirkbeck، وتُقدَّم للتدريب أو الاختبارCombines the sources aboveتجمع المصادر السابقة
The four test sets on slide 29مجموعات الاختبار الأربع في الشريحة 29

How to use them honestlyكيف تستخدمها بنزاهة

The lists serve two roles. Training data gives the counts for the confusion matrices. Test data measures the finished system. Keep them apart, and hold out a third slice, the development test set, for tuning choices such as the lambda weighting you will meet in part 07. Norvig did exactly this with Birkbeck: he developed on 270 misspellings and reported the final number on a separate 400, scoring 75% on the first and 68% on the second. The gap shows how much a score measured on the data you tuned on overstates real performance.

تؤدي هذه القوائم دورين. بيانات التدريب تعطي الأعداد لمصفوفات الالتباس، وبيانات الاختبار تقيس النظام النهائي. افصل بينهما، واحجز شريحة ثالثة هي مجموعة اختبار التطوير (development test set) لضبط الخيارات مثل ترجيح lambda الذي ستقابله في الجزء 07. وهذا بالضبط ما فعله Norvig مع Birkbeck: طوّر على 270 خطأ إملائيًا وأعلن الرقم النهائي على 400 منفصلة، فحصل على 75% في الأولى و68% في الثانية. ويُظهر هذا الفارق كم تبالغ الدرجة المقيسة على البيانات التي ضبطت عليها في تقدير الأداء الحقيقي.

Each known misspelling pair goes to exactly one bucket: train for counts, dev for tuning, test for the number you report.كل زوج خطأ إملائي معروف يذهب إلى سلة واحدة فقط: train للأعداد، و dev للضبط، و test للرقم الذي تعلنه.

Recall

Name the four test sets on slide 29 and one fact about each.سمِّ مجموعات الاختبار الأربع في الشريحة 29 واذكر معلومة واحدة عن كل منها.

Wikipedia's list of common misspellings (editor-collected pairs); its Aspell-filtered version (the GNU Aspell test set, 531 misspellings); the Birkbeck corpus (Mitton, about 36,000 misspellings, mostly handwritten); Norvig's list, which includes Wikipedia and Birkbeck and is offered for training or testing.
قائمة ويكيبيديا للأخطاء الإملائية الشائعة (أزواج جمعها المحررون)؛ ونسختها المفلترة عبر Aspell (مجموعة اختبار GNU Aspell، 531 خطأ إملائيًا)؛ ومدوّنة Birkbeck (Mitton، نحو 36,000 خطأ إملائي، معظمها مكتوب بخط اليد)؛ وقائمة Norvig التي تتضمن ويكيبيديا وBirkbeck وتُقدَّم للتدريب أو الاختبار.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • The noisy channel score for a candidate w is P(x|w) × P(w). Multiply the two columns, then rank.درجة القناة المشوشة لمرشّح w هي P(x|w) × P(w). اضرب العمودين ثم رتّب.
  • With a unigram prior, across (2.78 × 10^-9) edges out actress (2.70 × 10^-9), a 3% margin. The model picks across, and it is wrong.مع احتمال مسبق أحادي الكلمة تتقدم across (2.78 × 10^-9) بفارق ضئيل على actress (2.70 × 10^-9)، بهامش 3%. يختار النموذج across، وهو مخطئ.
  • Two derivations of acres (es|e and ss|s) can be summed to about 2.1 × 10^-9. acres still loses.يمكن جمع اشتقاقَي acres (es|e و ss|s) لنحصل على نحو 2.1 × 10^-9. ومع ذلك تبقى acres خاسرة.
  • A bigram prior scores the candidate against both neighbors: P(w | versatile) × P(whose | w).الاحتمال المسبق ثنائي الكلمات يقيّم المرشّح مقابل جاريه كليهما: P(w | versatile) × P(whose | w).
  • P(whose | actress) = .0010 against P(whose | across) = .000006. That right-hand bigram does all the work.P(whose | actress) = .0010 مقابل P(whose | across) = .000006. هذا الـ bigram الأيمن يقوم بكل العمل.
  • Context alone favors actress by about 167 times (2.1 × 10^-8 against 1.26 × 10^-10; the slide rounds the second to 1 × 10^-10).السياق وحده يرجّح actress بنحو 167 مرة (2.1 × 10^-8 مقابل 1.26 × 10^-10، والشريحة تقرّب الثاني إلى 1 × 10^-10).
  • Full bigram noisy channel P(x|w) P(w|versatile) P(whose|w): actress 2.46 × 10^-12 against across 1.17 × 10^-15, so actress wins by about 2,100 times.القناة المشوشة الكاملة بالـ bigram هي P(x|w) P(w|versatile) P(whose|w): actress تساوي 2.46 × 10^-12 مقابل 1.17 × 10^-15 لـ across، فتفوز actress بنحو 2,100 مرة.
  • Evaluate on real misspelling lists: Wikipedia's list, its Aspell-filtered version, the Birkbeck corpus, and Norvig's collection, split into train, dev and test.قيّم على قوائم أخطاء إملائية حقيقية: قائمة ويكيبيديا، ونسختها المفلترة عبر Aspell، ومدوّنة Birkbeck، ومجموعة Norvig، مقسّمة إلى تدريب وتطوير واختبار.

Sourcesالمصادر

Part 06: Real-word spelling errorsأخطاء الكلمات الحقيقية

Errors that are themselves dictionary words, why they are common, and the candidate-set recipe that treats every word in the sentence as possibly wrong.أخطاء تكون هي نفسها كلمات موجودة في القاموس، ولماذا هي شائعة، وطريقة مجموعة المرشحين التي تعامل كل كلمة في الجملة على أنها قد تكون خاطئة.

3 concepts3 مفاهيم, ، slides 30-33الشرائح 30-33

Why this part mattersلماذا يهمّ هذا الجزء

Everything so far in this lecture assumed the typo was obvious: acress is not English, so we knew exactly which token to fix. This part removes that comfort. Some typos produce a different, perfectly valid word, and a large share of real errors are like that. A spell checker that only looks words up in a list will wave every one of them through.

The ideas build in three steps. First, what these errors look like and why lookup is blind to them. Second, how to build a candidate set when you do not know which word is wrong. Third, how the noisy channel scores whole sentences instead of single words. For the exam, expect to classify the edit behind a real-word error, to write a candidate set, and to explain why the original word must stay in it. For research, this is the point where spelling correction stops being a lookup problem and becomes a language modeling problem, the same move that grammar checkers and modern neural correctors make.

كل ما سبق في هذه المحاضرة افترض أن الخطأ المطبعي واضح: acress ليست كلمة إنجليزية، فكنا نعرف بالضبط أي token نصلحه. هذا الجزء يزيل تلك الراحة. بعض الأخطاء المطبعية تنتج كلمة مختلفة صحيحة تمامًا، ونسبة كبيرة من الأخطاء الحقيقية من هذا النوع. والمدقق الإملائي الذي يكتفي بالبحث عن الكلمات في قائمة سيُمرر كل واحد منها دون أن يلاحظه.

تُبنى الأفكار على ثلاث خطوات. أولًا، كيف تبدو هذه الأخطاء ولماذا يعجز البحث في القاموس عن رؤيتها. ثانيًا، كيف نبني مجموعة المرشحين (candidate set) حين لا نعرف أي كلمة هي الخاطئة. ثالثًا، كيف تُقيّم القناة المشوشة (noisy channel) جملًا كاملة بدل كلمات منفردة. في الاختبار، توقّع أن يُطلب منك تصنيف التعديل وراء خطأ كلمة حقيقية، وكتابة مجموعة مرشحين، وشرح لماذا يجب أن تبقى الكلمة الأصلية فيها. ومن جهة البحث العلمي، هذه هي النقطة التي يتوقف فيها التصحيح الإملائي عن كونه مسألة بحث في قاموس ويصبح مسألة نمذجة لغوية (language modeling)، وهي النقلة نفسها التي تقوم بها مدققات القواعد والمصححات العصبية الحديثة.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Define a real-word error and explain why dictionary lookup can never detect one.تعريف خطأ الكلمة الحقيقية (real-word error) وشرح لماذا لا يستطيع البحث في القاموس اكتشافه أبدًا.
  2. Name the single edit behind each of the four classic examples: minuets, an, lave and be.تسمية التعديل الواحد وراء كل مثال من الأمثلة الكلاسيكية الأربعة: minuets و an و lave و be.
  3. Build the candidate set for a word: the word itself, its one-edit dictionary neighbors, and its homophones.بناء مجموعة المرشحين (candidate set) لكلمة ما: الكلمة نفسها، وجيرانها في القاموس على بعد تعديل واحد، وكلماتها المتجانسة صوتيًا (homophones).
  4. Explain why the search moves from one word to the whole sentence, and why the typed word must stay a candidate.شرح لماذا ينتقل البحث من كلمة واحدة إلى الجملة كلها، ولماذا يجب أن تبقى الكلمة المكتوبة ضمن المرشحين.
  5. Write the sentence-level noisy channel objective and say what the slide's P(W) leaves out.كتابة هدف القناة المشوشة (noisy channel) على مستوى الجملة، وتوضيح ما يُغفله P(W) في الشريحة.

Read this sentence once at normal speed: “The study was conducted mainly be John Black.” Most readers stumble on be and silently read by. Now give the same sentence to a program that checks each token against an English word list. The, study, was, conducted, mainly, be, John, Black: every one is in the list. The program reports zero errors.

اقرأ هذه الجملة مرة واحدة بسرعتك العادية: «The study was conducted mainly be John Black.». معظم القراء يتعثرون عند be ويقرؤونها في أذهانهم by دون أن يشعروا. والآن أعطِ الجملة نفسها لبرنامج يتحقق من كل token في قائمة كلمات إنجليزية. The، study، was، conducted، mainly، be، John، Black: كلها موجودة في القائمة. فيُبلغ البرنامج عن صفر أخطاء.

What a real-word error isما هو خطأ الكلمة الحقيقية

That is a real-word error: the writer meant one word and produced another word that also exists. It is the opposite of a non-word error like graffe, which fails lookup and so announces itself. Real-word errors come from the same two sources you met at the start of the lecture. A typographical error is a slip of the fingers that happens to land on a valid word. A cognitive error is a writer who does not know which spelling is right, typically between two homophones such as piece and peace.

هذا هو خطأ الكلمة الحقيقية (real-word error): قصد الكاتب كلمة فأنتج كلمة أخرى موجودة هي أيضًا. وهو عكس خطأ الكلمة غير الموجودة (non-word error) مثل graffe، الذي يفشل في البحث في القاموس فيكشف نفسه بنفسه. تأتي أخطاء الكلمات الحقيقية من المصدرين نفسيهما اللذين رأيتهما في بداية المحاضرة. الخطأ الطباعي (typographical error) هو زلة أصابع تصادف أن تقع على كلمة صحيحة. والخطأ المعرفي (cognitive error) هو كاتب لا يعرف أي تهجئة هي الصحيحة، وغالبًا ما يكون ذلك بين كلمتين متجانستين صوتيًا (homophones) مثل piece وpeace.

Every word in “conducted mainly be John Black” passes dictionary lookup; only the context window around be shows that by was meantكل كلمة في «conducted mainly be John Black» تجتاز البحث في القاموس؛ ونافذة السياق حول be وحدها تُظهر أن المقصود كان by

Dissecting the four classic examplesتشريح الأمثلة الكلاسيكية الأربعة

The slide’s four sentences come from Kukich’s survey and are reused in Jurafsky and Martin. Each one is a single edit away from the intended word, which is why the same edit operations from the non-word case will generate the fix. What changed is only that the edited string happens to be in the dictionary.

جمل الشريحة الأربع مأخوذة من مسح Kukich ويعيد استخدامها Jurafsky وMartin. كل واحدة منها تبعد تعديلًا واحدًا عن الكلمة المقصودة، ولهذا فإن عمليات التعديل نفسها المستخدمة في حالة الكلمات غير الموجودة هي التي ستولّد التصحيح. الشيء الوحيد الذي تغيّر هو أن السلسلة بعد التعديل تصادف أنها موجودة في القاموس.

TypedالمكتوبةIntendedالمقصودةSingle edit (intended to typed)تعديل واحد (من المقصودة إلى المكتوبة)Why lookup passes itلماذا يجتازها البحث في القاموس
minuetsminuetsminutesminutesTransposition of the adjacent letters t and eتبديل (transposition) للحرفين المتجاورين t وeminuets is a dance, a perfectly good wordminuets رقصة، وهي كلمة صحيحة تمامًا
ananandandDeletion of dحذف (deletion) للحرف dan is one of the most common words in Englishan من أكثر الكلمات شيوعًا في الإنجليزية
lavelaveleaveleaveDeletion of the first eحذف أول elave is a rare but valid verb, to washlave فعل نادر لكنه صحيح، ومعناه يغسل
bebebybySubstitution of e for yاستبدال (substitution) الحرف y بالحرف ebe is a very common verb, so it never looks odd alonebe فعل شائع جدًا، لذا لا يبدو غريبًا وحده أبدًا
Each classic real-word error is exactly one edit from the intended wordكل خطأ كلاسيكي من أخطاء الكلمات الحقيقية يبعد تعديلًا واحدًا بالضبط عن الكلمة المقصودة

Read the edit direction carefully. In the noisy channel, the channel turns the intended word into the typed one, so and becoming an is a deletion of d, not an insertion. The transposition in minuets is the swap that Damerau-Levenshtein distance counts as one operation: minu-te-s becomes minu-et-s.

انتبه جيدًا لاتجاه التعديل. في القناة المشوشة، تحوّل القناةُ الكلمةَ المقصودة إلى الكلمة المكتوبة، لذا فإن تحوّل and إلى an هو حذف (deletion) للحرف d، وليس إدراجًا. والتبديل (transposition) في minuets هو تبادل الموقعين الذي تعدّه مسافة Damerau-Levenshtein عملية واحدة: minu-te-s تصبح minu-et-s.

How common, and why it mattersما مدى شيوعها، ولماذا يهم ذلك

Kukich’s 1992 survey summarizes studies that put real-word errors at 25 to 40% of all spelling errors. Take the conservative end: if a quarter to two fifths of your errors are real words, then a checker that only does lookup misses up to two errors in every five, however good its non-word correction is. That is the gap this part closes.

يلخّص مسح Kukich عام 1992 دراسات تقدّر أخطاء الكلمات الحقيقية بنسبة 25 إلى 40% من جميع الأخطاء الإملائية. خذ الطرف المتحفظ: إذا كان ما بين الربع والخُمسين من أخطائك كلمات حقيقية، فإن المدقق الذي يكتفي بالبحث في القاموس يفوّت ما يصل إلى خطأين من كل خمسة، مهما كانت جودة تصحيحه للكلمات غير الموجودة. هذه هي الفجوة التي يسدّها هذا الجزء.

Quick checkاختبار سريع

In “conducted mainly be John Black”, which single edit turns the intended by into be?في «conducted mainly be John Black»، ما التعديل الواحد الذي يحوّل الكلمة المقصودة by إلى be؟

Quick checkاختبار سريع

Which single edit turns the intended word minutes into the typed word minuets?ما التعديل الواحد الذي يحوّل الكلمة المقصودة minutes إلى الكلمة المكتوبة minuets؟

Recall

Why does a spell checker that only looks words up in a dictionary report zero errors for “Can they lave him my messages?”لماذا يُبلغ مدقق إملائي يكتفي بالبحث عن الكلمات في القاموس عن صفر أخطاء في الجملة «Can they lave him my messages?»

Because every token, including lave (a rare verb meaning to wash), is a valid English word. Lookup can only detect non-word errors. The real-word error lave for leave is only visible from context: “they lave him” makes no sense, while “they leave him” is a common phrase.
لأن كل token فيها، بما في ذلك lave (فعل نادر يعني «يغسل»)، كلمة إنجليزية صحيحة. البحث في القاموس لا يكتشف إلا أخطاء الكلمات غير الموجودة. وخطأ الكلمة الحقيقية lave بدل leave لا يظهر إلا من السياق: «they lave him» لا معنى لها، بينما «they leave him» عبارة شائعة.

Take the word lave from “Can they lave him my messages?” and ask what the writer might have meant. One edit away there are many real words: leave (insert e), live, love, have, lane, lava. And there is one more option that the non-word case never needed: the writer may really have meant lave.

خذ الكلمة lave من «Can they lave him my messages?» واسأل: ماذا كان الكاتب يقصد؟ على بعد تعديل واحد توجد كلمات حقيقية كثيرة: leave (إدراج e)، وlive، وlove، وhave، وlane، وlava. وهناك خيار إضافي لم تحتجه حالة الكلمات غير الموجودة قط: ربما كان الكاتب يقصد فعلًا lave.

The recipe: for every word, three kinds of candidatesالوصفة: لكل كلمة ثلاثة أنواع من المرشحين

Because we do not know which word is wrong, candidate generation now runs on every word in the sentence, not just a flagged one. For each word the candidate set contains:

لأننا لا نعرف أي كلمة هي الخاطئة، صار توليد المرشحين (candidate generation) يعمل الآن على كل كلمة في الجملة، لا على كلمة واحدة مُعلَّمة فقط. ولكل كلمة تحتوي مجموعة المرشحين (candidate set) على:

  1. The word itself. Most words in any text are typed correctly, so “no change” has to be an option that can win.الكلمة نفسها. معظم الكلمات في أي نص تُكتب بشكل صحيح، لذا يجب أن يكون «عدم التغيير» خيارًا قادرًا على الفوز.
  2. Every single-letter edit that is an English word. Insertions, deletions, substitutions and transpositions at edit distance 1, filtered to dictionary words. This is the typographical side, and it covers all four slide examples.كل تعديل بحرف واحد ينتج كلمة إنجليزية. الإدراج والحذف والاستبدال والتبديل على مسافة تحرير (edit distance) تساوي 1، مع تصفيتها لتبقى كلمات القاموس فقط. هذا هو الجانب الطباعي، وهو يغطي أمثلة الشريحة الأربعة كلها.
  3. Its homophones. Words that sound the same but are spelled differently. This is the cognitive side, and it reaches pairs that a single edit cannot.الكلمات المتجانسة صوتيًا معها. كلمات تُنطق بالطريقة نفسها لكنها تُكتب بشكل مختلف. هذا هو الجانب المعرفي، وهو يصل إلى أزواج لا يستطيع تعديل واحد الوصول إليها.
The candidate set for lave: the word itself in teal, kept as a real option, and its one-edit dictionary neighbors in the main accentمجموعة المرشحين للكلمة lave: الكلمة نفسها باللون الفيروزي، مُبقاة كخيار حقيقي، وجيرانها في القاموس على بعد تعديل واحد باللون الأساسي

Why the original word must stay in the setلماذا يجب أن تبقى الكلمة الأصلية في المجموعة

In non-word correction we threw the typed string away: acress is not a word, so it cannot be the answer. Doing the same here would be a disaster. If every word were replaced by its best neighbor, a correct sentence would come back full of “corrections”. Keeping the typed word in its own set lets the model say “this word is fine”, and since that is the right answer for the vast majority of words, it should usually win. Part 07 makes this precise with the probability of no error.

في تصحيح الكلمات غير الموجودة كنا نتخلص من السلسلة المكتوبة: acress ليست كلمة، فلا يمكن أن تكون هي الإجابة. أما فعل الشيء نفسه هنا فسيكون كارثة. لو استُبدلت كل كلمة بأفضل جار لها، لعادت الجملة الصحيحة مليئة بـ«تصحيحات». إبقاء الكلمة المكتوبة في مجموعتها يسمح للنموذج بأن يقول «هذه الكلمة سليمة»، وبما أن هذه هي الإجابة الصحيحة للغالبية العظمى من الكلمات، فيجب أن تفوز عادةً. يجعل الجزء 07 هذا الأمر دقيقًا عبر احتمال عدم وجود خطأ (probability of no error).

Why homophones get their own slotلماذا تحصل الكلمات المتجانسة صوتيًا على خانة خاصة بها

A cognitive error is not a slip, so it need not be a small edit. Compare the pairs below. The one-edit rule catches some homophones by luck, but the classic confusions like piece and peace sit two edits apart. Adding homophones explicitly, from a pronunciation dictionary or a sound-based key, brings them into the set without widening the edit radius to 2 for every word, which would multiply the candidates for everything else.

الخطأ المعرفي ليس زلة أصابع، لذا لا يلزم أن يكون تعديلًا صغيرًا. قارن الأزواج في الجدول أدناه. قاعدة التعديل الواحد تلتقط بعض الكلمات المتجانسة صوتيًا بالصدفة، لكن حالات الخلط الكلاسيكية مثل piece وpeace تبعد عن بعضها تعديلين. إضافة الكلمات المتجانسة صوتيًا صراحةً، من قاموس نطق أو من مفتاح مبني على الصوت، يُدخلها إلى المجموعة دون توسيع نصف قطر التعديل إلى 2 لكل كلمة، وهو ما كان سيضاعف عدد المرشحين لكل الكلمات الأخرى.

PairالزوجEdit distanceمسافة التعديلReached by the one-edit rule?هل تصل إليه قاعدة التعديل الواحد؟
piece / peacepiece / peace22Two substitutions, out of reach of one editاستبدالان، خارج نطاق التعديل الواحد
their / theretheir / there22Two substitutions, out of reach of one editاستبدالان، خارج نطاق التعديل الواحد
two / tootwo / too11One substitution, the edit rule already finds itاستبدال واحد، فقاعدة التعديل تجده أصلًا
desert / dessertdesert / dessert11One insertion, the edit rule already finds itإدراج واحد، فقاعدة التعديل تجده أصلًا
Edit distance between common homophone pairsمسافة التعديل بين أزواج شائعة من الكلمات المتجانسة صوتيًا

Two ways to chooseطريقتان للاختيار

Once every word has a candidate set, the slide offers two ways to pick. The general one is the noisy channel model, which scores every candidate sentence and is the subject of the next concept. The specialised one is a task-specific classifier, also called a confusion-set classifier: train a model for one confusable group, such as to/too/two or weather/whether, using features of the surrounding words. Golding and Roth’s WinSpell is a well-known example. Classifiers are very accurate for the pairs they were trained on and say nothing about any other word.

بعد أن تصبح لكل كلمة مجموعة مرشحين، تعرض الشريحة طريقتين للاختيار. الطريقة العامة هي نموذج القناة المشوشة (noisy channel model)، الذي يُقيّم كل جملة مرشحة، وهو موضوع المفهوم التالي. والطريقة المتخصصة هي مصنِّف خاص بمهمة محددة، ويُسمى أيضًا مصنِّف مجموعة الالتباس (confusion-set classifier): تدرّب نموذجًا لمجموعة واحدة من الكلمات المتشابهة، مثل to/too/two أو weather/whether، باستخدام خصائص الكلمات المحيطة. ويُعدّ WinSpell الذي طوّره Golding وRoth مثالًا معروفًا. المصنِّفات دقيقة جدًا في الأزواج التي دُرِّبت عليها، ولا تقول شيئًا عن أي كلمة أخرى.

Recall

Why does the candidate set include homophones as well as one-edit neighbors?لماذا تتضمن مجموعة المرشحين الكلمات المتجانسة صوتيًا إضافةً إلى الجيران على بعد تعديل واحد؟

Because cognitive errors come from not knowing the spelling, not from a finger slip, so the intended word can be more than one edit away. piece and peace, or their and there, are two edits apart and would be missed by a one-edit rule. Listing homophones explicitly catches them without widening the edit radius for every word.
لأن الأخطاء المعرفية تأتي من عدم معرفة التهجئة، لا من زلة أصابع، لذا قد تبعد الكلمة المقصودة أكثر من تعديل واحد.piece وpeace، أو their وthere، يفصل بينهما تعديلان، وستفوتهما قاعدة التعديل الواحد. إدراج الكلمات المتجانسة صوتيًا صراحةً يلتقطها دون توسيع نصف قطر التعديل لكل كلمة.

Recall

In non-word correction the typed string is dropped from the candidates. Why is it kept in real-word correction?في تصحيح الكلمات غير الموجودة تُستبعد السلسلة المكتوبة من المرشحين. فلماذا تُبقى في تصحيح الكلمات الحقيقية؟

A non-word cannot be the intended word, so it is useless as a candidate. A real word usually is the intended word, since most words are typed correctly. Keeping it lets the model choose “no change”; dropping it would force a correction at every position.
الكلمة غير الموجودة لا يمكن أن تكون الكلمة المقصودة، فلا فائدة منها كمرشح. أما الكلمة الحقيقية فهي في العادة الكلمة المقصودة فعلًا، لأن معظم الكلمات تُكتب بشكل صحيح. إبقاؤها يسمح للنموذج باختيار «عدم التغيير»؛ واستبعادها سيفرض تصحيحًا في كل موضع.

Put the candidate sets for “mainly be John Black” side by side: {mainly, manly}, {be, by, bee, he, we}, {John}, {Black, Back}. Any choice of one candidate per column is a possible corrected sentence. That gives 2 × 5 × 1 × 2 = 20 sentences from four words, and the right one, “mainly by John Black”, is just one path through them.

ضع مجموعات المرشحين لعبارة «mainly be John Black» جنبًا إلى جنب: {mainly, manly}، {be, by, bee, he, we}، {John}، {Black, Back}. أي اختيار لمرشح واحد من كل عمود هو جملة مصححة محتملة. وهذا يعطي 2 × 5 × 1 × 2 = 20 جملة من أربع كلمات فقط، والجملة الصحيحة «mainly by John Black» ليست إلا مسارًا واحدًا بينها.

The key shift: from one word to the whole sentenceالنقلة الأساسية: من كلمة واحدة إلى الجملة كلها

In non-word correction we knew where the error was, so the search was over one word’s candidates. Here we do not know, so the unit of search becomes the sentence. Given a typed sentence X=x1,x2,…,xnX = x_1, x_2, \dots, x_n, we build Candidate(xᵢ) for every position and search over every sequence W=w1,…,wnW = w_1, \dots, w_n that takes one candidate from each set. This is the method of Mays, Damerau and Mercer (1991), which Jurafsky and Martin present as the noisy channel for real-word errors.

في تصحيح الكلمات غير الموجودة كنا نعرف مكان الخطأ، فكان البحث يجري على مرشحي كلمة واحدة. أما هنا فلا نعرف، فتصبح وحدة البحث هي الجملة. بالنظر إلى جملة مكتوبة X=x1,x2,…,xnX = x_1, x_2, \dots, x_n، نبني Candidate(xᵢ) لكل موضع ونبحث في كل تسلسل W=w1,…,wnW = w_1, \dots, w_n يأخذ مرشحًا واحدًا من كل مجموعة. هذه هي طريقة Mays وDamerau وMercer (1991)، التي يقدّمها Jurafsky وMartin على أنها القناة المشوشة لأخطاء الكلمات الحقيقية.

The candidate columns for mainly be John Black form a lattice of 20 sentences; the typed path is teal and the argmax path through by is the main accentأعمدة المرشحين لعبارة mainly be John Black تشكّل شبكة (lattice) من 20 جملة؛ المسار المكتوب باللون الفيروزي، ومسار argmax المار عبر by باللون الأساسي

The objective: prior times channel, over sentencesالهدف: الاحتمال المسبق مضروبًا في القناة، على مستوى الجمل

W^=argmax⁡W∈C(X)  P(X∣W) P(W)\hat{W} = \underset{W \in C(X)}{\operatorname{argmax}}\; P(X \mid W)\, P(W)
Sentence-level noisy channel: C(X) is every sentence built from the candidate setsالقناة المشوشة على مستوى الجملة: C(X) هي كل جملة تُبنى من مجموعات المرشحين

This is the same argmax as before, lifted from words to sentences. P(W) is the prior probability of the whole sentence, supplied by a language model such as a bigram language model or a trigram model, so context finally enters the score. P(X|W) is the channel model: how likely the writer was to type X when they meant W. For an unchanged word it is the probability of typing it correctly; for a changed word it is the probability of that edit.

هذا هو argmax نفسه كما سبق، لكنه رُفع من مستوى الكلمات إلى مستوى الجمل. P(W) هو الاحتمال المسبق (prior probability) للجملة كلها، ويوفّره نموذج لغوي مثل النموذج اللغوي الثنائي (bigram language model) أو نموذج ثلاثي (trigram)، وبذلك يدخل السياق أخيرًا في الدرجة. وP(X|W) هو نموذج القناة (channel model): ما مدى احتمال أن يكتب الكاتب X وهو يقصد W. بالنسبة إلى كلمة لم تتغير، فهو احتمال كتابتها بشكل صحيح؛ وبالنسبة إلى كلمة تغيّرت، فهو احتمال ذلك التعديل.

Worked exampleمثال محلول

Does be become by? (illustrative numbers)هل تصبح be هي by؟ (أرقام توضيحية)

  1. Fix the channelتثبيت القناة

    Use the simple Mays et al. channel. A word is typed correctly with probability α=0.95\alpha = 0.95, and the remaining 0.05 is shared equally by the other candidates. If be has 10 other candidates, each gets 0.05 / 10 = 0.005.
    نستخدم قناة Mays et al. البسيطة. تُكتب الكلمة بشكل صحيح باحتمال α=0.95\alpha = 0.95، وتتقاسم المرشحات الأخرى الباقي 0.05 بالتساوي. إذا كان للكلمة be 10 مرشحات أخرى، فكل منها يحصل على 0.05 / 10 = 0.005.
  2. Score the typed sentenceتقييم الجملة المكتوبة

    Suppose a bigram model gives P(be | mainly) = 0.0001 and P(John | be) = 0.00002. The language model part is 2 × 10⁻⁹. Times the channel 0.95 gives 1.9 × 10⁻⁹.
    لنفترض أن نموذجًا ثنائيًا (bigram) يعطي P(be | mainly) = 0.0001 وP(John | be) = 0.00002. جزء النموذج اللغوي يساوي 2 × 10⁻⁹. وبضربه في القناة 0.95 نحصل على 1.9 × 10⁻⁹.
  3. Score the corrected sentenceتقييم الجملة المصححة

    Suppose P(by | mainly) = 0.002 and P(John | by) = 0.0005. The language model part is 1 × 10⁻⁶, which is 500 times higher. Times the channel 0.005 gives 5 × 10⁻⁹.
    لنفترض أن P(by | mainly) = 0.002 وP(John | by) = 0.0005. جزء النموذج اللغوي يساوي 1 × 10⁻⁶، أي أعلى بـ500 مرة. وبضربه في القناة 0.005 نحصل على 5 × 10⁻⁹.
  4. Compareالمقارنة

    5 × 10⁻⁹ > 1.9 × 10⁻⁹, so the correction wins, by a factor of about 2.6. The channel charged a toll of 0.95 / 0.005 = 190 for changing the word, and the language model gain of 500 paid it.
    5 × 10⁻⁹ > 1.9 × 10⁻⁹، إذن يفوز التصحيح، بفارق يقارب 2.6 ضعف. فرضت القناة رسم عبور مقداره 0.95 / 0.005 = 190 مقابل تغيير الكلمة، ومكسب النموذج اللغوي البالغ 500 دفع هذا الرسم.
  5. Resultالنتيجة

    A change is accepted only when the context makes the new sentence more likely by more than the channel’s toll. Here “mainly by John” clears the bar; a mild preference would not.
    لا يُقبل التغيير إلا حين يجعل السياقُ الجملةَ الجديدة أكثر احتمالًا بمقدار يتجاوز رسم القناة. هنا تتجاوز «mainly by John» العتبة؛ أما التفضيل الطفيف فلن يكفي.

Why the full search is too bigلماذا البحث الكامل أكبر من اللازم

The number of candidate sentences is the product of the set sizes. With 10 words and 11 candidates each (the word plus 10 alternatives), that is 11¹⁰, about 26 billion sentences. Mays et al. cut this down by assuming at most one error per sentence, which leaves 1 + 10 × 10 = 101 sentences to score. That one-error-per-sentence assumption and the candidate lattice it prunes are the subject of Part 07.

عدد الجمل المرشحة هو حاصل ضرب أحجام المجموعات. مع 10 كلمات و11 مرشحًا لكل منها (الكلمة نفسها زائد 10 بدائل)، يصبح العدد 11¹⁰، أي نحو 26 billion (26 مليار) جملة. قلّص Mays et al. هذا العدد بافتراض وجود خطأ واحد على الأكثر في كل جملة، مما يترك 1 + 10 × 10 = 101 جملة فقط للتقييم. افتراض one-error-per-sentence (خطأ واحد لكل جملة) وشبكة المرشحين (candidate lattice) التي يقلّمها هما موضوع الجزء 07.

Non-word correctionتصحيح الكلمات غير الموجودةReal-word correctionتصحيح الكلمات الحقيقية
Exampleمثالgraffe for giraffegraffe بدل giraffebe for bybe بدل by
DetectionالاكتشافDictionary lookup: the string is not a wordالبحث في القاموس: السلسلة ليست كلمةNeeds context: the string is a wordيحتاج إلى السياق: السلسلة كلمة صحيحة
Where is the error?أين الخطأ؟Known: the one token that failed lookupمعروف: الـ token الوحيد الذي فشل في البحثUnknown: any word could be wrongغير معروف: أي كلمة قد تكون خاطئة
Does the typed string join the candidates?هل تدخل السلسلة المكتوبة ضمن المرشحين؟No, it is not a word, so it cannot be the answerلا، فهي ليست كلمة، فلا يمكن أن تكون الإجابةYes, it is usually correct and must be allowed to winنعم، فهي صحيحة في العادة ويجب أن يُسمح لها بالفوز
Unit of searchوحدة البحثOne wordكلمة واحدةThe whole sentenceالجملة كلها
Model neededالنموذج المطلوبChannel model plus a prior (a unigram is enough to start)نموذج قناة مع احتمال مسبق (prior)، ويكفي unigram للبدايةChannel model plus a language model over context, or a confusion-set classifierنموذج قناة مع نموذج لغوي على السياق، أو مصنِّف مجموعة الالتباس (confusion-set classifier)
Non-word versus real-word correctionتصحيح الكلمات غير الموجودة مقابل تصحيح الكلمات الحقيقية

Recall

What does P(W) alone get wrong, and what does the channel term P(X|W) add?ما الخطأ الذي يقع فيه P(W) وحده، وما الذي يضيفه حد القناة P(X|W)؟

P(W) alone prefers whatever sentence the language model likes best, so it rewrites correct but less common words into more common neighbors. P(X|W) adds the cost of the change: with α = 0.95 a kept word scores far higher than an edited one, so a correction must win on context by more than that toll.
P(W) وحده يفضّل أي جملة يحبها النموذج اللغوي أكثر، فيعيد كتابة الكلمات الصحيحة الأقل شيوعًا إلى جيران أكثر شيوعًا. ويضيف P(X|W) تكلفة التغيير: مع α = 0.95 تحصل الكلمة المُبقاة على درجة أعلى بكثير من الكلمة المعدَّلة، لذا يجب أن يفوز التصحيح بالسياق بمقدار يتجاوز ذلك الرسم.

Recall

How many candidate sentences are there for a 4-word sentence whose candidate sets have sizes 2, 5, 1 and 2?كم عدد الجمل المرشحة لجملة من 4 كلمات أحجام مجموعات مرشحيها 2 و5 و1 و2؟

The product of the sizes: 2 × 5 × 1 × 2 = 20 sentences. In general the count grows as the product, which is why practical systems restrict the search, for example to one error per sentence.
حاصل ضرب الأحجام: 2 × 5 × 1 × 2 = 20 جملة. وبشكل عام ينمو العدد كحاصل ضرب، ولهذا تقيّد الأنظمة العملية البحث، مثلًا بخطأ واحد لكل جملة.

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • A real-word error is a typo that lands on another valid word: minuets for minutes, an for and, lave for leave, be for by.خطأ الكلمة الحقيقية هو خطأ مطبعي ينتج كلمة صحيحة أخرى: minuets بدل minutes، و an بدل and، و lave بدل leave، و be بدل by.
  • Kukich (1992) reports that 25 to 40% of spelling errors are real words, so ignoring them leaves a large share of errors untouched.يذكر Kukich (1992) أن 25 إلى 40% من الأخطاء الإملائية كلمات حقيقية، لذا فإن تجاهلها يترك نسبة كبيرة من الأخطاء دون معالجة.
  • Dictionary lookup passes every real-word error. Only context can reveal it, so detection becomes the hard part.البحث في القاموس يُمرر كل خطأ كلمة حقيقية. السياق وحده يكشفه، ولذلك يصبح الاكتشاف (detection) هو الجزء الصعب.
  • Non-word correction knows where the error is. Real-word correction does not, so every word in the sentence is a suspect.تصحيح الكلمات غير الموجودة (non-word) يعرف مكان الخطأ. أما تصحيح الكلمات الحقيقية فلا يعرفه، فتصبح كل كلمة في الجملة موضع اشتباه.
  • Candidate set for each word: the word itself, every single-edit neighbor that is a word, and its homophones.مجموعة المرشحين لكل كلمة: الكلمة نفسها، وكل جار على بعد تعديل واحد يكون كلمة صحيحة، وكلماتها المتجانسة صوتيًا (homophones).
  • The typed word stays in its own candidate set because most words are typed correctly.تبقى الكلمة المكتوبة ضمن مجموعة مرشحيها لأن معظم الكلمات تُكتب بشكل صحيح.
  • Choose the sentence W that maximizes P(X|W) P(W). P(W) alone overcorrects, because it ignores how unlikely the change was.اختر الجملة W التي تعظّم P(X|W) P(W). استخدام P(W) وحده يؤدي إلى الإفراط في التصحيح، لأنه يتجاهل مدى ندرة حدوث هذا التغيير.
  • The full search is the product of the candidate set sizes, which explodes. Part 07 tames it with the one-error assumption.البحث الكامل هو حاصل ضرب أحجام مجموعات المرشحين، وهو ينفجر عدديًا. الجزء 07 يروّضه بافتراض وجود خطأ واحد فقط.

Sourcesالمصادر

Part 07: The candidate lattice, one error per sentence, and P(w|w)شبكة المرشحين وخطأ واحد في الجملة وP(w|w)

Searching the candidate lattice for 'two of thew', the one-error-per-sentence simplification, the channel probability of typing a word correctly, and Norvig's thew example.البحث في شبكة المرشحين لعبارة two of thew، وتبسيط خطأ واحد في كل جملة، واحتمال القناة لكتابة الكلمة بشكل صحيح، ومثال thew عند Norvig.

4 concepts4 مفاهيم, ، slides 34-39الشرائح 34-39

Why this part mattersلماذا يهمّ هذا الجزء

A non-word like acress announces itself: it is not in the dictionary, so you know where the error is and only have to pick the fix. A Real-word error gives no such signal. In two of thew apples, every word is a real English word, so any of them might be the mistake, and any of them might be exactly what the writer meant.

This part turns that problem into a search you can draw and count. First, a lattice that lays out every sentence the writer might have meant. Second, the one-error simplification that cuts that search from a product to a sum. Third, the one probability the real-word channel needs that the non-word channel never did: the chance that a word was typed correctly. Fourth, Norvig's thew table, where that chance meets real numbers. On the exam, expect to count candidate sentences, to interpret a value of α, and to multiply out a row of the table. For your own work, this is the cleanest small example of a design choice that every noisy channel system has to make: how much to trust the input as it is.

كلمة غير موجودة مثل acress تكشف نفسها بنفسها: هي ليست في القاموس، فأنت تعرف مكان الخطأ ولا يبقى عليك إلا اختيار التصحيح. أما real-word error (خطأ الكلمة الحقيقية) فلا يعطي أي إشارة من هذا النوع. في two of thew apples كل كلمة هي كلمة إنجليزية حقيقية، فقد تكون أي واحدة منها هي الخطأ، وقد تكون أي واحدة منها هي بالضبط ما قصده الكاتب.

هذا الجزء يحوّل تلك المشكلة إلى بحث يمكنك رسمه وعدّه. أولا، شبكة (lattice) تعرض كل جملة ربما قصدها الكاتب. ثانيا، تبسيط الخطأ الواحد (one-error) الذي يقلّص هذا البحث من حاصل ضرب إلى مجموع. ثالثا، الاحتمال الوحيد الذي تحتاجه قناة الكلمات الحقيقية ولم تحتجه قناة الكلمات غير الموجودة أبدا: احتمال أن الكلمة كُتبت صحيحة. رابعا، جدول Norvig لكلمة thew، حيث يلتقي هذا الاحتمال بأرقام حقيقية. في الامتحان، توقّع أن يُطلب منك عدّ الجمل المرشحة، وتفسير قيمة α، وحساب صف من الجدول بالضرب. وفي عملك الخاص، هذا أوضح مثال صغير على قرار تصميمي لا بد أن يتخذه كل نظام قناة صاخبة (noisy channel): إلى أي حد تثق في المدخل كما هو.

By the end you canفي نهاية هذا الجزء ستستطيع

  1. Draw the candidate lattice for a short sentence and read every path through it as one candidate sentence.رسم شبكة المرشحات (candidate lattice) لجملة قصيرة، وقراءة كل مسار فيها على أنه جملة مرشحة واحدة.
  2. Count the candidate sentences in the full lattice (a product) and under the one-error assumption (a sum), and explain why the assumption is needed.عدّ الجمل المرشحة في الشبكة الكاملة (حاصل ضرب) وتحت افتراض الخطأ الواحد (one-error، مجموع)، وشرح سبب الحاجة إلى هذا الافتراض.
  3. Explain where the two probabilities of the real-word noisy channel come from, and why it needs a new term, P(w|w).شرح مصدر الاحتمالين في القناة الصاخبة (noisy channel) لأخطاء الكلمات الحقيقية، ولماذا تحتاج إلى حد جديد هو P(w|w).
  4. Translate a value of α such as .95 or .99 into an error rate in words, and say who chooses it.تحويل قيمة α مثل .95 أو .99 إلى معدل أخطاء بالكلمات، وتحديد من يختارها.
  5. Rebuild Norvig's thew table: name each edit, multiply channel by prior, and decide when thew itself would win.إعادة بناء جدول Norvig لكلمة thew: تسمية كل تعديل، وضرب احتمال القناة في الاحتمال المسبق (prior)، وتحديد متى تفوز thew نفسها.

Take the typed phrase two of thew and, for each word on its own, write down every word the writer might have intended. Under two: to, tao, too and two itself. Under of: off, on, of. Under thew: threw, thaw, the and thew.

خذ العبارة المكتوبة two of thew، ولكل كلمة على حدة اكتب كل كلمة ربما قصدها الكاتب. تحت two: to وtao وtoo وtwo نفسها. تحت of: off وon وof. تحت thew: threw وthaw وthe وthew.

Each list is that word's Candidate set: real words within one edit, plus homophones such as too for two, plus the typed word itself. Now put the lists side by side as columns and connect every node in one column to every node in the next. The result is the Candidate lattice. Its key property is simple: pick one node per column, left to right, and you have spelled out one possible intended sentence. two of the is one path. too off thaw is another. The corrector's job is to find the path with the highest noisy channel score.

كل قائمة هي candidate set (مجموعة المرشحات) لتلك الكلمة: الكلمات الحقيقية التي تبعد تعديلا واحدا، مع الكلمات المتشابهة في النطق (homophones) مثل too بدل two، مع الكلمة المكتوبة نفسها. الآن ضع القوائم جنبا إلى جنب على شكل أعمدة، واربط كل عقدة في عمود بكل عقدة في العمود التالي. النتيجة هي candidate lattice (شبكة المرشحات). خاصيتها الأساسية بسيطة: اختر عقدة واحدة من كل عمود، من اليسار إلى اليمين، وستكون قد كتبت جملة واحدة محتملة قصدها الكاتب. two of the مسار واحد، وtoo off thaw مسار آخر. مهمة المصحِّح هي إيجاد المسار الذي له أعلى درجة في القناة الصاخبة (noisy channel).

The lattice for two of thew: one column of candidates per typed word, and the best path two, of, the lit upشبكة المرشحات لعبارة two of thew: عمود من المرشحات لكل كلمة مكتوبة، مع إبراز أفضل مسار two ثم of ثم the

The best path the lecture highlights is two of the. Notice what that path does: it keeps two and of exactly as typed and changes only thew. That is why each candidate set must contain the typed word itself. If two were missing from its own column, the lattice could not express “this word was fine”, and every path would be forced to change every word.

أفضل مسار تبرزه المحاضرة هو two of the. لاحظ ما يفعله هذا المسار: يُبقي two وof كما كُتبتا تماما، ويغيّر thew فقط. لهذا يجب أن تحتوي كل مجموعة مرشحات على الكلمة المكتوبة نفسها. لو غابت two عن عمودها، لما استطاعت الشبكة أن تعبّر عن أن «هذه الكلمة كانت سليمة»، ولاضطر كل مسار إلى تغيير كل كلمة.

W^=arg⁡max⁡W∈C(X)  P(X∣W) P(W)\hat{W} = \underset{W \in C(X)}{\arg\max}\; P(X \mid W)\, P(W)
The noisy channel over sentences: X is the typed sentence, C(X) the paths through the latticeالقناة المشوشة على الجمل: X الجملة المكتوبة، وC(X) المسارات عبر الشبكة (lattice)

Recall

Why must every column of the lattice contain the word that was actually typed?لماذا يجب أن يحتوي كل عمود في الشبكة على الكلمة التي كُتبت فعلا؟

Because most words in a sentence are correct. A path that keeps a word unchanged has to pass through that word's own node. Without it, the lattice could only produce sentences in which that word was an error.

لأن معظم الكلمات في الجملة صحيحة. المسار الذي يُبقي كلمة دون تغيير لا بد أن يمر بعقدة تلك الكلمة نفسها. وبدونها لن تنتج الشبكة إلا جملا تكون فيها تلك الكلمة خطأ.

Count the paths in the lattice above. There are 4 choices in the first column, 3 in the second and 4 in the third, and any choice can follow any other, so there are 4 × 3 × 4 = 48 candidate sentences for a three-word phrase.

عُدّ المسارات في الشبكة السابقة. هناك 4 خيارات في العمود الأول، و3 في الثاني، و4 في الثالث، وأي خيار يمكن أن يتبعه أي خيار آخر، فيكون عدد الجمل المرشحة 4 × 3 × 4 = 48 لعبارة من ثلاث كلمات.

That product is the problem. Add only at the front and apples at the end, as slide 36 does, and you multiply again by the size of each new set. A twenty-word sentence with four candidates per word has 4²⁰ ≈ 1.1 × 10¹² paths. Each one needs a language model score, so the full search is hopeless, and most of those sentences assume the writer made many errors at once, which is rare.

حاصل الضرب هذا هو المشكلة. أضف only في البداية وapples في النهاية، كما تفعل الشريحة 36، فتضرب مرة أخرى في حجم كل مجموعة جديدة. جملة من عشرين كلمة بأربعة مرشحات لكل كلمة لها 4²⁰ ≈ 1.1 × 10¹² مسارا. كل مسار يحتاج إلى درجة من النموذج اللغوي، فالبحث الكامل ميؤوس منه، كما أن معظم تلك الجمل تفترض أن الكاتب ارتكب أخطاء كثيرة في وقت واحد، وهذا نادر.

The simplificationالتبسيط

The One error per sentence assumption assumption, from Mays, Damerau and Mercer (1991), keeps only sentences that differ from the typed one in at most one word. In the lattice, that means a path may leave the typed node in at most one column. For two of thew:

افتراض one error per sentence (خطأ واحد في كل جملة)، من Mays وDamerau وMercer (1991)، يُبقي فقط الجمل التي تختلف عن الجملة المكتوبة في كلمة واحدة على الأكثر. في الشبكة، يعني ذلك أن المسار يجوز له أن يترك العقدة المكتوبة في عمود واحد على الأكثر. بالنسبة لـ two of thew:

  • The typed sentence itself, unchanged: two of thew. That is 1.الجملة المكتوبة نفسها دون تغيير: two of thew. هذه 1.
  • Change only the first word: to, tao, too. That is 3, for example too of thew (slide notation w‴₁ w₂ w₃).تغيير الكلمة الأولى فقط: to وtao وtoo. هذه 3، مثل too of thew (بترميز الشريحة w‴₁ w₂ w₃).
  • Change only the second word: off, on. That is 2, for example two off thew (w₁ w″₂ w₃).تغيير الكلمة الثانية فقط: off وon. هذه 2، مثل two off thew (w₁ w″₂ w₃).
  • Change only the third word: threw, thaw, the. That is 3, for example two of the (w₁ w₂ w′₃).تغيير الكلمة الثالثة فقط: threw وthaw وthe. هذه 3، مثل two of the (w₁ w₂ w′₃).
∣C(X)∣full=∏i=1n∣C(xi)∣=48∣C(X)∣one error=1+∑i=1n(∣C(xi)∣−1)=1+3+2+3=9|C(X)|_{\text{full}} = \prod_{i=1}^{n} |C(x_i)| = 48 \qquad |C(X)|_{\text{one error}} = 1 + \sum_{i=1}^{n} \bigl(|C(x_i)| - 1\bigr) = 1 + 3 + 2 + 3 = 9
The product becomes a sum: the search now grows linearly with sentence lengthحاصل الضرب يصبح مجموعًا: والبحث الآن ينمو خطيًا مع طول الجملة
All 48 sentences of the full lattice as dots; the one-error rule keeps 9 of them: the typed sentence and 8 single substitutionsجمل الشبكة الكاملة الـ 48 كلها على شكل نقاط، وقاعدة الخطأ الواحد تُبقي 9 منها: الجملة المكتوبة و8 استبدالات لكلمة واحدة

The twenty-word example drops from about 10¹² sentences to 1 + 20 × 3 = 61. The primes in the slide's notation only mark which position was replaced; w″₂ is “some other candidate for the second word”, not a second derivative or a second error.

مثال العشرين كلمة ينخفض من نحو 10¹² جملة إلى 1 + 20 × 3 = 61. علامات الشَّرطة (primes) في ترميز الشريحة تحدد فقط أي موضع استُبدل، فـ w″₂ تعني «مرشحا آخر للكلمة الثانية»، وليست مشتقة ثانية ولا خطأ ثانيا.

Quick checkاختبار سريع

Candidate sets for two, of and thew have sizes 4, 3 and 4. Under one error per sentence, how many candidate sentences are scored?أحجام مجموعات المرشحات لـ two وof وthew هي 4 و3 و4. تحت افتراض خطأ واحد في كل جملة، كم جملة مرشحة تُحسب درجتها؟

Recall

Why does the one-error assumption turn a product into a sum?لماذا يحوّل افتراض الخطأ الواحد حاصل الضرب إلى مجموع؟

In the full lattice every column varies independently, so the choices multiply. With at most one change, only one column varies in any sentence, so you count each column's alternatives separately and add them, then add the one sentence where nothing changes.

في الشبكة الكاملة يتغير كل عمود باستقلال عن غيره، فتتضاعف الخيارات بالضرب. ومع تغيير واحد على الأكثر، لا يتغير في أي جملة إلا عمود واحد، فتعدّ بدائل كل عمود على حدة وتجمعها، ثم تضيف الجملة الواحدة التي لا يتغير فيها شيء.

Score two of the nine sentences: two of the and two of thew. The first changes thew into the, so its channel term is the probability of that edit, which the confusion matrices already give you. The second changes nothing. What channel probability belongs to “the writer meant thew and typed thew”?

احسب درجة جملتين من الجمل التسع: two of the وtwo of thew. الأولى تغيّر thew إلى the، فحد القناة فيها هو احتمال ذلك التعديل، وهذا تعطيك إياه مصفوفات الالتباس (confusion matrices) مسبقا. الثانية لا تغيّر شيئا. فما احتمال القناة المناسب لحالة «الكاتب قصد thew وكتب thew»؟

For non-word errors this question never came up: the typed string was not a word, so it could not be the answer. With real words it is the most important candidate of all, because most typed words are correct. So the two probabilities of the noisy channel are filled in as follows.

في أخطاء الكلمات غير الموجودة لم يُطرح هذا السؤال أبدا: النص المكتوب لم يكن كلمة، فلا يمكن أن يكون هو الجواب. أما مع الكلمات الحقيقية فهو أهم مرشح على الإطلاق، لأن معظم الكلمات المكتوبة صحيحة. لذلك يُملأ احتمالا القناة الصاخبة على النحو الآتي.

TermالحدWhat it measuresما الذي يقيسهWhere it comes fromمن أين يأتي
P(W), the language modelP(W)، النموذج اللغويHow likely the whole candidate sentence isمدى احتمال الجملة المرشحة كاملةUnigram, bigram or trigram counts from a corpus, smoothed (for example with stupid backoff)عدّات unigram أو bigram أو trigram من مدوّنة، مع التنعيم (مثلا بطريقة stupid backoff)
P(x|w), x different from wP(x|w)، حيث x تختلف عن wHow likely the typist turned w into xمدى احتمال أن يحوّل الكاتب w إلى xThe same confusion-matrix channel as for non-word errors (Kernighan, Church and Gale)قناة مصفوفة الالتباس نفسها المستخدمة لأخطاء الكلمات غير الموجودة (Kernighan وChurch وGale)
P(w|w), the new termP(w|w)، الحد الجديدHow likely the typist typed w correctlyمدى احتمال أن يكتب الكاتب w صحيحةNot counted from a corpus. Chosen per application, called αلا تُعدّ من مدوّنة. تُختار لكل تطبيق، وتُسمى α
Where each probability in P(X|W) P(W) comes from for real-word correctionمصدر كل احتمال في P(X|W) P(W) عند تصحيح أخطاء الكلمات الحقيقية

The Prior probability is any language model you already know: a Unigram prior in the slide's table, or a Bigram language model or trigram over the whole sentence in practice. The Channel model for an actual edit is the same one used for non-words, built from the Kernighan, Church and Gale channel model confusion matrices. The one new value is the Probability of no error, written P(w|w) and usually called α.

prior probability (الاحتمال المسبق) هو أي نموذج لغوي تعرفه: unigram prior في جدول الشريحة، أو bigram language model أو trigram على الجملة كلها في التطبيق العملي. وchannel model (نموذج القناة) للتعديل الفعلي هو نفسه المستخدم للكلمات غير الموجودة، والمبني من مصفوفات الالتباس في Kernighan, Church and Gale. القيمة الجديدة الوحيدة هي probability of no error (احتمال عدم الخطأ)، وتُكتب P(w|w) وتُسمى عادة α.

Who sets α, and what it meansمن يحدد α، وماذا تعني

Ask what P(the|the) should be. There is no corpus count for it; it is a statement about the typist. If people mistype one word in twenty, then a given word comes out as intended with probability 19/20 = .95. In general, α = 1 − error rate, and an error rate of one in N words gives α = 1 − 1/N.

اسأل نفسك: كم يجب أن تكون P(the|the)؟ لا يوجد لها عدّ في المدوّنة (corpus)، فهي عبارة عن وصف للشخص الذي يكتب. إذا كان الناس يخطئون في كلمة واحدة من كل عشرين، فإن أي كلمة تخرج كما قُصدت باحتمال 19/20 = .95. وبشكل عام α = 1 − error rate، ومعدل خطأ قدره واحد في كل N كلمة يعطي α = 1 − 1/N.

α = P(w|w)α = P(w|w)Errorsالأخطاء1 − α1 − αMight suit, for exampleقد تناسب، على سبيل المثال
.90.901 in 10خطأ واحد في كل 100.100.10Fast chat typing on a phone, no proofreadingالكتابة السريعة في المحادثات على الجوال، دون مراجعة
.95.951 in 20خطأ واحد في كل 200.050.05Norvig's and SLP3's choice for web textاختيار Norvig وSLP3 لنصوص الويب
.99.991 in 100خطأ واحد في كل 1000.010.01Careful drafting, such as a thesis chapterالكتابة المتأنية، مثل فصل من رسالة دكتوراه
.995.9951 in 200خطأ واحد في كل 2000.0050.005Edited, proofread text such as a published bookنص محرَّر ومُراجَع، مثل كتاب منشور
The slide's four values of α, and the kind of text each one fitsقيم α الأربع في الشريحة، ونوع النص الذي تناسبه كل قيمة
Two hundred typed words per row: at α = .90 every tenth word is an error, at α = .995 only one word in two hundredمئتا كلمة مكتوبة في كل صف: عند α = .90 تكون كل كلمة عاشرة خطأ، وعند α = .995 كلمة واحدة فقط من كل مئتين

The slide's own phrase is “obviously this depends on the application”. The same corrector should behave differently on hasty phone messages and on a proofread manuscript, and α is the knob that says which one it is looking at. A low α tells the system that errors are common, so it is quick to change words. A high α tells it to trust the input, so a change has to be strongly supported by the language model.

عبارة الشريحة نفسها هي «من الواضح أن هذا يعتمد على التطبيق» (obviously this depends on the application). المصحِّح نفسه يجب أن يتصرف بشكل مختلف مع رسائل الجوال المكتوبة على عجل ومع مخطوطة مُراجَعة، وα هي المفتاح الذي يخبره بأيهما يتعامل. قيمة α المنخفضة تخبر النظام أن الأخطاء شائعة، فيسارع إلى تغيير الكلمات. وقيمة α المرتفعة تخبره أن يثق في المدخل، فلا يحدث التغيير إلا إذا دعمه النموذج اللغوي بقوة.

P(x∣w)={αx=w(1−α)⋅edit(x∣w)∑x′≠wedit(x′∣w)x∈C(w), x≠wP(x \mid w) = \begin{cases} \alpha & x = w \\ (1-\alpha)\cdot \dfrac{\text{edit}(x \mid w)}{\sum_{x' \neq w} \text{edit}(x' \mid w)} & x \in C(w),\ x \neq w \end{cases}
α for the typed word itself; the remaining 1 − α shared among the real edits, in proportion to their confusion-matrix probability (SLP3, after Mays et al.)α للكلمة المكتوبة نفسها؛ والباقي 1 − α يُوزَّع على التعديلات الحقيقية بنسبة احتمالها في مصفوفة الالتباس (SLP3، نقلًا عن Mays et al.)

Mays and colleagues first split 1 − α evenly among the other candidates. SLP3 replaces the even split with the confusion-matrix edit probabilities. Either way, the probabilities over all ways of typing w add up to one: α for no error, 1 − α for all errors together. Keep that sum in mind; it decides the puzzle at the end of this part.

وزّع Mays وزملاؤه في البداية 1 − α بالتساوي على المرشحات الأخرى. ثم استبدل SLP3 التوزيع المتساوي باحتمالات التعديل من مصفوفات الالتباس. وفي الحالتين، مجموع الاحتمالات على كل طرق كتابة w يساوي واحدا: α لعدم الخطأ، و1 − α لكل الأخطاء مجتمعة. احفظ هذا المجموع في ذهنك، فهو الذي يحسم اللغز في نهاية هذا الجزء.

Quick checkاختبار سريع

A system sets P(w|w) to .99. What does that say about the text it expects?نظام يضبط P(w|w) على .99. ماذا يقول ذلك عن النص الذي يتوقعه؟

Recall

Why did non-word correction never need P(w|w), while real-word correction does?لماذا لم يحتج تصحيح الكلمات غير الموجودة إلى P(w|w) أبدا، بينما يحتاجه تصحيح الكلمات الحقيقية؟

A non-word cannot be the intended word, so the typed string is never a candidate. A real word can be exactly what the writer meant, so it competes with its corrections and needs its own channel probability: the chance that it was typed without error.

الكلمة غير الموجودة لا يمكن أن تكون الكلمة المقصودة، فالنص المكتوب لا يكون مرشحا أبدا. أما الكلمة الحقيقية فقد تكون بالضبط ما قصده الكاتب، فهي تتنافس مع تصحيحاتها وتحتاج إلى احتمال قناة خاص بها: احتمال أنها كُتبت دون خطأ.

Peter Norvig worked this exact case. For the typed word x = thew he lists five intended words w: thew itself (an old word for muscle or sinew), and one candidate for each kind of single edit. For each, multiply the channel probability by a unigram prior.

عمل Peter Norvig على هذه الحالة بالذات. للكلمة المكتوبة x = thew يذكر خمس كلمات مقصودة w: thew نفسها (كلمة قديمة تعني العضلة أو الوتر)، ومرشحا واحدا لكل نوع من أنواع التعديل الواحد. لكل منها، اضرب احتمال القناة في احتمال مسبق من نوع unigram.

wwx|wx|wEditالتعديلP(x|w)P(x|w)P(w)P(w)10⁹ P(x|w) P(w)10⁹ P(x|w) P(w)
thetheew|eew|eInsertion: w typed after eإدراج (insertion): كُتبت w بعد e0.0000070.0000070.020.02140 (slide: 144)140 (في الشريحة: 144)
thewthewnoneلا يوجدNo edit: typed as intendedلا تعديل: كُتبت كما قُصدتα = 0.95α = 0.950.000000090.0000000985.5 (slide: 90)85.5 (في الشريحة: 90)
thawthawe|ae|aSubstitution: e typed for aاستبدال (substitution): كُتبت e مكان a0.0010.0010.00000070.00000070.70.7
threwthrewh|hrh|hrDeletion: r dropped after hحذف (deletion): سقطت r بعد h0.0000080.0000080.0000040.0000040.032 (slide: 0.03)0.032 (في الشريحة: 0.03)
thwethweew|weew|weTransposition: we typed as ewتبديل موضعين (transposition): كُتبت we على شكل ew0.0000030.0000030.000000040.000000040.00012 (slide: 0.0001)0.00012 (في الشريحة: 0.0001)
Norvig's thew example (slide 39), with the products recomputed from the displayed inputs, scaled by 10⁹مثال Norvig لكلمة thew (الشريحة 39)، مع إعادة حساب حواصل الضرب من المدخلات المعروضة، مضروبة في 10⁹

The x|w column uses the confusion-matrix notation: typed letters on the left, intended letters on the right. ew|e means the writer intended e and typed ew, an Insertion of w after e. e|a is a Substitution. h|hr means hr was intended and only h typed, a Deletion of r. ew|we is a Transposition. Each edit is conditioned on the letter before it, which is why ew|e carries the e along.

عمود x|w يستخدم ترميز مصفوفة الالتباس: الحروف المكتوبة على اليسار، والحروف المقصودة على اليمين. ew|e تعني أن الكاتب قصد e وكتب ew، أي insertion (إدراج) لـ w بعد e. وe|a هي substitution (استبدال). وh|hr تعني أن hr كانت مقصودة ولم يُكتب إلا h، أي deletion (حذف) لـ r. وew|we هي transposition (تبديل موضعين متجاورين). كل تعديل مشروط بالحرف الذي قبله، ولهذا تحمل ew|e الحرف e معها.

Worked exampleمثال محلول

Scoring the two leaders at α = .95حساب درجة المتصدّرَين عند α = .95

  1. The candidate theالمرشح the

    P(thew|the) × P(the) = 0.000007 × 0.02 = 1.4 × 10⁻⁷, which is 140 after scaling by 10⁹. The edit is rare, but the is the most common word in English.

    P(thew|the) × P(the) = 0.000007 × 0.02 = 1.4 × 10⁻⁷، أي 140 بعد الضرب في 10⁹. التعديل نادر، لكن the هي أكثر كلمة شيوعا في الإنجليزية.

  2. The candidate thewالمرشح thew

    P(thew|thew) × P(thew) = 0.95 × 0.00000009 = 8.55 × 10⁻⁸, which is 85.5. The channel is generous (no edit happened), but the word is rare.

    P(thew|thew) × P(thew) = 0.95 × 0.00000009 = 8.55 × 10⁻⁸، أي 85.5. القناة سخية (لم يحدث أي تعديل)، لكن الكلمة نادرة.

  3. The restالبقية

    thaw: 0.001 × 7 × 10⁻⁷ = 7 × 10⁻¹⁰ (0.7). threw: 8 × 10⁻⁶ × 4 × 10⁻⁶ = 3.2 × 10⁻¹¹ (0.032). thwe: 3 × 10⁻⁶ × 4 × 10⁻⁸ = 1.2 × 10⁻¹³ (0.00012).

    thaw: 0.001 × 7 × 10⁻⁷ = 7 × 10⁻¹⁰ (0.7). threw: 8 × 10⁻⁶ × 4 × 10⁻⁶ = 3.2 × 10⁻¹¹ (0.032). thwe: 3 × 10⁻⁶ × 4 × 10⁻⁸ = 1.2 × 10⁻¹³ (0.00012).

  4. Resultالنتيجة

    the wins with 140 against 85.5, a ratio of about 1.6. The corrector rewrites two of thew as two of the, the best path of slide 35.
    تفوز the بـ 140 مقابل 85.5، أي بنسبة تقارب 1.6. فيعيد المصحِّح كتابة two of thew على أنها two of the، وهو أفضل مسار في الشريحة 35.

Could a different α make thew win?هل يمكن لقيمة مختلفة من α أن تجعل thew تفوز؟

Read the formula naively, with the edit probabilities held fixed and only α moving. thew wins when α × 9 × 10⁻⁸ > 1.4 × 10⁻⁷, which needs α > 1.56. A probability cannot exceed one, so under that reading the wins for every α.

اقرأ الصيغة قراءة ساذجة، مع تثبيت احتمالات التعديل وتحريك α وحدها. تفوز thew عندما α × 9 × 10⁻⁸ > 1.4 × 10⁻⁷، وهذا يتطلب α > 1.56. والاحتمال لا يمكن أن يتجاوز واحدا، فبهذه القراءة تفوز the مع كل قيمة لـ α.

But the previous concept showed that α and the edits share one total: the edits get 1 − α. The 0.000007 for ew|e was estimated with 1 − α = 0.05. If the writer is more careful, every edit becomes less likely too, so the edit probability scales by (1 − α) / 0.05. Now the comparison is

لكن المفهوم السابق بيّن أن α والتعديلات تتقاسم مجموعا واحدا: التعديلات تحصل على 1 − α. القيمة 0.000007 لـ ew|e قُدّرت عند 1 − α = 0.05. فإذا كان الكاتب أكثر حرصا، يصبح كل تعديل أقل احتمالا أيضا، فيُضرب احتمال التعديل في (1 − α) / 0.05. وتصبح المقارنة الآن

1.4×10−7⋅1−α0.05⏟the  <  9×10−8 α⏟thew  ⟺  α>2.8×10−62.8×10−6+9×10−8≈0.969\underbrace{1.4\times10^{-7}\cdot\frac{1-\alpha}{0.05}}_{\text{the}} \;<\; \underbrace{9\times10^{-8}\,\alpha}_{\text{thew}} \iff \alpha > \frac{2.8\times10^{-6}}{2.8\times10^{-6}+9\times10^{-8}} \approx 0.969
With the edits sharing 1 − α, thew wins once errors are rarer than about 1 in 32 wordsحين تتقاسم التعديلات 1 − α، تفوز thew بمجرد أن تصبح الأخطاء أندر من نحو خطأ واحد في كل 32 كلمة

That is Norvig's own remark: had he assumed one error in fifty words (α = .98), thew would have become the most probable answer. Check it: the = 1.4 × 10⁻⁷ × 0.4 = 5.6 × 10⁻⁸, and thew = 0.98 × 9 × 10⁻⁸ = 8.8 × 10⁻⁸. SLP3 makes the same point: when α is high enough, the model may decide thew was intended. The other lever is the prior. In a corpus about anatomy or old poetry, P(thew) would be larger, and α would tip the balance much earlier.

وهذه ملاحظة Norvig نفسه: لو افترض خطأ واحدا في كل خمسين كلمة (α = .98)، لأصبحت thew هي الجواب الأعلى احتمالا. تحقق من ذلك: the = 1.4 × 10⁻⁷ × 0.4 = 5.6 × 10⁻⁸، وthew = 0.98 × 9 × 10⁻⁸ = 8.8 × 10⁻⁸. ويقول SLP3 الشيء نفسه: عندما تكون α مرتفعة بما يكفي، قد يقرر النموذج أن thew هي المقصودة. والرافعة الأخرى هي الاحتمال المسبق. في مدوّنة عن التشريح أو الشعر القديم، تكون P(thew) أكبر، فتقلب α الكفة في وقت أبكر بكثير.

SimulatorمحاكيTwo of thew: the lattice, α and the winning sentenceTwo of thew: الشبكة وα والجملة الفائزة
0.950
Sentences searched91 + 3 + 2 + 3
Winning sentencetwo of thehighest P(x|w) P(w) in the thew slotأعلى P(x|w) P(w) في خانة thew
thew wins whenneverneeds α above 1, impossibleتحتاج α أكبر من 1، وهذا مستحيل
weditP(x|w)P(w)10⁹ score
theew|e insertion of w after e7.0e-62e-2140.0
thewnone typed as intended0.9509e-885.5
thawe|a substitution of e for a1.0e-37e-70.7000
threwh|hr deletion of r after h8.0e-64e-60.0320
thweew|we transposition of we3.0e-64e-81.20e-4

Only the thew slot is scored, with the unigram priors and edit probabilities from slide 39. In the shared mode, every edit probability is rescaled by (1 − α) / 0.05, so the edits together always keep the probability that α leaves over. Bars use a log scale.تُحسب الدرجة لخانة thew وحدها، باستخدام احتمالات unigram المسبقة واحتمالات التعديل من الشريحة 39. في الوضع المشترك يُعاد تحجيم كل احتمال تعديل بالمعامل (1 − α) / 0.05، فتحتفظ التعديلات مجتمعةً دائمًا بالاحتمال الذي تتركه α. تستخدم الأشرطة مقياسًا لوغاريتميًا.

Try it. With “Edits fixed”, slide α from .90 to .995: thew climbs from 81 to about 90 but never reaches 140. Switch to “Edits share 1 − α” and the the score falls as α rises, until the winning sentence flips to two of thew just below α = .97. Toggle the search space to watch the lattice shrink from 48 paths to 9.

جرّبها. مع خيار «Edits fixed» (التعديلات ثابتة)، حرّك α من .90 إلى .995: ترتفع thew من 81 إلى نحو 90 لكنها لا تصل أبدا إلى 140. انتقل إلى «Edits share 1 − α» (التعديلات تتقاسم 1 − α) فتنخفض درجة the كلما ارتفعت α، حتى تنقلب الجملة الفائزة إلى two of thew قبل α = .97 بقليل. بدّل فضاء البحث لترى الشبكة تتقلص من 48 مسارا إلى 9.

Recall

Name the edit behind each of the, thaw, threw and thwe as corrections of thew.سمِّ التعديل الذي وراء كل من the وthaw وthrew وthwe بوصفها تصحيحات لـ thew.

the: insertion of w after e (ew|e). thaw: substitution of e for a (e|a). threw: deletion of r after h (h|hr). thwe: transposition of we into ew (ew|we).

the: إدراج (insertion) لـ w بعد e (ew|e). thaw: استبدال (substitution) e مكان a (e|a). threw: حذف (deletion) لـ r بعد h (h|hr). thwe: تبديل موضعين (transposition) لـ we إلى ew (ew|we).

Quick checkاختبار سريع

Edits share 1 − α. Raising α from .95 to .99 does what to the thew decision?التعديلات تتقاسم 1 − α. ماذا يحدث لقرار thew عند رفع α من .95 إلى .99؟

Recapالخلاصة

If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا

  • Each typed word gets a candidate set: itself plus real words one edit away. Stack the sets in columns and every left-to-right path is a candidate sentence: the candidate lattice.كل كلمة مكتوبة تحصل على مجموعة مرشحات (candidate set): الكلمة نفسها مع الكلمات الحقيقية التي تبعد عنها تعديلا واحدا. ضع المجموعات في أعمدة متجاورة، فيصبح كل مسار من اليسار إلى اليمين جملة مرشحة: هذه هي شبكة المرشحات (candidate lattice).
  • The full lattice for two of thew holds 4 × 3 × 4 = 48 sentences, and the count multiplies with sentence length.الشبكة الكاملة لعبارة two of thew تحتوي على 4 × 3 × 4 = 48 جملة، والعدد يتضاعف بالضرب كلما طالت الجملة.
  • One error per sentence keeps only the typed sentence plus every single-word substitution: 1 + 3 + 2 + 3 = 9. The count now adds instead of multiplying.افتراض خطأ واحد في كل جملة يُبقي فقط الجملة المكتوبة مع كل استبدال لكلمة واحدة: 1 + 3 + 2 + 3 = 9. صار العدد يُجمع بدل أن يُضرب.
  • Each candidate sentence W is scored by P(X|W) P(W): a language model (unigram, bigram, trigram) for P(W), and the non-word channel model for the changed word.كل جملة مرشحة W تُقيَّم بـ P(X|W) P(W): نموذج لغوي (unigram أو bigram أو trigram) لـ P(W)، ونموذج القناة نفسه المستخدم للكلمات غير الموجودة للكلمة التي تغيّرت.
  • Real words need one more channel value, P(w|w) = α, the probability that a word was typed as intended. α is set by the application: .90, .95, .99, .995 mean 1 error in 10, 20, 100, 200 words.الكلمات الحقيقية تحتاج إلى قيمة قناة إضافية، P(w|w) = α، وهي احتمال أن الكلمة كُتبت كما قُصدت. التطبيق هو الذي يحدد α: القيم .90 و.95 و.99 و.995 تعني خطأ واحدا في كل 10 و20 و100 و200 كلمة.
  • Norvig's thew table at α = .95 gives the = 0.000007 × 0.02 = 1.4 × 10⁻⁷ against thew = 0.95 × 9 × 10⁻⁸ = 8.55 × 10⁻⁸, so the wins.جدول Norvig لكلمة thew عند α = .95 يعطي the = 0.000007 × 0.02 = 1.4 × 10⁻⁷ مقابل thew = 0.95 × 9 × 10⁻⁸ = 8.55 × 10⁻⁸، لذلك تفوز the.
  • Raising α alone cannot rescue thew while the edit probabilities stay fixed. If the edits share the leftover 1 − α, as Norvig and SLP3 intend, thew wins above about α = .969.رفع α وحده لا ينقذ thew ما دامت احتمالات التعديلات ثابتة. أما إذا تقاسمت التعديلات الباقي 1 − α، كما يقصد Norvig وSLP3، فإن thew تفوز عندما تتجاوز α قرابة .969.

Sourcesالمصادر

Part 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)، والتعديلات الأغنى، وخصائص لوحة المفاتيح والسياق في القناة، والمصنِّفات للأزواج الملتبسة.

5 concepts5 مفاهيم, ، slides 40-48الشرائح 40-48

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في نهاية هذا الجزء ستستطيع

  1. Map the confidence of the best candidate to one of four interface actions: autocorrect, best suggestion, suggestion list, or flag.اربط ثقة النظام بأفضل مرشح بواحد من أربعة إجراءات في الواجهة: التصحيح التلقائي (autocorrect)، أو عرض أفضل اقتراح، أو عرض قائمة اقتراحات، أو مجرد التمييز (flag).
  2. 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)^λ، واكتب المعادلة بصيغة الضرب وبصيغة اللوغاريتم، وبيّن من أين تأتي λ.
  3. Compute how λ changes the acress ranking, including the λ at which across overtakes actress.احسب كيف تغيّر λ ترتيب مرشحي acress، بما في ذلك قيمة λ التي تتجاوز عندها across كلمة actress.
  4. 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 المرشحين ويقيّمهم حسب الصوت.
  5. 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).
  6. 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) على أنها خطأ.

The confidence ladder: confidence falls from top to bottom, and the interface intervenes lessسلّم الثقة: تنخفض الثقة من الأعلى إلى الأسفل، ويقل تدخل الواجهة
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لا يُعرض أي تخمين، فلا يمكن لقائمة مرشحين سيئة أن تضلل
Why each rung matches its confidenceلماذا تناسب كل درجة مستوى ثقتها

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) بضربهما أبدًا، بل تزنهما.

w^=argmax⁡w∈V  P(x∣w) P(w)λ\hat{w} = \operatorname*{argmax}_{w \in V} \; P(x \mid w)\,P(w)^{\lambda}
Weighted noisy channel: the prior is raised to a power λالقناة المشوشة الموزونة: يُرفع الاحتمال المسبق إلى القوة λ
w^=argmax⁡w∈V  log⁡P(x∣w)+λlog⁡P(w)\hat{w} = \operatorname*{argmax}_{w \in V} \; \log P(x \mid w) + \lambda \log P(w)
The same rule in log space: λ scales the language model's voteالقاعدة نفسها في الفضاء اللوغاريتمي: λ تحجّم صوت نموذج اللغة

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)

  1. 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.
  2. 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 في الشريحة.
  3. 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)، فكل زيادة في λ توسّع تقدّمها.
  4. 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 أولًا.
  5. 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 مقابل acrossReadingالتفسير
00actressactressactress leads across by about 12.6×تتقدم actress على across بنحو 12.6×Channel only: the cheapest edit winsالقناة وحدها: يفوز أرخص تعديل
0.50.5actressactressactress leads across by about 3.5×تتقدم actress على across بنحو 3.5×Prior counts, but too weakly to overturn the channelالاحتمال المسبق يُحتسب، لكن بضعف لا يكفي لقلب حكم القناة
11acrossacrossacross 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 في جدول الشريحة
22acrossacrossacross leads actress by about 13×تتقدم across على actress بنحو 13×Prior doubled: frequent words pull further aheadالاحتمال المسبق مضاعف: تبتعد الكلمات الشائعة أكثر في الصدارة
Winner on acress as λ changes (acres rows summed)الفائز في acress مع تغيّر λ (بعد جمع صفّي acres)

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، لأن احتمال القناة لهما مرتفع.

SimulatorمحاكيRe-rank acress as lambda growsأعد ترتيب مرشحي acress مع زيادة lambda
1.00

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 في جدول الشريحة في احتمال قناة واحد.

  1. across-8.56
  2. actress-8.57
  3. acres-8.68
  4. access-10.72
  5. caress-11.55
  6. cress-12.11
Winneracross
Lead over runner-up1.03×over actressعلى actress
across overtakes actress at0.989λwhere the two log scores are equalحيث تتساوى الدرجتان اللوغاريتميتان

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 يصفه بأنه تقريب خشن لطريقة نطق الكلمة. المهم أن الكلمات المتشابهة في النطق تميل إلى الالتقاء على المفتاح نفسه.

Metaphone step by step: knight becomes NT, and so does the misspelling niteMetaphone خطوة بخطوة: تصبح knight هي NT، وكذلك الخطأ الإملائي nite

Worked exampleمثال محلول

Metaphone key for knight and niteمفتاح Metaphone لكلمتي knight وnite

  1. Initial KNKN في بداية الكلمة

    knight begins with KN, so drop the first letter: NIGHT.
    تبدأ knight بـ KN، لذلك احذف الحرف الأول: NIGHT.
  2. 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.
  3. H after a vowelH بعد حرف علة

    H follows I and is not before a vowel, so drop it: NIT.
    حرف H يأتي بعد I وليس قبل حرف علة، لذلك احذفه: NIT.
  4. Vowelsحروف العلة

    Drop vowels that are not first: NT.
    احذف حروف العلة التي ليست في أول الكلمة: NT.
  5. 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) له، مثلًا:

P(fisikle∣physical)≈P(f∣ph) P(i∣y) P(s∣s) P(i∣i) P(k∣c) P(le∣al)P(\textit{fisikle} \mid \textit{physical}) \approx P(f \mid ph)\,P(i \mid y)\,P(s \mid s)\,P(i \mid i)\,P(k \mid c)\,P(le \mid al)
One partition of physical, each piece typed with its own edit probabilityتجزئة واحدة لكلمة physical، وكل قطعة تُكتب باحتمال تعديل خاص بها

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
Factors that influence the channel probabilityالعوامل التي تؤثر في احتمال القناة

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 (الإصبع الأوسط الأيمن) رغم تباعدهما. والقناة التي تعرف ترتيب لوحة المفاتيح تستطيع أن تضع الكتلة الاحتمالية بالضبط حيث تنزلق الأصابع.

Intended E: neighbours W, R, S and D are the likeliest slips, and I is its homologous keyالحرف المقصود E: جيرانه W وR وS وD هي الزلّات الأرجح، وI هو مفتاحه المتماثل (homologous) في اليد الأخرى

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-gramConfusion-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دقيق جدًا على زوجه
Noisy channel versus pair classifier for real-word errorsالقناة المشوشة مقابل مصنّف الزوج لأخطاء الكلمات الحقيقية

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المصادر