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