compromise-keypress
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published
a 'memoization' plugin for compromise

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.

npm install compromise-keypress
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

Readme

Keywords

none

Package Sidebar

Install

npm i compromise-keypress

Weekly Downloads

7

Version

0.0.2

License

MIT

Unpacked Size

10.3 kB

Total Files

6

Last publish

Collaborators

  • spencermountain