Majid Al-RaimiWhat counts as a wordما الذي يُعد كلمة

ICS 582Lecture 02المحاضرة 02Part 01الجزء 01

What counts as a wordما الذي يُعد كلمة

Why a word is not a universal unit, the difference between tokens and types, how corpus vocabularies compare, and the preprocessing decisions every tokenizer must make.لماذا الكلمة ليست وحدة عالمية، والفرق بين الرموز (tokens) والأنواع (types)، وكيف تُقارن مفردات المدونات، وقرارات المعالجة المسبقة التي يجب أن يتخذها كل مُقسِّم (tokenizer).

Conceptsالمفاهيم
4
Slidesالشرائح
1-10
Readingمدة القراءة
24 min24 دقيقة
Understoodما فهمته
0/4 conceptsمفاهيم

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

Every count, probability, embedding table and cost estimate in NLP starts from a decision about what a unit is. Before a language model can predict the next token, before a retrieval system can index a document, and before Zipf or Heaps can be plotted, someone has to say where one unit ends and the next begins.

This part makes that decision visible. It starts from a sentence that has no single word count, gives you the two definitions every later formula depends on (token and type), reads one famous table of corpus sizes, and finishes with the checklist of preprocessing choices a tokenizer must make. Your research pipeline will fix a tokenization policy once, and every N, |V| and sequence length downstream inherits it. Exams ask for token and type counts under a stated policy and for the consequences of each preprocessing choice.

كل عدّ، وكل احتمال، وكل جدول تضمينات (embedding table)، وكل تقدير للتكلفة في معالجة اللغات الطبيعية يبدأ من قرار حول ماهية الوحدة. قبل أن يتنبأ نموذج اللغة بالوحدة النصية التالية، وقبل أن يفهرس نظام الاسترجاع مستندًا، وقبل أن نرسم قانون Zipf أو Heaps، لا بد أن يحدد أحدٌ أين تنتهي وحدة وأين تبدأ التي تليها.

هذا الجزء يجعل ذلك القرار مرئيًا. يبدأ من جملة ليس لها عدد كلمات واحد، ثم يعطيك التعريفين اللذين تعتمد عليهما كل صيغة لاحقة (الوحدة النصية token والنوع type)، ثم يقرأ جدولًا شهيرًا لأحجام المدونات، وينتهي بقائمة اختيارات المعالجة المسبقة التي يجب أن يحسمها أي مقطِّع (tokenizer). ستثبّت سلسلة المعالجة في بحثك سياسة تقطيع مرة واحدة، وكل N و|V| وطول تسلسل بعدها يرث تلك السياسة. الاختبارات تطلب عدد الوحدات النصية والأنواع وفق سياسة محددة، وتطلب نتائج كل اختيار من اختيارات المعالجة المسبقة.

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

  1. State the token and type definitions and compute N and |V| for a given string under a stated policy for case and punctuation.أن تذكر تعريفَي الوحدة النصية (token) والنوع (type)، وتحسب N و|V| لنص معطى وفق سياسة محددة للتعامل مع حالة الأحرف وعلامات الترقيم.
  2. Explain why the same sentence has 16 or 18 tokens and 14 or 16 types depending on the policy, and why speech transcripts may keep uh and main-.أن تشرح لماذا تحتوي الجملة نفسها على 16 أو 18 وحدة نصية و14 أو 16 نوعًا بحسب السياسة المتبعة، ولماذا قد تُبقي نصوص الكلام المفرّغ على uh وmain-.
  3. Read the SLP3 corpus table, compute the type to token ratio, and explain both the falling ratio and the Switchboard genre effect.أن تقرأ جدول المدونات في SLP3، وتحسب نسبة الأنواع إلى الوحدات النصية، وتشرح سبب انخفاض هذه النسبة وأثر النوع الأدبي في Switchboard.
  4. Name the four preprocessing decisions and the four ambiguous boundaries, with one downstream consequence each, and state the Penn Treebank convention.أن تسمّي قرارات المعالجة المسبقة الأربعة والحدود الملتبسة الأربعة مع نتيجة لاحقة واحدة لكل منها، وأن تذكر اصطلاح Penn Treebank.

The whole lecture answers one question: what unit does a model operate on, and how do we get from raw bytes to that unit? Everything else is a stop on the way. The roadmap has eight stops, and it is worth holding the shape in mind because the lecture overview page mirrors it exactly.

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

  1. Words, with Zipf and Heaps. How to count units, and the two laws that govern how frequency and vocabulary behave as a corpus grows.الكلمات، مع قانونَي Zipf وHeaps. كيف نعدّ الوحدات، والقانونان اللذان يحكمان سلوك التكرار والمفردات كلما كبرت المدونة.
  2. Morphemes. The meaningful parts inside a word, which explain why walk, walks and walked are one lemma but three types.المورفيمات (Morphemes). الأجزاء ذات المعنى داخل الكلمة، وهي التي تفسر لماذا تكون walk وwalks وwalked أصلًا معجميًا (lemma) واحدًا لكنها ثلاثة أنواع (types).
  3. Corpora. Where the text comes from, and why genre, domain and time shift every count in this part.المدونات النصية (Corpora). من أين يأتي النص، ولماذا يغيّر النوع الأدبي والمجال والزمن كل رقم في هذا الجزء.
  4. Unicode. How characters become bytes, so that a tokenizer can promise to represent any script without an unknown symbol.يونيكود (Unicode). كيف تتحول الحروف إلى بايتات، حتى يستطيع المقطِّع (tokenizer) أن يضمن تمثيل أي نظام كتابة دون رمز مجهول.
  5. Tokenization with BPE. The algorithm that learns its own units from data instead of trusting spaces.التقطيع (Tokenization) باستخدام BPE. الخوارزمية التي تتعلم وحداتها بنفسها من البيانات بدلًا من الوثوق بالمسافات.
  6. Sentence segmentation. The period that ends a sentence versus the period inside Dr. or U.S.تقسيم الجمل (Sentence segmentation). النقطة التي تنهي الجملة مقابل النقطة الموجودة داخل Dr. أو U.S.
  7. Regular expressions. The pattern language behind pre-tokenizers, cleaners and feature extractors.التعبيرات النمطية (Regular expressions). لغة الأنماط التي تقوم عليها مراحل ما قبل التقطيع (pre-tokenizers) وأدوات تنظيف النص ومستخرجات السمات.
  8. Minimum edit distance. A distance between strings that scores spelling correction and speech recognizers alike.أدنى مسافة تحرير (Minimum edit distance). مقياس للمسافة بين سلسلتين نصيتين يُستخدم لتقييم التصحيح الإملائي وأنظمة التعرف على الكلام على حد سواء.

The first stop carries Zipf's law and Heaps' law. The second is the Morpheme. The third is the Corpus. The fourth turns a Code point into UTF-8 bytes. The fifth is Tokenization and byte-pair encoding. Then come Sentence segmentation, the Regular expression and, finally, Minimum edit distance. This part covers only the opening of the first stop, but it sets the vocabulary every later part reuses.

