Skip to content

Commit

Permalink
test(wink-nlp-specs): add nbsp test cases for entity & sentence
Browse files Browse the repository at this point in the history
references #135

Co-authored-by: Rachna <rachna@graype.in>
  • Loading branch information
sanjayaksaxena and rachnachakraborty committed Mar 29, 2024
1 parent e139a5a commit 6314c4f
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion test/wink-nlp-specs.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ describe( 'wink-nlp test-coverage and basic behavior', function () {
expect( doc.out() ).to.equal( sentence );
} );

it( 'should tokenize/detokenize the following sentence with non-breaking spaces', function () {
it( 'should tokenize/detokenize the text with non-breaking spaces', function () {
// Reconstruction.
expect( nlp.readDoc( nbspTokensArray.join('\u00a0') ).out() ).to.equal( nbspTokensArray.join('\u00a0') );
expect( nlp.readDoc( nbspTokensArray.join(' \u00a0') ).out() ).to.equal( nbspTokensArray.join(' \u00a0') );
Expand All @@ -144,6 +144,27 @@ describe( 'wink-nlp test-coverage and basic behavior', function () {
expect( nlp.readDoc( nbspTokensArray.join(' \u00a0\u00a0') ).out() ).to.equal( nbspTokensArray.join(' \u00a0\u00a0') );
} );

it( 'should tokenize/detokenize a sentence with non-breaking spaces', function () {
var textWith2S = 'I met Mr.\u00a0Gandhi. Mr.\u00a0Gandhi is a nice person.';
var sentences = nlp.readDoc( textWith2S ).sentences();
var sentencesText = [ 'I met Mr.\u00a0Gandhi.', 'Mr.\u00a0Gandhi is a nice person.' ];
// Reconstruction.
sentences.each( ( s, k ) => {
expect( s.out() ).to.equal( sentencesText[ k ] );
} );
} );

it( 'should tokenize/detokenize the entities\' value as text with non-breaking spaces', function () {
var textWith2S = 'I purchased 10 mangoes on March\u00a010th for US$\u00a099.00.';
var entities = nlp.readDoc( textWith2S ).entities();
var entitiesText = [ '10', 'March\u00a010th', 'US$\u00a099.00' ];
// Reconstruction.
entities.each( ( e, k ) => {
expect( e.out( ) ).to.equal( entitiesText[ k ] );
expect( e.out( its.value, as.text ) ).to.equal( entitiesText[ k ] );
} );
} );

it( 'should not contain empty tokens', function () {
var doc = nlp.readDoc( sentence );
expect( findEmptyTokens( doc ) ).deep.equal( [] );
Expand Down

0 comments on commit 6314c4f

Please sign in to comment.