Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.1

Request #4491 Add grade level
Submitted: 2005-05-31 19:56 UTC
From: mjohnson at pitsco dot com Assigned: cweiske
Status: Closed Package: Text_Statistics
PHP Version: Irrelevant OS: NA
Roadmaps: (Not assigned)    
Subscription  


 [2005-05-31 19:56 UTC] mjohnson at pitsco dot com
Description: ------------ Add Flesch-Kincaid grade level. This is calculated with the formula: (0.39 x the average number of words per sentence) + (11.8 x the average number of syllables per word) - 15.59 I've included code in the reproduce code that modifies the _analyze function. I don't have a site I can put it on easily, otherwise I'd post the whole change (which includes the addition of a $gradeLevel variable) Reproduce code: --------------- function _analyze() { $lines = explode("\n", $this->text); foreach( $lines as $line ) { $this->_analyze_line($line); } $nSentences = $this->numSentences; if (empty($nSentences)) { $nSentences = 1; } $nWords = $this->numWords; if (empty($nWords)) { $nWords = 1; } $wordsPerSent = $nWords / $nSentences; $syllablesPerWord = $this->numSyllables/$nWords; $this->flesch = 206.835 - 1.015 * $wordsPerSent - 84.6 * $syllablesPerWord; $this->gradeLevel = 0.39 * $wordsPerSent + 11.8 * $syllablesPerWord - 15.59; }

Comments

 [2007-03-27 12:52 UTC] cweiske (Christian Weiske)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.