تجزئة النص وبناء مفردات
حوّل النص إلى معرّفات صحيحة
تجزئة النص وبناء مفردات درس مجاني في Deep Learning Academy على CoddyKit. هذا هو الدرس 1 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Deep Learning Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
Networks Only Eat Numbers
A neural net cannot read raw letters. Before any learning happens, you must turn text into numbers the model can crunch. 🔢
First Step: Tokenize
To tokenize means to split text into small pieces called tokens. The simplest choice is to split a sentence on spaces into words.
text = "I love deep learning"
tokens = text.split()
# ["I", "love", "deep", "learning"]Tokens Can Be Smaller
A token need not be a whole word. It can be a character or a sub-word piece, which helps the model handle rare or unseen words.
Build a Vocabulary
A vocabulary is the full set of unique tokens your model knows. You collect every distinct token across your training text.
Give Each Token an Id
Each unique token gets one integer id. This mapping from token to id is how words become numbers the network can index.
vocab = {"i": 0, "love": 1, "deep": 2, "learning": 3}Encode a Sentence
To encode text, you look up each token in the vocabulary and replace it with its id, producing a list of integers.
ids = [vocab[t] for t in ["i", "love", "deep"]]
# [0, 1, 2]Handle Unknown Words
Some tokens at test time were never seen in training. Map them to a special unknown token so the model still gets a valid id.
unk_id = vocab.get("dragons", vocab["<unk>"])Special Tokens Help
Add special tokens like padding, start, and end markers. They give the model structure beyond the plain words themselves.
Lowercase and Clean
Normalizing text by lowercasing and stripping punctuation shrinks the vocabulary so Cat and cat share a single id.
Limit the Vocabulary Size
Real corpora have huge vocabularies. Keep only the most frequent tokens to control the vocab size; the rest become unknown.
Now Text Is a Tensor
Once encoded, a sentence is a list of ids you can wrap in a tensor. The pipeline from raw text to model input is complete.
import torch
ids = torch.tensor([0, 1, 2, 3])Quick Check
What does building a vocabulary give every unique token?
Recap
You split text into tokens, gather the unique ones into a vocabulary, and map each to an integer id so text becomes numbers. ✅
الأسئلة الشائعة
هل درس «تجزئة النص وبناء مفردات» مجاني؟
نعم — نص درس «تجزئة النص وبناء مفردات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Deep Learning Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Deep Learning Academy 4 دروس في المجموع.
ماذا ستتعلم في «تجزئة النص وبناء مفردات»؟
حوّل النص إلى معرّفات صحيحة تتمرن على Deep Learning Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Deep Learning Academy؟
لا تُشترط خبرة سابقة. Deep Learning Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 1 من أصل 4.
كم من الوقت يستغرق درس «تجزئة النص وبناء مفردات»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Deep Learning Academy هذا؟
نعم. كل درس في Deep Learning Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- تجزئة النص وبناء مفردات
- nn.Embedding: متجهات كلمات قابلة للتعلّم
- لماذا تلتقط Embeddings المعنى
- تدريب مصنّف نصوص