المحطة الأولى تحمل Zipf's law (قانون Zipf) وHeaps' law (قانون Heaps). والثانية هي المورفيم (morpheme). والثالثة هي المدونة النصية (corpus). والرابعة تحوّل نقطة الترميز (code point) إلى بايتات UTF-8. والخامسة هي التقطيع (tokenization) وترميز أزواج البايتات (byte-pair encoding). ثم يأتي تقسيم الجمل (sentence segmentation)، والتعبير النمطي (regular expression)، وأخيرًا أدنى مسافة تحرير (minimum edit distance). هذا الجزء يغطي بداية المحطة الأولى فقط، لكنه يضع المفردات التي يعيد كل جزء لاحق استخدامها.

The seven learning goals on slide 3 map onto the same stops: know why a word is not a universal unit, distinguish types from tokens and explain why vocabulary keeps growing, know what morphemes are, explain Unicode and byte-level processing, describe BPE and tokenizer design choices, use regular expressions, and compute minimum edit distance with dynamic programming. The first two goals are this part.

أهداف التعلم السبعة في الشريحة 3 ترتبط بالمحطات نفسها: أن تعرف لماذا ليست الكلمة وحدة عالمية، وأن تميّز الأنواع (types) من الوحدات النصية (tokens) وتشرح لماذا تستمر المفردات في النمو، وأن تعرف ما المورفيمات، وأن تشرح Unicode والمعالجة على مستوى البايت، وأن تصف BPE وخيارات تصميم المقطِّع، وأن تستخدم التعبيرات النمطية، وأن تحسب أدنى مسافة تحرير بالبرمجة الديناميكية (dynamic programming). الهدفان الأولان هما موضوع هذا الجزء.

Recall

Name the eight stops of the lecture roadmap in order.اذكر محطات خريطة طريق المحاضرة الثماني بالترتيب.

Words (Zipf and Heaps), morphemes, corpora, Unicode, tokenization (BPE), sentence segmentation, regular expressions, minimum edit distance.
الكلمات (Zipf وHeaps)، والمورفيمات، والمدونات، وUnicode، والتقطيع (BPE)، وتقسيم الجمل، والتعبيرات النمطية، وأدنى مسافة تحرير.

Count the words in this sentence before reading on: They picnicked by the pool, then lay back on the grass and looked at the stars. Most people say sixteen. Some say eighteen. Both are right, and the reason they can both be right is the subject of this concept.

عُدّ الكلمات في هذه الجملة قبل أن تكمل القراءة: They picnicked by the pool, then lay back on the grass and looked at the stars. معظم الناس يقولون ست عشرة. وبعضهم يقول ثماني عشرة. كلاهما صحيح، وسبب إمكان صحة الإجابتين معًا هو موضوع هذا المفهوم.

Worked exampleمثال محلول

Counting the picnic sentence three waysعدّ جملة النزهة بثلاث طرق

  1. Split on spacesالتقسيم عند المسافات

    Sixteen pieces: They, picnicked, by, the, pool,, then, lay, back, on, the, grass, and, looked, at, the, stars. The comma and the period ride along inside the pieces they touch.
    ست عشرة قطعة: They، picnicked، by، the، pool,، then، lay، back، on، the، grass، and، looked، at، the، stars. الفاصلة والنقطة تبقيان ملتصقتين بالقطعتين اللتين تلامسانهما.
  2. Give punctuation its own placeامنح علامات الترقيم مكانًا مستقلًا

    Cut the comma off pool and the period off stars. Now there are eighteen units. Jurafsky and Martin note that large language models generally count punctuation as separate words, so eighteen is the modern default rather than a quirk.
    افصل الفاصلة عن pool والنقطة عن stars. الآن أصبح لدينا ثماني عشرة وحدة. ويلاحظ Jurafsky وMartin أن نماذج اللغة الكبيرة تعدّ علامات الترقيم عمومًا كلمات منفصلة، لذلك فإن ثماني عشرة هي الافتراض الحديث وليست حالة شاذة.
  3. Collapse repeatsادمج المتكررات

    the occurs three times. Counting each distinct item once gives fourteen distinct words without punctuation, or sixteen if the comma and the period are counted as distinct items too.
    تظهر the ثلاث مرات. عدّ كل عنصر مميز مرة واحدة يعطي أربع عشرة كلمة مميزة دون علامات الترقيم، أو ست عشرة إذا عُدّت الفاصلة والنقطة عنصرين مميزين أيضًا.
  4. Lowercaseتحويل الأحرف إلى صغيرة

    Folding They to they changes nothing here, because no other they appears. In another sentence it would merge two distinct items into one.
    تحويل They إلى they لا يغيّر شيئًا هنا، لأنه لا توجد they أخرى في الجملة. أما في جملة أخرى فقد يدمج عنصرين مميزين في عنصر واحد.
  5. Four answers, one sentenceأربع إجابات، جملة واحدة

    PolicyالسياسةTokens Nالوحدات النصية NTypes |V|الأنواع |V|
    Whitespace onlyالمسافات فقط16161414
    Punctuation splitفصل علامات الترقيم18181616
    The picnic sentence under two counting policiesجملة النزهة وفق سياستين للعدّ
    The sentence never changed. The counting policy did.
    PolicyالسياسةTokens Nالوحدات النصية NTypes |V|الأنواع |V|
    Whitespace onlyالمسافات فقط16161414
    Punctuation splitفصل علامات الترقيم18181616
    The picnic sentence under two counting policiesجملة النزهة وفق سياستين للعدّ
    الجملة لم تتغير. الذي تغيّر هو سياسة العدّ.
The picnic sentence segmented by a punctuation-aware policy: seventeen boundaries, the three teal ones isolating the comma and the period, giving 18 tokens and 16 typesجملة النزهة مقسّمة وفق سياسة تراعي علامات الترقيم: سبعة عشر حدًا، الثلاثة الخضراء المزرقّة منها تعزل الفاصلة والنقطة، فتنتج 18 وحدة نصية (tokens) و16 نوعًا (types)

In many writing systems spaces suggest boundaries, but a space is only a suggestion. The moment you want a number, you have to decide what to do with everything that a space does not settle, and each decision is tied to what the text is for. Splitting text into units is Tokenization, and the resulting units are tokens. Jurafsky and Martin put it plainly: how we define words depends on the task. The table below pairs each question from the slide with a task that answers yes and a task that answers no.

في كثير من أنظمة الكتابة توحي المسافات بالحدود، لكن المسافة مجرد إيحاء. فبمجرد أن تريد رقمًا، عليك أن تقرر ماذا تفعل بكل ما لا تحسمه المسافة، وكل قرار مرتبط بالغرض من النص. تقسيم النص إلى وحدات هو التقطيع (tokenization)، والوحدات الناتجة هي الوحدات النصية (tokens). ويقولها Jurafsky وMartin بوضوح: طريقة تعريفنا للكلمات تعتمد على المهمة. الجدول أدناه يقرن كل سؤال من الشريحة بمهمة تجيب بنعم ومهمة تجيب بلا.

