0Pricing
NLP Academy · درس

شرح الثنائيات والثلاثيات

نوافذ منزلقة فوق الرموز

شرح الثنائيات والثلاثيات درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NLP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NLP Academy 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Naming the N-Grams

The n in n-gram is just a number. Pick n and you decide how many neighboring words each feature bundles together.

Meet the Bigram

A bigram is an n-gram of size two, every adjacent pair of words. It is the most common upgrade over plain single words. 👍

Bigrams in Action

From four words you get three overlapping pairs. Notice how each bigram shares one word with the next one.

words = "i love clean code".split()
bigrams = list(zip(words, words[1:]))
print(bigrams)

Meet the Trigram

A trigram takes three words at a time. It captures even more context, like is not good as one unit.

words = "this is not good".split()
trigrams = list(zip(words, words[1:], words[2:]))
print(trigrams)

How Many Do You Get?

For a sentence of N words, you get N minus n plus one n-grams. So 4 words give 3 bigrams and 2 trigrams.

The Window Slides

Each n-gram comes from a small window moving one word forward. Overlap is the point, since shared words stitch context together.

A Reusable Helper

You can build any n-gram with one tidy function using zip. Change the value of n and the same code handles bigrams or trigrams.

def ngrams(words, n):
    return list(zip(*[words[i:] for i in range(n)]))

Bigger N, More Context

Higher values of n hold longer phrases, so they capture context more precisely. That power comes with a cost you will meet soon.

Bigger N, Rarer Grams

The longer the run, the less often that exact sequence repeats. Large n-grams become rare, appearing in few documents.

Why Bigrams Are Popular

Bigrams hit a sweet spot: enough context to catch not bad, common enough to repeat across texts. That balance makes them a reliable default.

Mixing Sizes

You rarely use one size alone. Most pipelines combine unigrams and bigrams so the model sees both single words and their key pairs.

Quick Check

How many bigrams come from the sentence text is just data, which has four words?

Recap: Bigrams and Trigrams

A bigram joins two words, a trigram joins three. Bigger n holds more context but appears less often. Next you will let scikit-learn build them. ⚙️

الأسئلة الشائعة

هل درس «شرح الثنائيات والثلاثيات» مجاني؟

نعم — نص درس «شرح الثنائيات والثلاثيات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة NLP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة NLP Academy 4 دروس في المجموع.

ماذا ستتعلم في «شرح الثنائيات والثلاثيات»؟

نوافذ منزلقة فوق الرموز تتمرن على NLP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ NLP Academy؟

لا تُشترط خبرة سابقة. NLP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «شرح الثنائيات والثلاثيات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس NLP Academy هذا؟

نعم. كل درس في NLP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. لماذا تفقد الكلمات المفردة معناها
  2. شرح الثنائيات والثلاثيات
  3. سمات N-Gram في scikit-learn
  4. اختيار نطاق N-Gram المناسب
← العودة إلى NLP Academy