npm install compromise-scan
a very-fast lookup for compromise documents, when you have a lot of terms to look up.
const nlp = require('compromise') nlp.extend(require('compromise-scan')) // create a compressed lookup trie let trie = nlp.buildTrie(['two three four', 'three']) // create a document let doc = nlp('one two three four five.') // throw it at a document let m = doc.scan(trie) m.debug() // throw it at other documents nlp('three four five six.').scan(trie) nlp('one two. seven eight nine.').scan(trie)
compared to our typical lookup function, it's outrageously fast.
based on BrunoRB/ahocorasick by Bruno Roberto Búrigo.