JSPM

  • Created
  • Published
  • Downloads 136430
  • Score
    100M100P100Q156897F
  • License MIT

natural language processing in the browser

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

natural-language processing in the browser
npm install compromise@next
(formerly nlp_compromise)

inspect and play with english text

nlp('I look just like buddy holly').sentences().toPastTense().out('text')
// "I looked just like buddy holly."

Demos   |   Quick-start   |   Docs   |   Accuracy

💥Welcome to v7💥
a lot has changed!

Yup,

###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>&nbsp;</span>
  <span class="Verb PastTense">won</span>
</span>
*/

and yes, ofcourse, there's a lot more stuff.

###Join-in:

we're fun, we're using semver, and moving fast. 🛠️ get involved 💃

 

#See also For the former promise-library, see jnewman/compromise (Thanks to the awesome jnewman for the npm package!)

(don't forget NLTK, GATE, Stanford, and Illinois toolkit )