From 02b571d353e59a2e089754623ddcf7d6b104b7cc Mon Sep 17 00:00:00 2001 From: spencer kelly Date: Wed, 31 Jul 2024 13:51:51 -0400 Subject: [PATCH] fix contraction issue #1128 --- scratch.js | 2 +- src/2-two/contraction-two/compute/index.js | 2 +- tests/two/contractions/contraction-match.test.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/scratch.js b/scratch.js index bb4047b4d..a6b193e9d 100644 --- a/scratch.js +++ b/scratch.js @@ -4,7 +4,7 @@ import nlp from './src/three.js' // nlp.plugin(plg) nlp.verbose('tagger') // -let doc = nlp(` everybody's creating, and they're `) +let doc = nlp(` Somebody's hat`) doc.debug() diff --git a/src/2-two/contraction-two/compute/index.js b/src/2-two/contraction-two/compute/index.js index 17163991b..99a13e9d9 100644 --- a/src/2-two/contraction-two/compute/index.js +++ b/src/2-two/contraction-two/compute/index.js @@ -63,7 +63,7 @@ const contractionTwo = view => { for (let i = terms.length - 1; i >= 0; i -= 1) { // is it already a contraction if (terms[i].implicit) { - return + continue } let after = null if (byApostrophe.test(terms[i].normal) === true) { diff --git a/tests/two/contractions/contraction-match.test.js b/tests/two/contractions/contraction-match.test.js index c91989666..e91eec517 100644 --- a/tests/two/contractions/contraction-match.test.js +++ b/tests/two/contractions/contraction-match.test.js @@ -105,4 +105,18 @@ test('contraction-no-skip', function (t) { t.end() }) +test('multiple-contractions', function (t) { + let doc = nlp(`everybody's creating, and they're going`) + t.ok(doc.has('everybody is') && doc.has('they are'), `everybody's + they're`) + doc = nlp(`spencer's walking to the store and she's mad`) + t.ok(doc.has('spencer is') && doc.has('she is'), `spencer's + she's`) + + doc = nlp(`Somebody's going to see`) + t.equal(doc.has('somebody is'), true, `Somebody's going`) + + doc = nlp(`Somebody's hat`) + t.equal(doc.has('somebody is'), false, `Somebody's hat`) + + t.end() +})