[FEATURE] DPL-140: Readability score in RTE overlay#57
Merged
Conversation
Show a Flesch reading-ease score for the original and the optimized text in the DeepL Write RTE overlay, so editors get immediate feedback on how readable a text is before and after rephrasing. A new backend AJAX endpoint (ReadabilityController) calculates the score. Language-specific calculators are collected through the tagged iterator "deepl.readability" and resolved per content language (by primary subtag) by a registry. German, English, French, Italian and Portuguese ship with documented Flesch reading-ease adaptations, and further languages can be added by tagging a calculator that implements the language formula. Syllables are counted per language via org_heigl/hyphenator. The score is rendered as a coloured marker bar in the overlay and updated for the optimized text once rephrasing returns. Unsupported languages or empty texts yield no score instead of failing the request. The org_heigl/hyphenator dependency is pinned and additionally bundled as a contrib library (contrib/Libraries, declared via extra.typo3/cms.Package.providesPackages and autoloaded in classic mode through ext_localconf.php) so the extension also works in classic mode and TER installations. A dedicated contrib/composer.json plus a committed, prefer-lowest contrib/composer.lock pin the library; the publish workflow installs it into the release artifact and the checkContribComposer integration check keeps the constraint and lock in sync. Cherry-picked from the "reading-ease" feature branch and adapted to the current core-version-aware architecture: dependency injection via Symfony attributes (AutoconfigureTag, AutowireIterator, AsAlias) instead of Services.yaml, and the overlay template applied to both the v13 and v14 variants. (cherry picked from commit 5c97129)
contrib/composer.lockPackage changes
Settings · Docs · Powered by Private Packagist |
Documentation renderingYou can find files attached to the below linked Workflow Run URL (Logs). Please note that files only stay for around 5 days!
|
calien666
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Flesch reading-ease score to the DeepL Write RTE overlay, giving editors
immediate feedback on how readable a text is before and after rephrasing. The
score is shown as a coloured marker bar above the original and the optimized
text and is recalculated for the optimized text once rephrasing returns.
Details
ReadabilityController) computes the score.deepl.readabilitytagged iterator and resolved per content language (by primary subtag) by a
registry. Ships documented Flesch adaptations for German, English, French,
Italian and Portuguese; further languages can be added by tagging a
calculator that implements the formula.
request.
org_heigl/hyphenator. The dependencyis pinned to
3.1.0and additionally bundled as a contrib library(
contrib/Libraries,providesPackages+class_existsautoload inext_localconf.php) so the extension also works in classic mode / TERinstallations. A
checkContribComposerintegration check keeps the root andcontrib constraints and the prefer-lowest lock in sync.
changelog feature entry.
Readability calculator architecture
deeplwrite_readability→ReadabilityControllercomputes the scorefor the posted text + content language and returns
{score: …}, or{score: null}for unsupported languages / empty text (non-fatal, no 500).Classes/Readability/Calculator/and extendAbstractReadabilityCalculator(implementingReadabilityCalculatorInterface).The base class owns
calculateReadability()— counting sentences, words(unicode
\p{L}+, accent-safe) and syllables (viaorg_heigl/hyphenator,per-calculator
HYPHENATION_LOCALE) — guards empty input and caps the score at100. A concrete calculator only sets
LANGUAGE+HYPHENATION_LOCALEandimplements
calculateScore(float $asl, float $asw).#[AutoconfigureTag('deepl.readability')], collected via#[AutowireIterator('deepl.readability')]intoReadabilityCalculatorRegistry(exposed through
#[AsAlias]), and resolved per content language by itsprimary subtag (
ReadabilityCalculatorFactory→ registrynormalizeLanguage), soen-US/en-GBboth map to the English calculator.ASL= words / sentences andASW= syllables / word:206.835 - 1.015 * ASL - 84.6 * ASW180 - ASL - 58.5 * ASW207 - 1.015 * ASL - 73.6 * ASW206 - ASL - 65 * ASW248.835 - 1.015 * ASL - 84.6 * ASWes) is DeepL-supported but intentionally not shipped: thecommonly cited Fernández-Huerta formula carries a documented transcription
error, so it is described as a contribution candidate rather than guessed.
Quality
CGL, PHPStan (level 8), unit and functional tests all pass for TYPO3 v13 and
v14; the documentation renders cleanly.
Refs: DPL-140
Cherry-picked and adapted from #16.