JSPM

  • Created
  • Published
  • Downloads 143244
  • Score
    100M100P100Q157086F
  • 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, actually in the browser
(formerly nlp_compromise)
npm install compromise

inspect and play with english text.

πŸ’₯Welcome to v7πŸ’₯
a lot has changed!
```javascript let r = nlp('I look just like buddy holly.') r.sentences().toPastTense() r.out('text') // "I looked just like buddy holly." ```
200k
  just a javascript file  
86%
  on the Penn treebank  
πŸ™
  npm install compromise  
IE9+
    caniuse, youbetcha    

demos   |   quickStart   |   docs   |   accuracy

no training, configuration, or prolog

the idea is, reach-in to a part of the text, and change it:
```javascript r = nlp('john is really nice. sara sings loudly.')

r.match('#Person').toUpperCase() //JOHN is really nice. SARA sings loudly.

//or pluck-out some parts, r.remove('#Adverb') // "JOHN is nice. SARA sings."

//replacements, r.replace('is nice', 'is bad') // "JOHN is bad. SARA sings."

//fancy! r.sentences().toNegative() // "JOHN is not bad. SARA doesn't sing."

<div align="left">
  grab those parts, and <b>analyze-the-heck</b> out of them:
</div>
```javascript
r = nlp(chomskyFanFic)
r.places().sort('freq').unique().data()
/*[
  {text: 'MIT lecture hall'},
  {text: '23 Desperado dr.'},
  {text: 'desert island'},
]*/

r.questions().not('^but how .+').data()
/* [] */
    πŸ€—     πŸ€—     πŸ€—     πŸ€—     πŸ€—     πŸ€—     πŸ€—     πŸ€—     πŸ€—     πŸ€—
Part-of-Speech Tagging Named-Entity Resolution Verb Conjugation Inflection/Pluralization
###Client-side: ```html ```

###Tense:

let r = nlp('she sells seashells by the seashore.')
r.sentences().toFutureTense().out('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.out('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().out('text')
// 'five of december'

r.values().toNumber().out('text')
// '5 of december'

###Normalization:

r = nlp("the guest-singer's bjΓΆrk at seven thirty.").normalize().out('text')
// 'The guest singer is Bjork at 7:30.'

###Named-entity recognition:

r = nlp('the opera about richard nixon visiting china')
r.topics().data()
// [
//   { text: 'richard nixon' },
//   { text: 'china' }
// ]

###Fancy outputs:

r = nlp('Tony Hawk won').out('html')
/*
<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 πŸ’ƒ
      Twitter      
      Slack group      
      Mailing-list      
      Pull-requests      

 

###Don't forget about:

For the former promise-library, see jnewman/compromise (Thanks Joshua!)

(also don't forget NLTK, GATE, Stanford, and Illinois toolkit ) ❀️️
[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/82cc8ebd98b64ed199d7be6021488062)](https://www.codacy.com/app/spencerkelly86/nlp_compromise)