nlp.text("She sells seashells").negate()
// She doesn't sell seashells
nlp_compromise aims to be the reasonable way to use language in software.
- smaller than jQuery (100k)
- 86% on the Penn treebank
- keypress speed, constant-time
- caniuse, yessir. IE9+
- no dependencies, training, or configuration.
It's a use-focused, satisfactory javascript library for understanding, changing, and making written english.
:boom: Welcome to v2.0! Please file an issue if you find something 💥
npm install nlp_compromise
<script src="./builds/nlp_compromise.es5.min.js"> </script>
let nlp = require("nlp_compromise");
nlp.text('She sells seashells').to_past()
// She sold seashells
nlp.verb("speak").conjugate();
// { past: 'spoke',
// infinitive: 'speak',
// gerund: 'speaking',
// actor: 'speaker',
// present: 'speaks',
// future: 'will speak',
// perfect: 'have spoken',
// pluperfect: 'had spoken',
// future_perfect: 'will have spoken'
// }
nlp.noun("dinosaur").pluralize();
// "dinosaurs"
nlp.term("hamburger").syllables();
// [ 'ham', 'bur', 'ger' ]
nlp.person("Tony Hawk").article();
// "he"
nlp.text("Tony Danza did a kickflip").people();
// "Tony Danza"
nlp.value("five hundred and sixty").number;
// 560
we've also got a modest, though ambitious plugin ecosystem:
nlp.plugin(require("nlp-locale"))
nlp.term("favourite").toAmerican()
// favorite
nlp.plugin(require("nlp-syllables"));
var t2 = nlp.term('houston texas');
t2.syllables()
//[ [ 'hous', 'ton' ], [ 'tex', 'as' ] ]
nlp.plugin(require("nlp-ngram"));
var t4 = nlp.text(`Tony Hawk played Tony Hawk's pro skater`);
t4.ngram({min_count: 2});
// [ { word: 'tony hawk', count: 2, size: 1 } ]
nlp_compromise is a wicked-problem solved with many hands. Contributions in all forms are respected.
Join our slack group
or our infrequent announcement email-list