liveBook · Manning

Word count

A metric that counts word units in text, either overall or for a specified word, according to the applicable segmentation rule.

How 2 Manning books explain it

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
Measures words in a file alongside line and character counts, or counts occurrences of individual words.
How deep it goes
Works through split-based counting, line-by-line accumulation, alphabetic filtering, and dictionary frequencies without defining a universal word boundary.
Examples
Uses a four-line sample reporting 30 words and a cleaned text file ranked by most and least common words.
What you can do after
Build it from scratch as a Python file counter, then adapt it for alphabetic-only counts or per-word frequencies.

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 →

Related concepts

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.