Skip to content
natural language processing on the clientside
JavaScript
Find file
Latest commit 8783ac7 Spencer Kelly bump version for npm

README.md

Natural Language Processing in the browser

CodacyBadge npm version downloads

nlp.text("She sells seashells").negate()
// She doesn't sell seashells

nlp_compromise aims to be the reasonable way to use language in software.

Yup,

  • 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.

                - Check it out -

   :boom: Welcome to v3.0!   Please file an issue if you find something :boom:

Off you go:

npm install nlp_compromise

<script src="http://rawgit.com/nlp-compromise/nlp_compromise/master/builds/nlp-compromise.es5.min.js"></script>

let nlp = require("nlp_compromise"); // or nlp = window.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 } ]

                try it out

View the Full API Documentation

Development

Issue Stats Issue Stats

nlp_compromise is a wicked-problem solved with many hands. Contributions in all forms are respected.

Join our slack group slack or our infrequent announcement email-list

MIT license

Something went wrong with that request. Please try again.