QuestionالسؤالA task that says yesمهمة تجيب بنعمA task that says noمهمة تجيب بلا
Is punctuation its own token?هل علامة الترقيم وحدة نصية مستقلة؟Language models and parsers, where a period or a question mark carries meaningنماذج اللغة والمحللات النحوية، حيث تحمل النقطة أو علامة الاستفهام معنىBag-of-words retrieval, where punctuation only adds noiseالاسترجاع بحقيبة الكلمات (bag-of-words)، حيث لا تضيف علامات الترقيم إلا ضوضاء
Do we lowercase?هل نحوّل الأحرف إلى صغيرة؟Information retrieval, where a query rarely matches the case of the documentاسترجاع المعلومات، حيث نادرًا ما يطابق الاستعلام حالة الأحرف في المستندNamed entity recognition and part-of-speech tagging, where a capital is evidenceالتعرف على الكيانات المسماة ووسم أقسام الكلام، حيث يكون الحرف الكبير دليلًا
How do we treat numbers, URLs, emojis, hashtags?كيف نتعامل مع الأرقام والروابط والرموز التعبيرية والوسوم؟Social media analysis keeps #NLP and emojis whole because they carry sentimentتحليل وسائل التواصل الاجتماعي يُبقي #NLP والرموز التعبيرية كاملة لأنها تحمل المشاعرA grammar checker may replace every number by one placeholderمدقق القواعد قد يستبدل كل رقم بعنصر نائب واحد
Do we keep disfluencies?هل نُبقي على تعثرات الكلام؟Speech recognition, where uh predicts a restart and identifies the speakerالتعرف على الكلام، حيث تتنبأ uh بإعادة البدء وتساعد على تحديد هوية المتحدثParsing and translation, which want the fluent sentence underneathالتحليل النحوي والترجمة، اللذان يريدان الجملة السليمة الكامنة تحتها
Tokenization questions and the tasks that answer them differentlyأسئلة التقطيع والمهام التي تجيب عنها بشكل مختلف

Speech: where the units fall apartالكلام المنطوق: حيث تتفكك الوحدات

Written text at least offers spaces. A transcript of spontaneous speech offers something stranger. Consider the utterance I do uh main- mainly business data processing. There is a broken-off word, main-, which Jurafsky and Martin call a fragment, and a filler, uh, which they call a filled pause. Together these are a Disfluency. Should a tokenizer keep them?

النص المكتوب يقدم المسافات على الأقل. أما تفريغ الكلام العفوي فيقدم شيئًا أغرب. تأمل العبارة I do uh main- mainly business data processing. فيها كلمة مبتورة هي main-، يسميها Jurafsky وMartin جزءًا مبتورًا (fragment)، وفيها حشوة هي uh، يسميانها وقفة مملوءة (filled pause). ومعًا يشكلان ما يسمى تعثر الكلام (disfluency). فهل ينبغي للمقطِّع أن يحتفظ بهما؟

For speech recognition the answer is yes, and for a reason that surprises people: fillers help predict the upcoming word, because they signal that the speaker is restarting the clause or idea, and they are a cue to speaker identification. Clark and Fox Tree went further and argued that uh and um are conventional English words: uh announces an expected minor delay, um a major one. A parser or a translation system, on the other hand, wants the fluent sentence underneath, so it drops them. The Switchboard portion of the Penn Treebank release is explicitly annotated for disfluencies, so this decision is built into a real corpus, not a thought experiment.

بالنسبة للتعرف على الكلام فالإجابة نعم، ولسبب يفاجئ الناس: الحشوات تساعد على التنبؤ بالكلمة القادمة، لأنها تشير إلى أن المتحدث يعيد بدء الجملة أو الفكرة، كما أنها دليل يساعد على تحديد هوية المتحدث. وذهب Clark وFox Tree أبعد من ذلك، فقالا إن uh وum كلمتان إنجليزيتان متعارف عليهما: uh تعلن عن تأخير بسيط متوقع، وum عن تأخير كبير. أما المحلل النحوي (parser) أو نظام الترجمة فيريد الجملة السليمة الكامنة تحتها، لذلك يحذفهما. والجزء الخاص بـ Switchboard في إصدار Penn Treebank موسوم صراحة بتعثرات الكلام، فهذا القرار مبني داخل مدونة حقيقية، وليس تجربة ذهنية.

Languages with no spaces at allلغات بلا مسافات على الإطلاق

The space is a convention of some scripts, not of language. Chinese, Japanese and Thai are written without spaces between words, so there is no orthographic word to count. Jurafsky and Martin give a Chinese sentence about Yao Ming reaching the finals and show that its units depend on which standard you adopt. Chinese words average only 1.5 to 1.9 characters, so the character is often the practical unit, and the question "how many words?" simply has no answer until a segmentation standard is chosen.

المسافة عُرف في بعض أنظمة الكتابة، وليست من طبيعة اللغة. فالصينية واليابانية والتايلاندية تُكتب دون مسافات بين الكلمات، فلا توجد كلمة إملائية لنعدّها. ويعرض Jurafsky وMartin جملة صينية عن وصول Yao Ming إلى النهائيات، ويبيّنان أن وحداتها تعتمد على المعيار الذي تعتمده. متوسط طول الكلمة الصينية 1.5 إلى 1.9 حرف فقط، لذلك يكون الحرف في الغالب هو الوحدة العملية، والسؤال «كم كلمة؟» ببساطة لا جواب له حتى يُختار معيار للتقسيم.

One Chinese sentence, three counts (SLP3 section 2.1)جملة صينية واحدة، ثلاثة أعداد (SLP3، القسم 2.1)

Chinese Treebank standardمعيار Chinese Treebank
3 words3 كلمات
Peking University standardمعيار جامعة بكين (Peking University)
5 words5 كلمات
Charactersالحروف
7 units7 وحدات

Recall

How many tokens and types does the picnic sentence have without punctuation, and with it?كم عدد الوحدات النصية (tokens) والأنواع (types) في جملة النزهة دون علامات الترقيم، وكم عددها معها؟

16 tokens and 14 types without punctuation (the occurs three times); 18 tokens and 16 types once the comma and the period count as tokens.
16 وحدة نصية و14 نوعًا دون علامات الترقيم (لأن the تظهر ثلاث مرات)؛ و18 وحدة نصية و16 نوعًا عندما تُعدّ الفاصلة والنقطة وحدتين نصيتين.

Recall

Give two reasons Jurafsky and Martin give for keeping uh and um in speech recognition.اذكر سببين يقدمهما Jurafsky وMartin للإبقاء على uh وum في التعرف على الكلام.

They help predict the upcoming word, because they signal that the speaker is restarting the clause or idea, and they are a cue to speaker identification. Clark and Fox Tree add that uh signals a minor delay and um a major one.
أنهما تساعدان على التنبؤ بالكلمة القادمة، لأنهما تشيران إلى أن المتحدث يعيد بدء الجملة أو الفكرة، وأنهما دليل على هوية المتحدث. ويضيف Clark وFox Tree أن uh تشير إلى تأخير بسيط وum إلى تأخير كبير.

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

