0.0.2 • Published 3 years ago

compromise-keypress v0.0.2

Weekly downloads
35
License
MIT
Repository
github
Last release
3 years ago

If you're parsing a document that's changing in real-time, it's wasteful to re-parse the whole document each time one character changes.

This plugin adds a new function nlp.keypress() to the compromise object. This method works the same as the main nlp() object, except it remembers each sentence, and only re-analyses a sentence if it changes.

const nlp = require('compromise')
nlp.extend(require('compromise-keypress'))

let doc = nlp.keypress('Seven bottles of beer on the wall.')

doc = nlp.keypress('Seven bottles of beer on the wall. Six bottles of beer...')
// only re-tags the second sentence

nlp.clear() // invalidate the cache
// (free-up any cached sentences from memory)

.keypress() automatically deletes unused cached sentences, so extended-use shouldn't hog-up memory needlessly.

Work in progress.

See Also

MIT