The Gunning-Fog index is a measure of text readability. It represents the approximate reading age of the text - the age someone will need to be to understand what they are reading
The following is the algorithm to determine the Gunning-Fog index:
(average_words_sentence + percentage_of_words_with_more_than_three_syllables) * 0.4The above produces a number, which is a rough measure of the age someone must be to understand the content. The lower the number, the more understandable the content will be to your visitors. Web sites should aim to have content that falls roughly in the 11-15 range for this test.
Any number returned over the value of 22 can be taken to be just 22, and is roughly equivalent to post-graduate level.
Below are a selection of function you can use to determine the Gunning-Fog index of text. To calculate this, all you need to is call the function as follows, where $text is the text you wish to measure the readability of.
$gunning_fog_score = gunning_fog_score($text);function gunning_fog_score($text) {
return ((average_words_sentence($text) + percentage_number_words_three_syllables($text)) * 0.4);
}function average_words_sentence($text) {
$sentences = strlen(preg_replace('/[^\.!?]/', '', $text));
$words = strlen(preg_replace('/[^ ]/', '', $text));
return ($words/$sentences);
}function percentage_number_words_three_syllables($text) {
$syllables = 0;
$words = explode(' ', $text);
for ($i = 0; $i < count($words); $i++) {
if (count_syllables($words[$i]) > 2) {
$syllables ++;
}
}
$score = number_format((($syllables / count($words)) * 100));
return ($score);
}function count_syllables($word) {
$subsyl = Array(
'cial'
,'tia'
,'cius'
,'cious'
,'giu'
,'ion'
,'iou'
,'sia$'
,'.ely$'
);
$addsyl = Array(
'ia'
,'riet'
,'dien'
,'iu'
,'io'
,'ii'
,'[aeiouym]bl$'
,'[aeiou]{3}'
,'^mc'
,'ism$'
,'([^aeiouy])\1l$'
,'[^l]lien'
,'^coa[dglx].'
,'[^gq]ua[^auieo]'
,'dnt$'
);
// Based on Greg Fast's Perl module Lingua::EN::Syllables
$word = preg_replace('/[^a-z]/is', '', strtolower($word));
$word_parts = preg_split('/[^aeiouy]+/', $word);
foreach ($word_parts as $key => $value) {
if ($value <> '') {
$valid_word_parts[] = $value;
}
}
$syllables = 0;
foreach ($subsyl as $syl) {
if (strpos($word, $syl) !== false) {
$syllables--;
}
}
foreach ($addsyl as $syl) {
if (strpos($word, $syl) !== false) {
$syllables++;
}
}
if (strlen($word) == 1) {
$syllables++;
}
$syllables += count($valid_word_parts);
$syllables = ($syllables == 0) ? 1 : $syllables;
return $syllables;
}
Tags
Syndication
If you like this post, subscribe to my full feed or partial feed.

ILoveJackDaniels.com is the online playground of