Match lexicon words that start with # or @
This commit is contained in:
1 parent
1a4531e30f
commit
3ff36c655a
2 files changed
+21
No files matched your search
@@ -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')
|
||||
|
||||
Reference in new issue
Block a user