Add more sentence ending punctuation

This commit is contained in:
Alfred Melch 2019-12-22 19:28:33 +01:00
parent f87acd5514
commit 2e4cdbe67b

View File

@ -1,3 +1,5 @@
const sentenceEndings = '.!?:;'
/**
* Returns an object containing the segmented text and metainfo about word and
* sentence beginnings
@ -24,7 +26,9 @@ export function parseText(text, maxLength) {
curIdx += fragments.length
// set flag if next word is sentence beginning
sentenceFlag = word.endsWith('.')
sentenceFlag = sentenceEndings
.split('')
.some(ending => word.endsWith(ending))
}
return { segments, words, sentences }