Which of these is a reason a speech recognizer keeps the filler uh while a parser drops it?أيٌّ من الآتي سببٌ لاحتفاظ نظام التعرف على الكلام بالحشوة uh بينما يحذفها المحلل النحوي؟

Once a policy is fixed, two numbers describe any text. Take Hamlet's to be or not to be. Six units are written down in order. Only four different ones appear, because to and be each occur twice. Those two numbers have names, and the whole of corpus statistics is built on them.

بمجرد تثبيت السياسة، يصف أي نص رقمان. خذ عبارة هاملت to be or not to be. هناك ست وحدات مكتوبة بالترتيب. ولا يظهر منها إلا أربع مختلفة، لأن to وbe تتكرر كل منهما مرتين. لهذين الرقمين اسمان، وعليهما يقوم علم إحصاءات المدونات كله.

A Token is one occurrence of a unit in running text, and the total count of tokens is written N. A Type is a distinct vocabulary item, and the number of types is the size of the Vocabulary, written |V|. So to be or not to be has N = 6 tokens and |V| = 4 types: to, be, or, not. The two are tied together by a bookkeeping identity: every token belongs to exactly one type, so the type counts add up to the token count.

الوحدة النصية (token) هي ظهور واحد لوحدة في النص الجاري، ويُرمز لإجمالي عدد الوحدات النصية بـ N. والنوع (type) هو عنصر مفردات مميز، وعدد الأنواع هو حجم المفردات (vocabulary) ويُرمز له بـ |V|. إذن to be or not to be فيها N = 6 وحدات نصية و|V| = 4 أنواع: to، be، or، not. ويربط بينهما تطابق محاسبي: كل وحدة نصية تنتمي إلى نوع واحد بالضبط، لذلك يساوي مجموع أعداد الأنواع عدد الوحدات النصية.

N=∑w∈Vc(w)N = \sum_{w \in V} c(w)
Tokens are the sum of type counts: 2 + 2 + 1 + 1 = 6عدد الرموز (tokens) هو مجموع تكرارات الأنواع (types): 2 + 2 + 1 + 1 = 6
Six tokens in running order collapse into four type stacks: to and be twice each, or and not once, and the stack heights add back up to N = 6ست وحدات نصية بترتيب ورودها تنضم إلى أربع أكوام من الأنواع: to وbe مرتين لكل منهما، وor وnot مرة واحدة، ومجموع ارتفاعات الأكوام يعود إلى N = 6

Try it yourself. The counter below applies a tokenization policy to a sentence and recomputes both numbers live. Start with the picnic sentence, switch on punctuation splitting and watch N go from 16 to 18. Then load the Apple sentence and flip lowercase: N stays put while |V| drops, because Apple and apple have become one type. That asymmetry is the whole lesson of the next concept in miniature.

جرّبها بنفسك. العدّاد أدناه يطبق سياسة تقطيع على جملة ويعيد حساب الرقمين مباشرة. ابدأ بجملة النزهة، وفعّل فصل علامات الترقيم، وراقب N ينتقل من 16 إلى 18. ثم حمّل جملة Apple وفعّل تحويل الأحرف إلى صغيرة: يبقى N كما هو بينما ينخفض |V|، لأن Apple وapple أصبحتا نوعًا واحدًا. هذا اللاتماثل هو درس المفهوم التالي كله في صورة مصغرة.

InteractiveتفاعليToken and type counter: every toggle is a tokenization policyعدّاد الرموز والأنواع: كل مفتاح سياسة تقسيم
Tokens Nالرموز N16occurrences
Types |V|الأنواع |V|14distinct
|V| / N0.88types per token

16 tokens, 14 types

Token streamسلسلة الرموز
Theypicnickedbythepool,thenlaybackonthegrassandlookedatthestars.
Type set with countsمجموعة الأنواع مع عدد تكرار كل منها
  • They×1
  • picnicked×1
  • by×1
  • the×3
  • pool,×1
  • then×1
  • lay×1
  • back×1
  • on×1
  • grass×1
  • and×1
  • looked×1
  • at×1
  • stars.×1

Punctuation and clitic tokens are teal, the <NUM> placeholder is in the accent color. Watch both counts change as you flip each policy.رموز علامات الترقيم والملحقات باللون الأخضر المزرق، والبديل <NUM> باللون المميز. راقب تغيّر العددين كلما بدّلت أي سياسة.

Five corpora, one tableخمس مدونات، جدول واحد

Jurafsky and Martin collect rough counts for several English corpora, and the lecture reproduces their table. Two columns are on the slide. The two on the right are computed here: types per thousand tokens, and its reciprocal, tokens per type. Read those computed columns first, because they tell a story the raw counts hide.

يجمع Jurafsky وMartin أعدادًا تقريبية لعدة مدونات إنجليزية، والمحاضرة تعيد عرض جدولهما. عمودان موجودان في الشريحة. أما العمودان على اليمين فمحسوبان هنا: عدد الأنواع لكل ألف وحدة نصية، ومقلوبه، أي عدد الوحدات النصية لكل نوع. اقرأ هذين العمودين المحسوبين أولًا، لأنهما يرويان قصة تخفيها الأعداد الخام.

CorpusالمدونةGenreالنوع الأدبيTypes |V|الأنواع |V|Tokens Nالوحدات النصية NTypes per 1,000 tokensالأنواع لكل 1,000 وحدة نصيةTokens per typeالوحدات النصية لكل نوع
ShakespeareShakespearePlays and poemsمسرحيات وقصائد31 thousand31 ألفًا884 thousand884 ألفًا35.135.128.528.5
Brown corpusمدونة Brown15 written genres, 196115 نوعًا أدبيًا مكتوبًا، 196138 thousand38 ألفًا1 millionمليون واحد38.038.026.326.3
SwitchboardSwitchboardTelephone conversationمحادثات هاتفية20 thousand20 ألفًا2.4 million2.4 مليون8.38.3120120
COCACOCA8 balanced genres8 أنواع أدبية متوازنة2 million2 مليون440 million440 مليونًا4.54.5220220
Google n-gramsGoogle n-gramsWeb textنصوص الويب13 million13 مليونًا1 trillion1 تريليون0.0130.01376,92376,923
Rough numbers of wordform types and tokens for English corpora (SLP3 Fig. 2.1 and the lecture slide), with computed ratiosأعداد تقريبية لأنواع صيغ الكلمات ووحداتها النصية في مدونات إنجليزية (SLP3 الشكل 2.1 وشريحة المحاضرة)، مع نسب محسوبة

Down the table, N grows by six orders of magnitude while |V| grows by less than three. The ratio of types to tokens falls from about 35 per thousand for Shakespeare to about 0.013 per thousand for the Google corpus. This is the first preview of Heaps' law: vocabulary grows without bound but sublinearly, |V| = k N^β with β between 0 and 1, and Jurafsky and Martin report values from 0.44 to 0.56 or higher, so vocabulary goes up a little faster than the square root of the text length. Part 02 fits that law properly; here it is enough to see the bend.

بالنزول في الجدول، يكبر N بست مراتب عشرية بينما يكبر |V| بأقل من ثلاث. وتنخفض نسبة الأنواع إلى الوحدات النصية (type to token ratio) من نحو 35 لكل ألف في شكسبير إلى نحو 0.013 لكل ألف في مدونة Google. وهذه أول لمحة عن قانون Heaps: المفردات تنمو بلا حد لكن بمعدل أبطأ من الخطي، |V| = k N^β حيث β بين 0 و1، ويذكر Jurafsky وMartin قيمًا من 0.44 إلى 0.56 أو أعلى، أي أن المفردات تزداد أسرع قليلًا من الجذر التربيعي لطول النص. الجزء 02 يطابق هذا القانون على البيانات بشكل كامل؛ وهنا يكفي أن ترى الانحناء.

Types against tokens with both axes on a log scale: Heaps' law is a straight line of slope about 0.5, well under the slope-1 line where every token would be new, and Switchboard sits below the fit because conversation reuses a small vocabularyالأنواع مقابل الوحدات النصية مع محورين بمقياس لوغاريتمي: قانون Heaps خط مستقيم ميله نحو 0.5، أدنى بكثير من خط الميل 1 الذي تكون فيه كل وحدة نصية جديدة، ويقع Switchboard تحت الخط المطابق لأن المحادثة تعيد استخدام مفردات قليلة

Now read across rows instead of down. Brown has one million tokens and 38 thousand types. Switchboard has more than twice as many tokens and only 20 thousand types, fewer even than Shakespeare with a third of Switchboard's tokens. Size alone cannot explain that. Switchboard is about 2,400 telephone conversations among 543 speakers on about 70 everyday topics, and casual conversation reuses a small everyday vocabulary. Brown samples 500 texts across 15 written genres, and Shakespeare's plays reach for coinages and archaic forms. This is the point of slide 6: even within one language, genre and domain shift the vocabulary, so |V| depends on the Corpus, not only on N.

اقرأ الآن عبر الصفوف بدلًا من النزول. في Brown مليون وحدة نصية و38 ألف نوع. وفي Switchboard أكثر من ضعف عدد الوحدات النصية لكن 20 ألف نوع فقط، أي أقل حتى من شكسبير الذي لديه ثلث وحدات Switchboard النصية. الحجم وحده لا يفسر ذلك. فـ Switchboard يضم نحو 2,400 محادثة هاتفية بين 543 متحدثًا حول نحو 70 موضوعًا يوميًا، والمحادثة العفوية تعيد استخدام مفردات يومية قليلة. أما Brown فيأخذ عينات من 500 نص عبر 15 نوعًا أدبيًا مكتوبًا، ومسرحيات شكسبير تلجأ إلى الكلمات المبتكرة والصيغ القديمة. هذه هي فكرة الشريحة 6: حتى داخل اللغة الواحدة، يغيّر النوع الأدبي والمجال المفردات، لذلك يعتمد |V| على المدونة (corpus)، وليس على N وحده.

Why the vocabulary never stops growingلماذا لا تتوقف المفردات عن النمو

The falling ratio and the endless growth have the same cause. Function words like the and of are seen early and then only repeat. Content words keep arriving. Slide 8 lists where they come from, and each source is a reason your model will meet a word it has never seen.

للنسبة المتناقصة والنمو الذي لا ينتهي سبب واحد. الكلمات الوظيفية مثل the وof تُرى مبكرًا ثم تتكرر فقط. أما كلمات المحتوى فتستمر في الوصول. والشريحة 8 تذكر مصادرها، وكل مصدر منها سبب لأن يصادف نموذجك كلمة لم يرها من قبل.

  • Proper names and new products: every person, place, company and gadget is a type, and new ones appear every day.أسماء العلم والمنتجات الجديدة: كل شخص ومكان وشركة وجهاز هو نوع (type)، وتظهر أسماء جديدة كل يوم.
  • Creative spellings and typos: cooool, gr8 and every misspelling is a fresh type under a wordform policy.التهجئات الإبداعية والأخطاء الإملائية: cooool وgr8 وكل خطأ إملائي هو نوع جديد في ظل سياسة تعتمد صيغة الكلمة (wordform).
  • Code-switching: speakers mix languages within one utterance, so an English corpus carries Spanish, Hindi or Arabic types as well.التناوب اللغوي (Code-switching): يخلط المتحدثون اللغات داخل عبارة واحدة، لذلك تحمل المدونة الإنجليزية أنواعًا إسبانية أو هندية أو عربية أيضًا.
  • Morphology: walk, walks, walked and walking are four wordform types but one Lemma. Inflection multiplies surface forms, and morphologically rich languages multiply them far more.الصرف: walk وwalks وwalked وwalking أربعة أنواع من حيث صيغة الكلمة لكنها أصل معجمي واحد (lemma). والتصريف (inflection) يضاعف الصيغ السطحية، واللغات الغنية صرفيًا تضاعفها أكثر بكثير.
  • Compounding and multiword expressions: New York and ice cream behave as single lexical units but span a space. Sag and colleagues called multiword expressions a pain in the neck for NLP, and Jurafsky and Martin note that tokenizing them needs a dictionary and is tied up with named entity recognition.التركيب والتعبيرات متعددة الكلمات: New York وice cream تتصرفان كوحدتين معجميتين مفردتين لكنهما تمتدان عبر مسافة. وقد وصف Sag وزملاؤه التعبيرات متعددة الكلمات بأنها مصدر إزعاج كبير لمعالجة اللغات الطبيعية (a pain in the neck for NLP)، ويلاحظ Jurafsky وMartin أن تقطيعها يحتاج إلى قاموس ومرتبط بالتعرف على الكيانات المسماة (named entity recognition).

The consequence is that out-of-vocabulary words are unavoidable under any word-level policy. However large the training corpus, tomorrow's text contains a name or a typo that is not in V. That is the problem subword tokenization solves later in this lecture, by building rare words out of pieces that are in the vocabulary.

والنتيجة أن الكلمات خارج المفردات (out-of-vocabulary) أمر لا مفر منه في أي سياسة على مستوى الكلمة. فمهما كبرت مدونة التدريب، سيحتوي نص الغد على اسم أو خطأ إملائي غير موجود في V. وهذه هي المشكلة التي يحلها التقطيع إلى أجزاء الكلمات (subword) لاحقًا في هذه المحاضرة، ببناء الكلمات النادرة من قطع موجودة في المفردات.

Recall

Define token and type, then give N and |V| for 'to be or not to be'.عرّف الوحدة النصية (token) والنوع (type)، ثم أعطِ N و|V| لعبارة 'to be or not to be'.

