Skip to content

Commit

Permalink
fix contraction issue #1128
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Jul 31, 2024
1 parent 8aa5a97 commit 02b571d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down
2 changes: 1 addition & 1 deletion src/2-two/contraction-two/compute/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions tests/two/contractions/contraction-match.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

0 comments on commit 02b571d

Please sign in to comment.