ReadSight (Rust) — Multilingual Readability Engine
readsight measures text readability across 86 languages using 17 readability
formulas, plus a syllable counter and word hyphenator based on the Frank M. Liang
(TeX) hyphenation algorithm. It has no network access and no heavy
dependencies — all language data and hyphenation patterns are embedded in the crate.
This is a byte-accurate Rust port of the canonical PHP library and its Python port:
- PHP (canonical): https://github.com/MADEVAL/ReadSight
- Python port: https://github.com/MADEVAL/ReadSightPy
Output parity with the reference implementations is verified with golden vectors
generated from the PHP library (see tests/golden).
Installation
[]
= "1.0"
Quick start
use ReadSight;
Run the bundled demo:
Features
- 86 languages with language-specific letter/word/sentence tokenizers.
- 17 readability formulas (see below), each with the reference coefficients.
- TeX (Liang) hyphenation via the bundled
hyph-utf8pattern files. - Three syllable modes per language —
tex,heuristic(withvowelModecluster/individualfor Slavic languages), andcomposite. - Embedded data by default; optional [
Config::from_dirs] to read from the filesystem instead. - Zero
unsafe,#![forbid(unsafe_code)].
Readability formulas
Universal (all languages): Gunning Fog, SMOG, Coleman-Liau, Automated Readability Index (ARI), LIX.
Language-specific: Flesch Reading Ease, Flesch-Kincaid Grade Level, Wiener Sachtextformel (4 variants), Gulpease, Fernández-Huerta, Szigriszt-Pazos, Gutiérrez-Polini, Crawford, FOG-PL, Dale-Chall, Spache, OSMAN.
use ReadSight;
let rs = new.unwrap;
// Wiener Sachtextformel supports 4 variants (1..=4)
let r = rs.wiener_sachtextformel.unwrap;
assert_eq!;
API overview
ReadSight (aliased as Engine) is the entry point:
- Text / syllable:
split_word,split_syllables,syllable_count,word_count,sentence_count,letter_count,total_syllables,average_syllables_per_word,average_words_per_sentence,polysyllable_count,words_with_more_than_n_syllables,histogram_syllables,analyze,add_hyphenations. - Formulas:
score(name, text)plus one convenience method per formula (flesch_reading_ease,gunning_fog,smog_index,coleman_liau,automated_readability_index,lix,gulpease,fernandez_huerta,szigriszt_pazos,gutierrez_polini,crawford,fog_pl,dale_chall,spache,osman,wiener_sachtextformel). - Static:
ReadSight::supported_languages(config).
All formula methods return Result<FormulaResult, Error> — analyze (and hence
every formula) returns [Error::EmptyText] for empty input.
Supported languages
ReadSight::supported_languages(None) returns all 86 codes (sorted). They mirror
the JSON files under data/languages exactly.
Data source
By default all data is embedded at compile time (via include_dir!). To load from
the filesystem instead:
use ;
let config = from_dirs;
let rs = with_config.unwrap;
Testing
The suite includes:
- Golden parity against the PHP reference:
analyze+ all 17 formulas over every one of the 86 languages, plus per-word syllable vectors. - Ported unit tests from the PHP/Python suites (hyphenation, syllables, text splitting, formulas, grade-level interpretation).
- Full-language smoke test that builds every language and runs every supported formula.
License
MIT — see LICENSE. Readability data and hyphenation patterns originate
from the canonical PHP project and the hyph-utf8
package.