Home » Text » Text_Statistics » Bug #4491
Add grade level
Details
| 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) |
Comments
[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;
}