Skip to content

Commit

Permalink
Improve information
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 17, 2023
1 parent 02922ae commit 7f7e896
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resources/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"failed.content.no_heading": "The page does not contain any h1 tag, while it should.",
"failed.content.no_title": "The page does not contain a title tag, while it should.",
"failed.content.title_length": "The page title is :actualValue characters long. It should be max :expectedValue characters long.",
"failed.content.too_long_sentence": "The page contains :actualValue sentences that are too long.",
"failed.content.too_long_sentence": "The page has :actualValue too long sentences which exceeds 20% of the total sentences. Rectify :neededToFix sentences to meet the 20% limit.",
"failed.content.transition_words_ratio_check.no_phrases_found": "The page does not contain any transition words.",
"failed.content.transition_words_ratio_check.too_few_transition_words": "The page contains too few transition words. The recommended minimum is 30%, while the actual number is :actualValue%.",
"failed.meta.description": "The page does not contain a description meta tag, while it should.",
Expand Down
2 changes: 1 addition & 1 deletion resources/lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"failed.content.no_heading": "The page does not contain any h1 tag, while it should.",
"failed.content.no_title": "The page does not contain a title tag, while it should.",
"failed.content.title_length": "The page title is :actualValue characters long. It should be max :expectedValue characters long.",
"failed.content.too_long_sentence": "The page contains :actualValue sentences that are too long.",
"failed.content.too_long_sentence": "De pagina bevat :actualValue te lange zinnen welke meer dan 20% van het totale aantal zinnen uitmaken. Corrigeer :neededToFix zinnen om aan de limiet van 20% te voldoen.",
"failed.content.transition_words_ratio_check.no_phrases_found": "De pagina bevat geen zinnen.",
"failed.content.transition_words_ratio_check.too_few_transition_words": "De pagina bevat te weinig transitiewoorden. Het zou minstens 30% moeten zijn, maar het is :actualValue%.",
"failed.meta.description": "The page does not contain a description meta tag, while it should.",
Expand Down
5 changes: 5 additions & 0 deletions src/Checks/Content/TooLongSentenceCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ public function validateContent(Response $response, Crawler $crawler): bool

// If more than 20% of the total sentences are too long, fail
if (count($sentencesWithTooManyWords) / count($phrases) > 0.2) {

// Count how many sentences needed to fix to fall below 20%
$sentencesNeededToFix = count($sentencesWithTooManyWords) - (count($phrases) * 0.2);

$this->failureReason = __('failed.content.too_long_sentence', [
'actualValue' => count($this->actualValue),
'neededToFix' => round($sentencesNeededToFix, 0, PHP_ROUND_HALF_UP),
]);

return false;
Expand Down

0 comments on commit 7f7e896

Please sign in to comment.