From a6a8f9ca8f2d0a979c8489c75174f5a3b1d7ae2e Mon Sep 17 00:00:00 2001 From: spencer kelly Date: Mon, 1 Apr 2024 12:40:21 -0400 Subject: [PATCH] allow 3 slashes in a word --- scratch.js | 12 ++---------- src/1-one/tokenize/compute/alias.js | 2 +- tests/one/misc/slash.test.js | 12 ++++++------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/scratch.js b/scratch.js index c4591d14b..25ddfad8a 100644 --- a/scratch.js +++ b/scratch.js @@ -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 ' diff --git a/src/1-one/tokenize/compute/alias.js b/src/1-one/tokenize/compute/alias.js index ac4c2e598..e8889ff08 100644 --- a/src/1-one/tokenize/compute/alias.js +++ b/src/1-one/tokenize/compute/alias.js @@ -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 !== '') { diff --git a/tests/one/misc/slash.test.js b/tests/one/misc/slash.test.js index 38f903bad..dd4a0c083 100644 --- a/tests/one/misc/slash.test.js +++ b/tests/one/misc/slash.test.js @@ -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() })