mirror of
https://github.com/kemalai/FreeCrawl-SEO-Tool.git
synced 2026-10-18 00:39:38 +02:00
fix: sentence count stalls on long unpunctuated pages (#36)
This commit is contained in:
1 parent
e31fd1f367
commit
865a25aba4
1 file changed
+4
-2
@@ -2604,8 +2604,10 @@ function computeReadability(text: string, wordCount: number): ReadabilityScores
|
||||
}
|
||||
// Sentence boundary heuristic: . / ! / ? / … followed by whitespace or
|
||||
// end of text. Multiple terminators collapse into one. Newline already
|
||||
// collapsed to single space upstream.
|
||||
const sentenceMatches = text.match(/[^.!?…]+[.!?…]+/g);
|
||||
// collapsed to single space upstream. Counting each non-terminator ->
|
||||
// terminator boundary gives the same count as `/[^.!?…]+[.!?…]+/g`,
|
||||
// which backtracks quadratically on a long unterminated run of text.
|
||||
const sentenceMatches = text.match(/[^.!?…][.!?…]/g);
|
||||
const sentenceCount = sentenceMatches ? sentenceMatches.length : 1;
|
||||
|
||||
let totalSyllables = 0;
|
||||
|
||||
Reference in new issue
Block a user