File tree Expand file tree Collapse file tree 2 files changed +24
-1
lines changed
lib/node_modules/@stdlib/nlp/sentencize Expand file tree Collapse file tree 2 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,8 @@ function isEndOfSentence( tokens, i ) {
6868 if (
6969 ( token === '!' || token === '?' ) &&
7070 ! RE_PREFIXES . test ( tokens [ im1 ] ) &&
71- ! RE_SUFFIXES . test ( tokens [ ip1 ] )
71+ ! RE_SUFFIXES . test ( tokens [ ip1 ] ) &&
72+ ( tokens [ ip1 ] !== '!' && tokens [ ip1 ] !== '?' )
7273 ) {
7374 return true ;
7475 }
Original file line number Diff line number Diff line change @@ -289,6 +289,28 @@ tape( 'the function splits a string into an array of sentences (unfinished last
289289 t . end ( ) ;
290290} ) ;
291291
292+ tape ( 'the function splits a string into an array of sentences (multiple punctuation marks)' , function test ( t ) {
293+ var expected ;
294+ var actual ;
295+ var str ;
296+
297+ str = 'HAPPY BIRTHDAY!!! Have an awesome day!' ;
298+ expected = [ 'HAPPY BIRTHDAY!!!' , 'Have an awesome day!' ] ;
299+ actual = sentencize ( str ) ;
300+ t . deepEqual ( actual , expected , 'returns an array of sentences' ) ;
301+
302+ str = 'What?? How can that be??' ;
303+ expected = [ 'What??' , 'How can that be??' ] ;
304+ actual = sentencize ( str ) ;
305+ t . deepEqual ( actual , expected , 'returns an array of sentences' ) ;
306+
307+ str = 'How dare you!?!' ;
308+ expected = [ 'How dare you!?!' ] ;
309+ actual = sentencize ( str ) ;
310+ t . deepEqual ( actual , expected , 'returns an array of sentences' ) ;
311+ t . end ( ) ;
312+ } ) ;
313+
292314tape ( 'the function returns an empty array if provided an empty string' , function test ( t ) {
293315 var out = sentencize ( '' ) ;
294316 t . equal ( isArray ( out ) , true , 'returns an array' ) ;
You can’t perform that action at this time.
0 commit comments