Add more sentence ending punctuation

context-store
Alfred Melch 5 years ago
parent f87acd5514
commit 2e4cdbe67b

@ -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 }

Loading…
Cancel
Save