开发者社区> 镜像站> NPM> compromise-keypress
compromise-keypress
memoization plugin for nlp-compromise
Last updated 10 months ago by spencermountain .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install compromise-keypress 
SYNC missed versions from official npm registry.
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

Current Tags

  • 0.0.1                                ...           latest (10 months ago)

1 Versions

  • 0.0.1                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (0)
None
Dependents (0)
None