A token is one occurrence of a unit in running text, and N counts them. A type is a distinct vocabulary item, and |V| counts them. N = 6, |V| = 4 (to, be, or, not).
الوحدة النصية ظهور واحد لوحدة في النص الجاري، وN يعدّها. والنوع عنصر مفردات مميز، و|V| يعدّه. N = 6، |V| = 4 (to، be، or، not).

Recall

Why does Switchboard have fewer types than Shakespeare despite almost three times as many tokens?لماذا يحتوي Switchboard على أنواع أقل من شكسبير رغم أن وحداته النصية تقارب ثلاثة أضعاف؟

Genre and domain. Conversational telephone speech reuses a small everyday vocabulary, so |V| depends on the corpus and its genre, not only on N.
بسبب النوع الأدبي والمجال. الكلام الهاتفي الحواري يعيد استخدام مفردات يومية قليلة، لذلك يعتمد |V| على المدونة ونوعها الأدبي، وليس على N وحده.

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

Counting punctuation as tokens and ignoring case, what are N and |V| for 'to be, or not to be.'?إذا عددنا علامات الترقيم وحدات نصية وتجاهلنا حالة الأحرف، فما قيمتا N و|V| لعبارة 'to be, or not to be.'؟

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

Switchboard has almost three times Shakespeare's tokens but fewer types. What explains this?في Switchboard ما يقارب ثلاثة أضعاف الوحدات النصية لدى شكسبير لكن أنواعًا أقل. ما الذي يفسر ذلك؟

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

The vocabulary size |V| of a model is best described as a property of which of these?أفضل وصف لحجم المفردات |V| لنموذج ما أنه خاصية لأيٍّ مما يلي؟

Every policy in this part has been described in words. Here is one written down as rules and run on a real sentence. The Penn Treebank convention is the standard for parsed corpora of English, and Jurafsky and Martin use this example to show its output.

كل سياسة في هذا الجزء وُصفت بالكلمات حتى الآن. وهنا سياسة مكتوبة كقواعد ومطبقة على جملة حقيقية. اصطلاح Penn Treebank هو المعيار للمدونات الإنجليزية المحللة نحويًا، ويستخدم Jurafsky وMartin هذا المثال لعرض مخرجاته.

Worked exampleمثال محلول

Penn Treebank tokenization of one sentenceتقطيع جملة واحدة وفق Penn Treebank

  1. Inputالمدخل

    "The San Francisco-based restaurant," they said, "doesn't charge $10".
    "The San Francisco-based restaurant," they said, "doesn't charge $10".
  2. Separate all punctuationافصل جميع علامات الترقيم

    Each quotation mark, comma and the final period becomes its own token, so restaurant," turns into restaurant, , and ".
    كل علامة تنصيص وكل فاصلة والنقطة الأخيرة تصبح وحدة نصية مستقلة، لذلك تتحول restaurant," إلى restaurant و, و".
  3. Keep hyphenated words togetherأبقِ الكلمات الموصولة بشرطة معًا

    Francisco-based stays one token. The convention treats a hyphenated compound as a unit.
    تبقى Francisco-based وحدة نصية واحدة. فالاصطلاح يعامل المركب الموصول بشرطة كوحدة واحدة.
  4. Split cliticsافصل اللواحق المتصلة

    doesn't becomes does and n't. Marcus and colleagues describe this in the original Treebank paper: contractions and the Anglo-Saxon genitive of nouns are automatically split into their component morphemes, so children's becomes children and 's, and won't becomes the odd pair wo and n't.
    تصبح doesn't وحدتين: does وn't. ويصف Marcus وزملاؤه ذلك في ورقة Treebank الأصلية: صيغ الاختصار وحالة الملكية الأنجلوساكسونية للأسماء (Anglo-Saxon genitive) تُفصل تلقائيًا إلى مورفيماتها المكوّنة، لذلك تصبح children's وحدتين: children و's، وتصبح won't الزوج الغريب wo وn't.
  5. Separate the currency signافصل رمز العملة

    $10 becomes $ and 10.
    تصبح $10 وحدتين: $ و10.
  6. Outputالمخرج

    " The San Francisco-based restaurant , " they said , " does n't charge $ 10 " . That is N = 18 tokens and |V| = 14 types, because the four quotation marks are one type and the two commas are one type.
    " The San Francisco-based restaurant , " they said , " does n't charge $ 10 " . أي N = 18 وحدة نصية و|V| = 14 نوعًا، لأن علامات التنصيص الأربع نوع واحد، والفاصلتين نوع واحد.
Two Penn Treebank splits: a tick drops between does and n't and between children and 's, then the halves slide apart, matching footnote 8 of Marcus, Santorini and Marcinkiewiczعمليتا فصل وفق Penn Treebank: تسقط علامة حدّ بين does وn't وبين children و's، ثم ينزلق النصفان مبتعدين، بما يطابق الحاشية 8 في ورقة Marcus وSantorini وMarcinkiewicz

The four decisionsالقرارات الأربعة

The worked example silently made four decisions, and slide 9 names them. Each has options, each helps some task and each hurts another. The table is the answer to the exam question "list four preprocessing decisions and one downstream consequence of each".

اتخذ المثال المحلول أربعة قرارات بصمت، والشريحة 9 تسمّيها. لكل قرار خيارات، وكل قرار يفيد مهمة ويضر بأخرى. والجدول هو الإجابة عن سؤال الاختبار «اذكر أربعة قرارات للمعالجة المسبقة ونتيجة لاحقة واحدة لكل منها».

DecisionالقرارOptionsالخياراتHelpsيفيدHurtsيضر
Case foldingتوحيد حالة الأحرف (case folding)Keep case, lowercase everything, or truecaseالإبقاء على حالة الأحرف، أو تحويل كل شيء إلى أحرف صغيرة، أو استعادة الحالة الصحيحة (truecasing)Retrieval recall: a query for apple matches Appleتحسين الاستدعاء في الاسترجاع: الاستعلام عن apple يطابق AppleNamed entity recognition: Apple, Bush, the Fed and General Motors lose their capital evidenceالتعرف على الكيانات المسماة: تفقد Apple وBush وthe Fed وGeneral Motors دليل الحرف الكبير
Punctuationعلامات الترقيمAttach to the word, separate it, or drop itإلصاقها بالكلمة، أو فصلها، أو حذفهاParsers and sentence segmenters, which read commas and periods as structureالمحللات النحوية ومقسِّمات الجمل، التي تقرأ الفواصل والنقاط على أنها بنيةDropping loses question marks and quotes; naive splitting breaks m.p.h., Ph.D., $45.55 and 01/02/06الحذف يُضيع علامات الاستفهام والتنصيص؛ والفصل الساذج يكسر m.p.h. وPh.D. و$45.55 و01/02/06
Normalizationالتطبيع (normalization)Accents, precomposed versus decomposed letters, curly versus straight quotes, hyphen versus dashعلامات التشكيل، والحروف المركّبة مسبقًا مقابل المفككة، وعلامات التنصيص المنحنية مقابل المستقيمة، والشرطة الواصلة مقابل الشرطة الطويلةMatching and a compact vocabulary: one quote type, not fourالمطابقة ومفردات مدمجة: نوع واحد من علامات التنصيص بدلًا من أربعةMeaningful distinctions vanish, such as accented pairs in French or a minus sign versus a hyphenتختفي فروق ذات معنى، مثل أزواج الحروف المشكّلة في الفرنسية أو علامة الطرح مقابل الشرطة الواصلة
NumbersالأرقامKeep raw, map to <NUM>, or segment into digit chunksالإبقاء عليها خامًا، أو استبدالها بـ <NUM>، أو تقسيمها إلى مجموعات من الأرقام<NUM> shrinks |V|; digit chunks let a model generalize arithmetic<NUM> يقلص |V|؛ ومجموعات الأرقام تتيح للنموذج تعميم الحسابRaw numbers make every price a new type; <NUM> throws away magnitudeالأرقام الخام تجعل كل سعر نوعًا جديدًا؛ و<NUM> يُضيع المقدار
Preprocessing decisions with their options and consequencesقرارات المعالجة المسبقة مع خياراتها ونتائجها

