0Pricing
NLP Academy · درس

عدّ الكلمات والمحارف

قياسات أساسية للطول والتكرار

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

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

Measuring Text First

Before any fancy analysis, you measure text. Simple counts of characters and words already tell you a lot about a document. 📏

Count Characters With len

The len function returns how many characters a string holds, including spaces and punctuation.

text = "NLP is fun"
print(len(text))  # 10

Spaces Count Too

Remember that whitespace like spaces and newlines are real characters, so they are included in any character count.

Split Into Words

The split method breaks a string on whitespace and returns a list of words, your simplest path to word counting.

words = "one two three".split()
print(words)  # ['one','two','three']

Count the Words

Apply len to the list from split and you get the word count of the whole document.

words = text.split()
print(len(words))  # number of words

Split Is Naive

Plain split treats hello! as one word because punctuation sticks to letters. Good enough to start, but not perfect.

Count Sentences Roughly

A quick sentence estimate is to count periods, question marks, and exclamation points. It is rough but instantly useful.

n = text.count(".") + text.count("?") + text.count("!")

Average Word Length

Divide total letters by word count to get average word length, a small signal about how dense the writing is.

avg = len(text.replace(" ", "")) / len(words)

Counting Specific Substrings

The count method tells you how many times a substring appears, handy for tallying a single target word.

print(text.lower().count("the"))

Unique Words With a Set

Put the word list into a set and its length is the number of unique words, a measure of vocabulary richness.

unique = set(words)
print(len(unique))

Why Counts Matter

These statistics drive real decisions: spam filters flag odd lengths, and readability tools lean on word counts.

Quick Check

Test your grasp of basic Python text counting.

Recap: Counting Text

You can now count characters with len, words with split, unique words with a set, and rough sentences by punctuation. 🔢

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

هل درس «عدّ الكلمات والمحارف» مجاني؟

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

ماذا ستتعلم في «عدّ الكلمات والمحارف»؟

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

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

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

كم من الوقت يستغرق درس «عدّ الكلمات والمحارف»؟

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

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

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

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

  1. السلاسل والمحارف والترميزات
  2. قراءة الملفات النصية إلى Python
  3. عدّ الكلمات والمحارف
  4. إنشاء أول جدول لتكرار الكلمات
← العودة إلى NLP Academy