Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 11, 2023
1 parent d8e37ac commit 18938c9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Checks/Content/FleschReadingEaseCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,23 @@ public function validateContent(Crawler $crawler): bool
// Average syllable count per word
$averageSyllableCount = $this->getAverageSyllableCountPerWord($sentences);

dd($averageSyllableCount, $averageWordCount);
$fleschReadingEase = $this->fleschReadingEaseScoreFromAverages($averageSyllableCount, $averageWordCount);

// TODO:
// Average word count is too low and the average syllable count is too high. That's why the calculation is not accurate.
// Probably because we still get sentences like: cls-11{stroke:#fe8185}
// We need to find a better way to get all sentences from a web page.
dd($averageSyllableCount, $averageWordCount, $fleschReadingEase);

// return true;
}

private function fleschReadingEaseScoreFromAverages(float $averageSyllableCount, float $averageWordCount): float
{
$fleschReadingEase = 206.835 - (1.015 * $averageWordCount) - (84.6 * $averageSyllableCount);
return $fleschReadingEase;
}

private function getAverageWordCountPerSentence(array $sentences): int
{
$totalWordCount = 0;
Expand Down

0 comments on commit 18938c9

Please sign in to comment.