nlp performance plugin for compromise
npm install compromise-speed
### WorkerPool parse sentences of a large text in parallel: ```js import {workerPool} from 'compromise-speed' nlp.extend(workerPool) let doc = await nlp.workerPool(myNovel, 'the #Adjective of #Noun') doc.debug()//results ``` you can pass in a [compromise match](https://observablehq.com/@spencermountain/compromise-match-syntax), or a [net](https://observablehq.com/@spencermountain/compromise-sweep): ```js let net = nlp.buildNet([ { match: 'every single #Noun' }, { match: 'not (a|one) #Noun' }, ]) let doc = await nlp.workerPool(myNovel, net) doc.debug()//results ``` ### StreamFile parse and process a file from your filesystem, without loading it all into memory: ```js import {streamFile} from 'compromise-speed' nlp.extend(streamFile) nlp.streamFile('./path/to/file.txt', (s)=>{ // map fn on each sentence return s.if('the #Adjective of times') }).then(doc=>{ // just the returned matches doc.debug() }) ``` ### Keypress if you are running compromise on every keystroke, it is not necessary to re-parse all sentences, every time. This plugin will cache any already-parsed sentences, and combine them in-memory, with any changed ones. it will also un-cache any temporary sentences, to clear-up memory. ```js import {keyPress} from 'compromise-speed' nlp.extend(keyPress) let doc = nlp.keyPress('parsed once. it was the blurst of') doc = nlp.keyPress('parsed once. it was the blurst of times') ``` or in the browser: ```html ``` MIT