Add more sentence ending punctuation
This commit is contained in:
		
							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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user