Skip to main content

Module readability

Module readability 

Source
Expand description

Readability scoring utilities (Flesch Reading Ease and Flesch-Kincaid Grade Level).

This module provides a small, dependency-free implementation of two widely used readability metrics that are computed server-side during markdown rendering:

  • Flesch Reading Ease (FRE) — higher values mean easier to read (0 = extremely difficult, 100 = extremely easy).
  • Flesch-Kincaid Grade Level (FKGL) — expressed as a US school grade.

The heart of both formulas is the syllable count. We use a simple Aydin/sylco-style heuristic that is correct on the overwhelming majority of English words and degrades gracefully on edge cases. This matches the project’s “zero run-time dependencies” principle — the formulas themselves are trivial arithmetic.

§Example

use mbr_core::readability::{ReadabilityCounts, scores};

let counts = ReadabilityCounts {
    words: 10,
    sentences: 2,
    syllables: 14,
};
let s = scores(&counts);
assert!(s.flesch_reading_ease.is_some());
assert!(s.flesch_kincaid_grade.is_some());

Structs§

ReadabilityCounts
Accumulated counts needed to compute readability scores.
ReadabilityScores
Computed readability scores.

Functions§

count_syllables
Count syllables in a word using a simple heuristic.
scores
Compute readability scores from accumulated counts.