Case folding is the most tempting shortcut. Manning, Raghavan and Schütze observe that for information retrieval, lowercasing everything often remains the most practical solution, and in the same breath list what it destroys: proper nouns distinguished only by case, such as General Motors, the Fed against fed, and Bush against bush. Their alternative is truecasing, restoring the likely original case with a classifier. Jurafsky and Martin add that for other tasks capitalization is a useful feature and is retained, so some teams keep a cased and an uncased model side by side.

توحيد حالة الأحرف (Case folding) هو الاختصار الأكثر إغراءً. ويلاحظ Manning وRaghavan وSchütze أن تحويل كل شيء إلى أحرف صغيرة يظل في الغالب الحل الأكثر عملية لاسترجاع المعلومات، ويذكرون في الوقت نفسه ما يدمّره: أسماء العلم التي لا يميزها إلا حالة الأحرف، مثل General Motors، وthe Fed مقابل fed، وBush مقابل bush. والبديل عندهم هو استعادة الحالة الصحيحة (truecasing)، أي استرجاع حالة الأحرف الأصلية المرجحة باستخدام مصنِّف. ويضيف Jurafsky وMartin أن حالة الأحرف في مهام أخرى سمة مفيدة فيُحتفظ بها، لذلك تحتفظ بعض الفرق بنموذج يراعي حالة الأحرف (cased) وآخر لا يراعيها (uncased) جنبًا إلى جنب.

Normalization is the quiet one. A Unicode normalization form decides whether the precomposed letter Ç at U+00C7 and the sequence C plus combining cedilla are the same type. Unicode Standard Annex 15 defines four forms, NFC, NFD, NFKC and NFKD, and the same logic applies to four kinds of quotation mark and three kinds of dash that a keyboard and a word processor scatter through any corpus. Skip it and your vocabulary silently holds several copies of the same word.

التطبيع هو القرار الصامت. فصيغة تطبيع يونيكود (Unicode normalization) تقرر هل الحرف المركّب مسبقًا Ç عند U+00C7 والتسلسل C مع علامة السيديا المركِّبة (combining cedilla) نوع واحد أم لا. ويعرّف الملحق القياسي 15 ليونيكود (Unicode Standard Annex 15) أربع صيغ هي NFC وNFD وNFKC وNFKD، والمنطق نفسه ينطبق على أربعة أشكال من علامات التنصيص وثلاثة أشكال من الشرطات تنثرها لوحة المفاتيح ومعالج النصوص في أي مدونة. تجاهله، وستحمل مفرداتك بصمت عدة نسخ من الكلمة نفسها.

Numbers show the trade-off most sharply. Kept raw, every price and every year is a new type and |V| explodes. Mapped to a single <NUM> placeholder, the vocabulary shrinks but the model can no longer tell 12 from 12,000. Modern tokenizers pick a middle path: Jurafsky and Martin describe the GPT-4o tokenizer chunking numbers into groups of up to three digits, so magnitude survives as a sequence of small pieces.

الأرقام تُظهر المفاضلة بأوضح صورة. إذا أُبقيت خامًا، يصبح كل سعر وكل سنة نوعًا جديدًا ويتضخم |V|. وإذا استُبدلت كلها بعنصر نائب واحد <NUM>، تتقلص المفردات لكن النموذج لا يعود قادرًا على التمييز بين 12 و12,000. والمقطِّعات الحديثة تختار طريقًا وسطًا: يصف Jurafsky وMartin مقطِّع GPT-4o الذي يقسم الأرقام إلى مجموعات من ثلاثة أرقام كحد أقصى، فيبقى المقدار محفوظًا كتسلسل من القطع الصغيرة.

The four ambiguous boundariesالحدود الملتبسة الأربعة

Even after the four decisions are made, some characters refuse to settle. Slide 10 collects them. In each case the same character is a boundary in one context and part of a unit in another, and a tokenizer has to pick a default and accept the errors it causes.

حتى بعد اتخاذ القرارات الأربعة، تبقى بعض الحروف عصيّة على الحسم. والشريحة 10 تجمعها. في كل حالة يكون الحرف نفسه حدًا في سياق وجزءًا من وحدة في سياق آخر، وعلى المقطِّع أن يختار افتراضًا ويتقبل الأخطاء التي يسببها.

BoundaryالحدExampleمثالTreebank defaultافتراض TreebankAlternativeالبديل
Hyphensالشرطات الواصلةstate-of-the-artstate-of-the-artKeep the hyphenated word together as one tokenإبقاء الكلمة الموصولة بشرطة معًا كوحدة نصية واحدةSplit into state, of, the, art so each piece is a known typeتقسيمها إلى state وof وthe وart حتى تكون كل قطعة نوعًا معروفًا
AbbreviationsالاختصاراتU.S., Dr., e.g.U.S., Dr., e.g.Keep the internal periods; the trailing period is ambiguous with a sentence endالإبقاء على النقاط الداخلية؛ أما النقطة الأخيرة فملتبسة مع نهاية الجملةStrip periods entirely, at the cost of merging US the country with us the pronounحذف النقاط كليًا، على حساب دمج US (الدولة) مع us (الضمير)
Cliticsاللواحق المتصلة (clitics)we'll, I'm, possessive 'swe'll، I'm، علامة الملكية 'sSplit off the clitic: we 'll, I 'm, children 's, does n't, wo n'tفصل اللاحقة المتصلة: we 'll، I 'm، children 's، does n't، wo n'tKeep the contraction whole, so doesn't and does not are unrelated typesإبقاء الاختصار كاملًا، فتصبح doesn't وdoes not نوعين لا علاقة بينهما
Social mediaوسائل التواصل الاجتماعي#NLP, @user, URLs#NLP، @user، الروابط (URLs)Splits # and @ off their word and breaks a URL at its colon, slashes and question markيفصل # و@ عن كلمتيهما ويقسم الرابط عند النقطتين الرأسيتين والشرطات المائلة وعلامة الاستفهامA social-media tokenizer keeps hashtags, handles and URLs whole with dedicated patternsمقطِّع وسائل التواصل الاجتماعي يُبقي الوسوم وأسماء المستخدمين والروابط كاملة بأنماط مخصصة
Ambiguous boundaries, the Penn Treebank default and the alternativeالحدود الملتبسة، والافتراض في Penn Treebank، والبديل

