diff --git a/src/1-one/lexicon/compute/single-word.js b/src/1-one/lexicon/compute/single-word.js index 9d79fa9..ae584ec 100644 --- a/src/1-one/lexicon/compute/single-word.js +++ b/src/1-one/lexicon/compute/single-word.js @@ -17,6 +17,11 @@ const checkLexicon = function (terms, i, world) { setTag([t], lexicon[word], world, false, '1-lexicon') return true } + // '#gojetsgo' can be in the lexicon with its hash + if (t.machine && Object.hasOwn(lexicon, t.normal)) { + setTag([t], lexicon[t.normal], world, false, '1-lexicon-normal') + return true + } // lookup aliases in the lexicon if (t.alias) { const found = t.alias.find(str => Object.hasOwn(lexicon, str)) diff --git a/tests/one/lexicon/core-lexicon.test.js b/tests/one/lexicon/core-lexicon.test.js index 8d24fdf..3ea8199 100644 --- a/tests/one/lexicon/core-lexicon.test.js +++ b/tests/one/lexicon/core-lexicon.test.js @@ -74,6 +74,22 @@ test('apostrophe lexicon:', function (t) { t.end() }) +test('hashtag lexicon:', function (t) { + const lex = { + '#GoJetsGo': 'SportsTeam', + '@NHLJets': 'SportsTeam', + } + let doc = nlp('#GoJetsGo', lex) + t.equal(doc.match('#SportsTeam').text(), '#GoJetsGo', here + 'lexicon w/ hashtag') + + doc = nlp('go @NHLJets', lex) + t.equal(doc.match('#SportsTeam').text(), '@NHLJets', here + 'lexicon w/ at-mention') + + doc = nlp('GoJetsGo', lex) + t.equal(doc.has('#SportsTeam'), false, here + 'no hashtag, no match') + t.end() +}) + test('long lexicon:', function (t) { nlp.addWords({ 'new york yankees are cool and not bad': 'Long' }) let doc = nlp('the new york yankees are cool and smart')