إنشاء أول جدول لتكرار الكلمات
احسب عدد مرات ظهور كل كلمة
إنشاء أول جدول لتكرار الكلمات درس مجاني في NLP Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في NLP Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة NLP Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
What Is a Frequency Table?
A frequency table maps each word to how many times it appears. It is the foundation of nearly every text analysis. 📊
Start With Tokens
First turn text into a list of words, then lowercase them so The and the count as the same token.
words = text.lower().split()Count With a Dictionary
A Python dictionary stores word to count pairs. You loop through words and add one each time a word appears.
freq = {}
for w in words:
freq[w] = freq.get(w, 0) + 1The get Trick
Using get with a default of zero avoids errors when a word is seen for the first time. It keeps the loop clean.
freq[w] = freq.get(w, 0) + 1Counter Does It for You
The Counter class from collections builds the whole table in one line, no manual loop needed.
from collections import Counter
freq = Counter(words)Look Up a Word
With the table built, reading a count is instant. Just index the word and you get its frequency.
print(freq["the"]) # how many times the appearsFind the Most Common
Counter's most_common method returns the top words and their counts, already sorted from highest to lowest.
print(freq.most_common(3))Stopwords Dominate
The top of almost every table is stopwords like the, of, and a. They are frequent but carry little meaning.
Sort Your Own Dictionary
To rank a plain dict, sort its items by value. The sorted function with a key gives you the order you want.
ranked = sorted(freq.items(), key=lambda x: x[1], reverse=True)Frequencies Power Features
This table is the seed of bag-of-words, where word counts become the numbers that machine learning models read.
Loop to Print the Table
Iterate over the items to display each word beside its count, giving you a readable summary of the document.
for word, n in freq.items():
print(word, n)Quick Check
Pick the fastest way to build a word count table.
Recap: Your Frequency Table
You built a frequency table with a dict or Counter, ranked the top words, and saw how counts feed bag-of-words features. 🎉
الأسئلة الشائعة
هل درس «إنشاء أول جدول لتكرار الكلمات» مجاني؟
نعم — نص درس «إنشاء أول جدول لتكرار الكلمات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة NLP Academy، انتقل إلى CoddyKit PRO. تتضمن دورة NLP Academy 4 دروس في المجموع.
ماذا ستتعلم في «إنشاء أول جدول لتكرار الكلمات»؟
احسب عدد مرات ظهور كل كلمة تتمرن على NLP Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ NLP Academy؟
لا تُشترط خبرة سابقة. NLP Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «إنشاء أول جدول لتكرار الكلمات»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس NLP Academy هذا؟
نعم. كل درس في NLP Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- السلاسل والمحارف والترميزات
- قراءة الملفات النصية إلى Python
- عدّ الكلمات والمحارف
- إنشاء أول جدول لتكرار الكلمات