Skip to content

Commit 708f1a0

Browse files
committed
fix: do not break subsequent exclamation or question marks
--- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: failed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
1 parent 93b976b commit 708f1a0

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/node_modules/@stdlib/nlp/sentencize/lib/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

lib/node_modules/@stdlib/nlp/sentencize/test/test.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
292314
tape( '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' );

0 commit comments

Comments
 (0)