0.0.9 • Published 5 years ago

compromise-plugin v0.0.9

Weekly downloads
1,332
License
MIT
Repository
github
Last release
5 years ago
//take this plugin,
var plugin = {
  name:'compromise-dinosaur',
  words: {
    brontosaurus:'Dinosaur',
    trex: 'Dinosaur'
  },
  tags: {
    Dinosaur: {
      isA: 'Animal'
    },
    Animal: {
      isA: 'Noun'
    }
  },
  regex: {
    '.osaurus$': 'Dinosaur',
    'uuu+': 'Exaggeration'
  }
};

var pack = require('compromise-plugin');
var tinyPlugin= pack(plugin) //CRAZY_SMALL!


//then load it in nlp-compromise (it unpacks automatically)
nlp.plugin(tinyPlugin);
var doc = nlp('i saw a HUUUUGE trex').debug()
/*
  'i'           - Pronoun, Noun, Singular
  'saw'         - PastTense, Verb, VerbPhrase
  'a'           - Determiner
  'HUUUUGE'     - Exaggeration
  'trex'        - Dinosaur, Animal, Noun, Singular
*/

the cool thing about this process is that the pack() step can be as slow as we'd like. It can do all-sorts of laborious things up-front, to ensure the plugin can 'pop' back into uncompressed form very quickly.

CLI

if you prefer, you can integrate compromise-plugin into your workflow from the command-line:

npm i -g compromise-plugin
#pack it..
compromise-pack ./path/to/myPlugin.js | ./plugin.min.js

#unpack it..
compromise-unpack ./path/to/plugin.min.js

Compatibility

the compromise plugin spec will change over time, and to avoid having to remember which versions line-up, we will try to use the same major-version numbers as compromise.

so if you want a plugin to work with comprimise v12, publish it with compromise-plugin@12.*.*

Other examples

//military-words
{
  plurals:{
    barracks:'barracks'
  },
  patterns:{
    "#Ordinal infantry? division":'Noun',
    "major (general|lieutenant|#Person)":'Person',
    "#Posessive six":'Noun',
    "over$":'Expression'
  },
  words:{
    'niner':'Value',
    'buck sergeant':'Person'
  }
}

MIT

0.0.9

5 years ago

0.0.8

7 years ago

0.0.7

7 years ago

0.0.6

7 years ago

0.0.5

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago