إنشاء مفردات
اربط كل كلمة بفهرس ثابت
إنشاء مفردات درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 2 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NLP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NLP Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
What Is a Vocabulary?
A vocabulary is the full set of unique words your model knows. Each word gets one fixed slot in every document vector. 📖
Collect Every Unique Word
To build it, gather all words across your documents and keep only the distinct ones, dropping repeats.
words = set("the cat sat the mat".split())Give Each Word an Index
Sort the unique words and assign each a number. This word to index map is your vocabulary lookup.
vocab = {w: i for i, w in enumerate(sorted(words))}The Index Defines the Slot
The index tells a word which position it occupies in every vector, so cat always lands in the same column.
Vocabulary Sets Vector Length
If your vocabulary has 5000 words, every document becomes a vector of 5000 numbers, one slot per word.
Order Must Stay Fixed
Once set, the mapping must never change. A stable order guarantees that column 3 means the same word for every document.
Out-of-Vocabulary Words
A word not in your vocabulary is called out of vocabulary. The simplest choice is to ignore it during counting.
Pruning Rare Words
Words that appear once add noise and size. Dropping very rare terms keeps the vocabulary smaller and cleaner.
Dropping Very Common Words
You can also cut words that appear in nearly every document. These stopwords rarely help tell documents apart.
Look Up an Index
With the map built, finding a word position is instant. Just index the dictionary by the word you want.
print(vocab["cat"]) # the column index for catVocabulary Powers Counting
This map is the backbone of vectorization. Next you fill each slot with how often that word appears in a document.
Quick Check
What does a word index represent?
Recap: Your Vocabulary
You built a vocabulary of unique words, mapped each to a fixed index, and saw how pruning keeps it lean and useful. 🎉
الأسئلة الشائعة
هل درس «إنشاء مفردات» مجاني؟
نعم — نص درس «إنشاء مفردات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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 يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- لماذا تحتاج النماذج إلى أرقام لا كلمات
- إنشاء مفردات
- العد باستخدام CountVectorizer
- قراءة مصفوفة المستندات والمصطلحات