mirror of
https://github.com/iib0011/omni-tools.git
synced 2025-11-07 09:24:55 +05:30
feat: text-statistic (fixed service count sentences method)
This commit is contained in:
parent
8740b8f72e
commit
e1f1c6a1c4
1 changed files with 4 additions and 6 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue