Skip to content

Commit

Permalink
allow 3 slashes in a word
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Apr 1, 2024
1 parent 78b62aa commit a6a8f9c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
12 changes: 2 additions & 10 deletions scratch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,8 @@ import nlp from './src/three.js'
// nlp.plugin(plg)
// nlp.verbose('tagger')

nlp.plugin({
frozen: {
'mr plow': 'Frozen',
},
})
let doc = nlp('that name again is Mr Plow..').debug()

// lessThan

// nlp(`IEEE/WIC/ACM`).debug()
let doc = nlp(`IEEE/WIC/ACM`).debug()
console.log(doc.docs[0])
// console.log(nlp(`IEEE/WIC`).debug().docs[0][0])

// const prependingText = 'the patient will need an '
Expand Down
2 changes: 1 addition & 1 deletion src/1-one/tokenize/compute/alias.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const addAliases = function (term, world) {
if (hasSlash.test(str) && !hasDomain.test(str) && !isMath.test(str)) {
let arr = str.split(hasSlash)
// don't split urls and things
if (arr.length <= 2) {
if (arr.length <= 3) {
arr.forEach(word => {
word = word.trim()
if (word !== '') {
Expand Down
12 changes: 6 additions & 6 deletions tests/one/misc/slash.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ test('slash match', function (t) {
t.equal(doc.has('his'), true, here + 'slash with lots of spaces')
t.equal(doc.has('her'), true, here + 'slash with lots of spaces')

// str = 'left his/her/their backpack '
// doc = nlp(str)
// t.equal(doc.has('his'), true, here + 'three-slash - his')
// t.equal(doc.has('her'), true, here + 'three-slash - her')
// t.equal(doc.has('their'), true, here + 'three-slash - their')
// t.equal(doc.has('his/her/their'), true, here + 'three-slash - his/her/their ')
str = 'left his/her/their backpack '
doc = nlp(str)
t.equal(doc.has('his'), true, here + 'three-slash - his')
t.equal(doc.has('her'), true, here + 'three-slash - her')
t.equal(doc.has('their'), true, here + 'three-slash - their')
t.equal(doc.has('his/her/their'), true, here + 'three-slash - his/her/their ')

t.end()
})

0 comments on commit a6a8f9c

Please sign in to comment.