diff --git a/lib/node_modules/@stdlib/nlp/sentencize/lib/main.js b/lib/node_modules/@stdlib/nlp/sentencize/lib/main.js index e63c524ccdb0..8cf46b32640f 100644 --- a/lib/node_modules/@stdlib/nlp/sentencize/lib/main.js +++ b/lib/node_modules/@stdlib/nlp/sentencize/lib/main.js @@ -68,7 +68,8 @@ function isEndOfSentence( tokens, i ) { if ( ( token === '!' || token === '?' ) && !RE_PREFIXES.test( tokens[ im1 ] ) && - !RE_SUFFIXES.test( tokens[ ip1 ] ) + !RE_SUFFIXES.test( tokens[ ip1 ] ) && + ( tokens[ ip1 ] !== '!' && tokens[ ip1 ] !== '?' ) ) { return true; } diff --git a/lib/node_modules/@stdlib/nlp/sentencize/test/test.js b/lib/node_modules/@stdlib/nlp/sentencize/test/test.js index 546c70964980..304534773b85 100644 --- a/lib/node_modules/@stdlib/nlp/sentencize/test/test.js +++ b/lib/node_modules/@stdlib/nlp/sentencize/test/test.js @@ -289,6 +289,28 @@ tape( 'the function splits a string into an array of sentences (unfinished last t.end(); }); +tape( 'the function splits a string into an array of sentences (multiple punctuation marks)', function test( t ) { + var expected; + var actual; + var str; + + str = 'HAPPY BIRTHDAY!!! Have an awesome day!'; + expected = [ 'HAPPY BIRTHDAY!!!', 'Have an awesome day!' ]; + actual = sentencize( str ); + t.deepEqual( actual, expected, 'returns an array of sentences' ); + + str = 'What?? How can that be??'; + expected = [ 'What??', 'How can that be??' ]; + actual = sentencize( str ); + t.deepEqual( actual, expected, 'returns an array of sentences' ); + + str = 'How dare you!?!'; + expected = [ 'How dare you!?!' ]; + actual = sentencize( str ); + t.deepEqual( actual, expected, 'returns an array of sentences' ); + t.end(); +}); + tape( 'the function returns an empty array if provided an empty string', function test( t ) { var out = sentencize( '' ); t.equal( isArray( out ), true, 'returns an array' );