Package Exports
- compromise
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (compromise) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
npm install compromise@next
nlp('I look just like buddy holly').sentences().toPastTense().out('text')
// "I looked just like buddy holly."
Demos | Quick-start | Docs | Accuracy
Yup,
- a 200k js file
- 86% on the Penn treebank
- keypress speed, constant-time.
- caniuse, uhuh. IE9+
- no dependencies, training, configuration, or prolog
###Grammar, for the win:
r = nlp('john is really nice. sara quickly walks.')
//pluck-out some parts
r.remove('#Adverb')
//reach-in and transform parts
r.match('#Person').toTitleCase()
r.plaintext()
// 'John is nice. Sara walks.'
###Conjugation:
r = nlp('she sells seashells by the seashore.').sentences().toFuture().text()
//'she will sell seashells...'
r.verbs().conjugate()
// [{ PastTense: 'sold',
// Infinitive: 'sell',
// Gerund: 'selling', ...
// }]
###Plural/singular:
r = nlp('a bottle of beer on the wall.')
r.nouns().first().toPlural()
r.text()
//'The bottles of beer on the wall.'
###Negation:
r = nlp('london is calling')
r.sentences().toNegative()
// 'london is not calling'
###Number interpretation:
r = nlp('fifth of december')
r.values().toCardinal().text()
// 'five of december'
r.values().toNumber().text()
// '5 of december'
###Clever normalization:
r = nlp("the guest-singer's björk at seven thirty.").normalize().text()
// 'The guest singer is Bjork at 7:30.'
###Named-entity recognition:
r = nlp('the opera about richard nixon visiting china')
r.match('(#Person|#Place|#Organization)').data()
// [
// { text: 'richard nixon', tags: ['Person'] },
// { text: 'china', tags: ['Place', 'Country'] }
// ]
###Fancy outputs:
r = nlp('Tony Hawk won').asHtml()
/*
<span>
<span class="Person Noun MalePerson">Tony Hawk</span>
<span> </span>
<span class="Verb PastTense">won</span>
</span>
*/
and yes, ofcourse, there's a lot more stuff.
###Join-in:
#See also For the former promise-library, see jnewman/compromise (Thanks to the awesome jnewman for the npm package!)
- naturalNode - decidedly fancier, statistical nlp in javascript
- SuperScript - clever conversation engine in javascript
- NodeBox Linguistics - conjugation, inflection in javascript
- reText - very impressive text utilities in javascript
- jsPos - js-build of the time-tested Brill-tagger
- spaCy - speedy, multilingual tagger in C/python
(don't forget NLTK, GATE, Stanford, and Illinois toolkit )