Word count
A metric that counts word units in text, either overall or for a specified word, according to the applicable segmentation rule.
The Quick Python Book, Fourth Edition
A word count is the number of words identified in a text according to a specified word-segmentation rule.
- How it is used
- Uses word counts for file statistics and word-frequency analysis.
- How deep it goes
- Works through whitespace counting, alphabetic filtering, frequency dictionaries, and memory trade-offs.
- Examples
- Uses a sample text file for line, word, and character counts and a Moby Dick excerpt for word frequencies.
- What you can do after
- Builds a word counter from scratch and adapts it for word frequencies or command-line file statistics.
Read how The Quick Python Book, Fourth Edition explains word count →
Functional Programming in Scala, Second Edition
The number of whitespace-delimited words represented by a character sequence or word-count summary.
- How it is used
- Motivates monoidal parallel parsing by showing why split substrings require richer results than integer counts.
- How deep it goes
- Derives a `WC` algebraic data type, all four combine cases, law tests, and a character-folding implementation.
- Examples
- Works through splitting "lorem ipsum dolor sit amet, " inside "dolor" and combines the resulting `Part` values.
- What you can do after
- Build it from scratch by defining a lawful `WC` monoid and folding whitespace-classified characters into a final count.
Read how Functional Programming in Scala, Second Edition explains word count →
Also covered in
- Outlier Detection in Python
- Python Workout, Second Edition
- WordPress Power Toolkit: Harness AI to build next-level websites
- Tiny Python Projects: Learn coding and testing with puzzles and games
- Grokking Machine Learning, Second EditionIn early access (MEAP)
- Python Workout: 50 ten-minute exercises
What to know first
- plain textPlain text is character data represented without rich formatting, styling, or presentation instructions.
- whitespace characterA whitespace character is a nonprinting character representing spacing or separation in text, such as a space, tab, or line break.
Related concepts
- packagekind of · A software package is an organized unit of related software components, defined by a programming language or package ecosystem for grouping, naming, building, importing, or distribution.
- tokencontrasts with · A text token is a discrete unit of text, such as a word, subword, character, or punctuation mark, produced by tokenization and processed as one element by a language model or text-processing system.
- functionproduced by · A function is a callable unit of program code that performs a computation or operation, can accept inputs, and may produce a result or side effect.
- Mapuses · A map is an associative data structure that stores key-value associations and supports retrieving values by key.
- classifieruses · A classifier is a predictive model that assigns an input to one or more discrete classes or categories.
Questions about word count
What is word count?
A metric that counts word units in text, either overall or for a specified word, according to the applicable segmentation rule.
Which Manning books explain word count?
The Quick Python Book, Fourth Edition and Functional Programming in Scala, Second Edition.
What should I know before learning word count?
Manning books that teach word count usually introduce plain text and whitespace character first.
What is the difference between word count and token?
A metric that counts word units in text, either overall or for a specified word, according to the applicable segmentation rule. A text token is a discrete unit of text, such as a word, subword, character, or punctuation mark, produced by tokenization and processed as one element by a language model or text-processing system.
What is word count a kind of?
Word count is a kind of package. A software package is an organized unit of related software components, defined by a programming language or package ecosystem for grouping, naming, building, importing, or distribution.
What is word count also called?
Word count is also called number of words.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

