Guide
Text Statistics & Readability
Wordsmith provides several helpful methods for getting statistics about text and/or evaluating its readability.
Wordsmith’s statistics/readability methods include:
automatedReadabilityIndex
averageWordsPerSentence
colemanLiauIndex
daleChallReadabilityScore
fleschKincaidReadingEase
fleschKincaidGradeLevel
gunningFogScore
readTime
sentenceCount
smogIndex
spacheReadabilityScore
wc
wordcount
Text Statistics
averageWordsPerSentence
Returns the average number of words per sentence in the text.
{% set text %} |
sentenceCount
Returns an approximate count of sentences in the text.
(The sentence count returned by this function should be treated as a rough approximation. Extra periods in the text, such as in words like “Mr.” or “Mrs.”, will prevent the count from being exactly accurate.)
{% set text %} |
wc
An alias for wordcount
.
wordcount
Counts the number of words inside string. (Returns an integer number.)
wordcount
strips tags from the provided text, so it will provide a correct value when used on HTML content.
(Bonus: Unlike PHP’s str_word_count
, Wordsmith’s wordcount
is multi-byte-safe and locale-agnostic.)
{% wordcount('Peter piper picked a peck of pickled peppers.') %} |
Reading Time
readTime
Calculates the units of time required for an average person to read the given passage of text.
(By default, this method assumes a 200 words-per-minute English reading rate and returns the number of minutes needed to read a passage at that rate.)
You can optionally specify your own reading rate, to accommodate a different language or compensate for reading difficulty.
You can also optionally specify a minimum number of units, which serves as a floor for the returned value.
Parameters:
rate
(200
) — The number of words an average person can read per unit of time.minimum
(1
) — The minimum value that will be returned.
{% set tales %} |
Readability
automatedReadabilityIndex
Gives the Automated Readability Index of the text, from 0 to 12.
colemanLiauIndex
Gives the Coleman-Liau Index of the text, from 0 to 12.
daleChallReadabilityScore
Gives the Dale-Chall readability score of the text, from 0 to 10.
fleschKincaidReadingEase
Gives the Flesch-Kincaid Reading Ease of the text, from 0 to 100.
fleschKincaidGradeLevel
Gives the Flesch-Kincaid Grade level of the text, from 0 to 12.
gunningFogScore
Gives the Gunning-Fog score of the text, from 0 to 19.
smogIndex
Gives the SMOG Index of the text, from 0 to 12.
spacheReadabilityScore
Gives the Spache readability score of the text, from 0 to 5.
(This scale is not really suitable for measuring readability above grade 4.)