pub struct TextStats {
pub words: u64,
pub sentences: u64,
pub characters: u64,
pub characters_no_spaces: u64,
pub avg_word_length: f64,
pub avg_sentence_length: f64,
pub estimated_reading_seconds: f64,
pub estimated_reading_minutes: u64,
pub difficulty_score: f64,
}Expand description
The full bundle of computed statistics for a piece of text.
All fields are computed from a single pass over the input. Counts are
u64 so they compose cleanly with very large documents; averages and
durations are f64.
Fields§
§words: u64Number of whitespace-or-punctuation-delimited word tokens.
sentences: u64Number of sentence-ending units (. ! ?), with a trailing
sentence counted even if the final terminator is omitted.
characters: u64Total number of Unicode scalar values (Rust chars), including
whitespace and punctuation.
characters_no_spaces: u64Characters excluding ASCII whitespace.
avg_word_length: f64Average number of characters per word (letters only, per word).
avg_sentence_length: f64Average number of words per sentence.
estimated_reading_seconds: f64Estimated reading time in seconds (at WORDS_PER_MINUTE).
estimated_reading_minutes: u64Estimated reading time in whole minutes (rounded up, minimum 1 if the text is non-empty).
difficulty_score: f64A 0–100 lexile-like difficulty estimate; higher means harder.
Implementations§
Source§impl TextStats
impl TextStats
Sourcepub fn difficulty_band(&self) -> Difficulty
pub fn difficulty_band(&self) -> Difficulty
Map the continuous difficulty_score to a coarse band.