Expand description
§text-statistics
Comprehensive text statistics: word, sentence, and character counts, average word length, average sentence length, estimated reading time, and a lexile-like difficulty estimate. Pure Rust, zero dependencies, deterministic.
These are the same measurements the BeLikeNative AI writing assistant surfaces while you write — turned into a small, embeddable library.
§Quick example
use text_statistics::stats;
let s = stats("The cat sat on the mat. It was a good day for a nap.");
assert_eq!(s.words, 14);
assert_eq!(s.sentences, 2);
assert!(s.avg_word_length > 2.5);
assert!(s.estimated_reading_seconds < 60.0);
assert!(s.difficulty_band() == text_statistics::Difficulty::Easy);Structs§
- Text
Stats - The full bundle of computed statistics for a piece of text.
Enums§
- Difficulty
- A coarse difficulty band derived from the lexile-like estimate.
Constants§
- EASY_
AVG_ WORD_ LENGTH - Lexile-like difficulty reference: characters per word at grade-5 level. Below this average word length the text is considered “easy”.
- HARD_
AVG_ SENTENCE_ LENGTH - Above this average sentence length (in words) the text is considered “difficult” to follow.
- HARD_
AVG_ WORD_ LENGTH - Above this average word length the text is considered “difficult” (roughly grade-11+ vocabulary density).
- WORDS_
PER_ MINUTE - Average adult reading speed, in words per minute. 200 wpm is the widely-cited average for silent reading of English prose.