A Clitic is the trickiest of the four because the apostrophe is three-way ambiguous. Jurafsky and Martin point out that it marks the genitive (the book's cover), quotation ('The other class', she said) and the contracted clitic (we'll, I'm). Hyphens run from co-education, where the pieces are meaningless alone, to Hewlett-Packard, where each is a name, and Manning and colleagues show there is no rule that suits both. Abbreviation periods will return as the central problem of Sentence segmentation later in the lecture. Social media adds hashtags, handles and URLs that should be kept whole, since #NLP or a web address split at its punctuation is worthless. A Treebank-style tokenizer will not do this by itself: it pads # and @ with spaces and breaks a URL at its colon, so a social-media pipeline adds hashtag, handle and URL patterns in front of it.

اللاحقة المتصلة (clitic) هي الأصعب بين الأربعة لأن الفاصلة العليا (apostrophe) ملتبسة على ثلاثة أوجه. يشير Jurafsky وMartin إلى أنها تدل على الملكية (the book's cover)، وعلى الاقتباس ('The other class', she said)، وعلى اللاحقة المتصلة المختصرة (we'll، I'm). والشرطات الواصلة تتراوح من co-education، حيث لا معنى للقطع منفردة، إلى Hewlett-Packard، حيث كل قطعة اسم، ويبيّن Manning وزملاؤه أنه لا توجد قاعدة تناسب الحالتين. ونقاط الاختصارات ستعود كمشكلة محورية في تقسيم الجمل (sentence segmentation) لاحقًا في المحاضرة. وتضيف وسائل التواصل الاجتماعي الوسوم (hashtags) وأسماء المستخدمين (handles) والروابط (URLs) التي يجب الإبقاء عليها كاملة، لأن #NLP أو عنوان الويب إذا قُسّم عند علامات ترقيمه يصبح بلا قيمة. والمقطِّع على نمط Treebank لن يفعل ذلك من تلقاء نفسه: فهو يحيط # و@ بمسافات ويقسم الرابط عند النقطتين الرأسيتين، لذلك تضيف سلسلة معالجة وسائل التواصل الاجتماعي أنماطًا للوسوم وأسماء المستخدمين والروابط قبله.

Recall

Under the Penn Treebank convention, tokenize 'doesn't' and 'children's'.وفق اصطلاح Penn Treebank، قطّع 'doesn't' و'children's'.

does + n't, and children + 's. Contractions and the genitive are split into their component morphemes; punctuation is separated; hyphenated words stay together.
does + n't، وchildren + 's. صيغ الاختصار وحالة الملكية تُفصل إلى مورفيماتها المكوّنة؛ وعلامات الترقيم تُفصل؛ والكلمات الموصولة بشرطة تبقى معًا.

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

Which preprocessing decision helps information retrieval but hurts named entity recognition?أي قرار من قرارات المعالجة المسبقة يفيد استرجاع المعلومات لكنه يضر بالتعرف على الكيانات المسماة؟

Recapالخلاصة

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

  • A word is not a natural unit: the picnic sentence has 16 or 18 tokens and 14 or 16 types depending on the punctuation policy.الكلمة ليست وحدة طبيعية: جملة النزهة فيها 16 أو 18 وحدة نصية (token) و14 أو 16 نوعًا (type) بحسب سياسة التعامل مع علامات الترقيم.
  • Token = one occurrence (N); type = one distinct item (|V|); 'to be or not to be' is N = 6, |V| = 4.الوحدة النصية (token) = ظهور واحد (N)؛ النوع (type) = عنصر مميز واحد (|V|)؛ عبارة 'to be or not to be' فيها N = 6 و|V| = 4.
  • Speech adds fragments (main-) and filled pauses (uh, um); speech recognizers keep them, parsers drop them.يضيف الكلام المنطوق أجزاء كلمات مبتورة (main-) ووقفات مملوءة (uh وum)؛ أنظمة التعرف على الكلام تُبقيها، والمحللات النحوية (parsers) تحذفها.
  • Chinese, Japanese and Thai have no orthographic words; the same Chinese sentence can be 3, 5 or 7 units.الصينية واليابانية والتايلاندية لا توجد فيها كلمات إملائية مفصولة بمسافات؛ فالجملة الصينية نفسها قد تُعدّ 3 أو 5 أو 7 وحدات.
  • Types grow with tokens but sublinearly (Heaps: |V| = k N^beta, beta about 0.5); the type to token ratio falls from 3.5% (Shakespeare) to 0.0013% (Google n-grams).تنمو الأنواع مع نمو الوحدات النصية لكن بمعدل أبطأ من الخطي (قانون Heaps: |V| = k N^beta، وbeta تقارب 0.5)؛ وتنخفض نسبة الأنواع إلى الوحدات من 3.5% (شكسبير) إلى 0.0013% (Google n-grams).
  • Genre matters as much as size: Switchboard has 2.4 million tokens but only 20 thousand types.النوع الأدبي مهم بقدر الحجم: Switchboard فيه 2.4 مليون وحدة نصية لكن 20 ألف نوع فقط.
  • Vocabulary is hard because of names, new products, typos, code-switching, morphology and multiword expressions; OOV is unavoidable.المفردات صعبة بسبب أسماء العلم، والمنتجات الجديدة، والأخطاء الإملائية، والتناوب اللغوي (code-switching)، والصرف، والتعبيرات متعددة الكلمات؛ لذلك فالكلمات خارج المفردات (OOV) أمر لا مفر منه.
  • Four preprocessing decisions: case folding, punctuation, normalization, numbers. Four ambiguous boundaries: hyphens, abbreviations, clitics, social media.قرارات المعالجة المسبقة الأربعة: توحيد حالة الأحرف (case folding)، وعلامات الترقيم، والتطبيع (normalization)، والأرقام. والحدود الملتبسة الأربعة: الشرطات الواصلة، والاختصارات، واللواحق المتصلة (clitics)، ووسائل التواصل الاجتماعي.
  • Penn Treebank convention: separate punctuation, keep hyphenated words, split clitics and possessives (doesn't -> does n't, children's -> children 's).اصطلاح Penn Treebank: افصل علامات الترقيم، وأبقِ الكلمات الموصولة بشرطة معًا، وافصل اللواحق المتصلة وعلامة الملكية (doesn't -> does n't، وchildren's -> children 's).
  • |V| is a property of the corpus plus the tokenization policy, never of the language alone.|V| خاصية للمدونة مع سياسة التقطيع (tokenization)، وليست أبدًا خاصية للغة وحدها.

Sourcesالمصادر