I forget where exactly I lifted these from, but they’ve been very useful for some coding projects I’ve been working on silently in the background.

Maths and English
I thought I would share them here. Enjoy and use responsibly.
- Simple Measure of Gobbledygook is actually pretty cool.
- Flesch Reading Ease Score you’ve probably heard of before. It’s another way to “grade” text/content/words.
Maths and english, boys, maths and english…
// Number of words: number of space series or linebreaks + 1
$wc = preg_match_all( '/[ \r]/', preg_replace( '/ +/', ' ', $mynewtext), $tmp );
// Number of syllables: vowels not followed by another vowel. Quite accurate approximation.
$syc = preg_match_all( '/[aeiouy][^aeiouy]/', $mynewtext, $tmp );
// Number of polysyllabic words (>=3 syllables): Vowel, non-spaces, vowel, non-spaces, vowel (or more non-spaces-vowel)
$psyc = preg_match_all( '/[aeiouy]([^ ]*[aeiouy]){2,}/', $mynewtext, $tmp );
// Number of sentences: Number of periods, exclamation marks, question marks and linebreaks
$sec = preg_match_all( '/[.!?\r]/', $mynewtext, $tmp );
// Flesch Reading Ease Score
$fres = 206.835 - 1.015 * ( $wc / $sec ) - 84.6 * ( $syc / $wc );
// Simple Measure of Gobbledygook
$smog = 1.043 * sqrt( $psyc * ( 30 / $sec ) ) + 3.1291;
Tags: php reading level, accurate approximation, content words, php code, exclamation marks, flesch reading ease score, php wordcount, Stress (linguistics), maths and english, english boys, PHP snippets, polysyllabic words, Word Count, question marks, space series, flesch reading ease, syllable count, text content 





