From 708f1a02472e35e114020a36ba6fd355702f93b6 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Sat, 22 Feb 2025 16:20:06 -0500 Subject: [PATCH] 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 --- --- .../@stdlib/nlp/sentencize/lib/main.js | 3 ++- .../@stdlib/nlp/sentencize/test/test.js | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) 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' );