mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-09-20 14:39:34 +02:00
feat: text-statistic (fixed service count sentences method)
This commit is contained in:
@@ -14,12 +14,10 @@ function countCharacters(text: string): number {
|
||||
}
|
||||
|
||||
function countSentences(text: string, options: InitialValuesType): number {
|
||||
const sentenceDelimiters = options.sentenceDelimiters || [
|
||||
'.',
|
||||
'!',
|
||||
'?',
|
||||
'...'
|
||||
];
|
||||
const sentenceDelimiters = options.sentenceDelimiters
|
||||
? options.sentenceDelimiters.split(',').map((s) => s.trim())
|
||||
: ['.', '!', '?', '...'];
|
||||
|
||||
const regex = new RegExp(`[${sentenceDelimiters.join('')}]`, 'g');
|
||||
const sentences = text
|
||||
.split(regex)
|
||||
|
Reference in New Issue
Block a user