Giter Site home page Giter Site logo

compromise's Introduction

natural language processing, actually in the browser
(formerly nlp_compromise)
inspect and play with english text.

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

demos   |   quickStart   |   docs

no training, configuration, or prolog

the idea is, reach-in to a part of the text, and change it:

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

or just be downright fancy

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

or grab specific parts, and analyze-the-heck out of them:

r = nlp(freshPrince)
r.places().sort('freq').unique().data()
/*[
  {text: 'West Philadelphia'},
  {text: 'Bel-Air'}
]*/
Part-of-Speech Tagging️ Named-Entity Recognition️ 🍾Verb Conjugation ✨Inflection/Pluralization

Client-side:

<script src="https://unpkg.com/compromise@latest/builds/compromise.min.js"></script>
<script>
  var r = nlp('dinosaur').nouns().toPlural()
  console.log(r.out('text'))
  //dinosaurs
</script>

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="nl-Person nl-Noun nl-FirstName">Tony</span>
  <span class="nl-Person nl-Noun nl-LastName">Hawk</span>
  <span>&nbsp;</span>
  <span class="nl-Verb nl-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 ) ❤️️

compromise's People

Contributors

spencermountain avatar ilyankou avatar silentrob avatar leoseccia avatar khtdr avatar kiran-rao avatar wallali avatar creatorrr avatar johnyesberg avatar davidbuhler avatar nloveladyallen avatar kahwee avatar soyjavi avatar ericcarraway avatar anastasiia-zolochevska avatar abazhenov avatar nkov avatar ndarville avatar cranesandcaff avatar dijs avatar stevebakh avatar gunyarakun avatar tscheys avatar tsavo avatar fay-jai avatar brandonjy avatar andrewwalsh avatar hearsid avatar npmcdn-to-unpkg-bot avatar somejeff avatar

Watchers

Joni Salminen avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.