Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/node_modules/@stdlib/nlp/sentencize/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
22 changes: 22 additions & 0 deletions lib/node_modules/@stdlib/nlp/sentencize/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down
Loading