Coder Social home page Coder Social logo

coreylista / compromise Goto Github PK

View Code? Open in Web Editor NEW

This project forked from spencermountain/compromise

0.0 1.0 0.0 20.21 MB

natural language processing, in javascript

Home Page: http://compromise.cool

License: MIT License

JavaScript 99.95% HTML 0.05% TypeScript 0.01%

compromise's Introduction

natural language processing, in javascript
by Spencer Kelly and many contributors

var nlp = require('compromise')

nlp('Wee-ooh, I look just like buddy holly.').sentences().toPastTense()
// 'Wee-ooh, I looked just like buddy holly.'

nlp('..then consider me Miles Davis!').people().out('freq')
// [{ text:'Miles Davis', count:1 }]
210kb
        one javascript file        
86%
    on the Penn treebank    
🙏
    npm install compromise    
IE9+
      caniuse, youbetcha      
a least-fancy way to handle text,

Text in → data out.

without training, jargon or config

Demos       Usage       API       WTF

⚡️ on the Client-side

<script src="https://unpkg.com/compromise@latest/builds/compromise.min.js"></script>
<script>
  var doc = nlp('dinosaur')

  var str = doc.nouns().toPlural().out('text')
  console.log(str)
  // 'dinosaurs'
</script>

🌋 Server-side!

var nlp = require('compromise')

var doc = nlp('London is calling')
doc.sentences().toNegative()
// 'London is not calling'
nouns! verbs! adjectives!
people, places, organizations
seven hundred and fifty == 750
like a regex for a sentence
all your base are belong
contractions, style, mood..

pop right in:
var doc= nlp(myNovel) //whoosh
doc.match('the #Superlative of times').length
API is bearable:
doc.contractions().expand()
doc.people().lastNames()
loosely-held opinions..
var ayeRight= require('nlp-scottish-slang')
nlp.plugin(ayeRight)
nlp('Taps aff, high doh!')

no foolin,
6 years, 150 PRs, 60 devs
in production in the United Nations🎈

Throw in text,

even if it's just one word:

var doc = nlp('Ludwig van Beethoven')
doc.match('#TitleCase van #LastName').out()
// 'Ludwig van Beethoven'

doc.people().out('list')
// ['ludwig van beethoven']

    Move stuff around:

doc = nlp('a bottle of beer on the wall.')
doc.nouns().first().toPlural()
doc.out('text')
//'The bottles of beer on the wall.'
doc = nlp('ninety five thousand and fifty two')
doc.values().toNumber().out('text')
// '95052'

doc = nlp('the 23rd of December')
doc.values().add(2).toText()
doc.out('text')
// 'the twenty fifth of December'
doc = nlp("the guest-singer's björk   at seven thirty.").normalize().out('text')
// 'The guest singer is Bjork at 7:30.'
  • Tense: - switch between conjugations of any verb
let doc = nlp('she sells seashells by the seashore.')
doc.sentences().toFutureTense().out('text')
//'she will sell seashells...'

doc.verbs().conjugate()
// [{ PastTense: 'sold',
//    Infinitive: 'sell',
//    Gerund: 'selling', ...
// }]
doc = nlp("we're not gonna take it, no we ain't gonna take it.")
doc.has('going') // true
doc.match('are not').length // == 2
doc.contractions().expand().out()
//'we are not going to take it, no we are not going to take it'
doc = nlp('that opera about richard nixon visiting china')
doc.topics().data()
// [
//   { text: 'richard nixon' },
//   { text: 'china' }
// ]
var lexicon={
  'boston': 'MusicalGroup'
}
doc = nlp('i heard Boston\'s set in Chicago', lexicon)

//alternatively, fix it all 'in-post':
doc.match('heard #Possessive set').terms(1).tag('MusicalGroup')
doc = nlp('We like Roy! We like Roy!').sentences().out('array')
// ['We like Roy!', 'We like Roy!']

doc = nlp('Tony Hawk').out('html')
/*
<span>
  <span class="nl-Person nl-FirstName">Tony</span>
  <span>&nbsp;</span>
  <span class="nl-Person nl-LastName">Hawk</span>
</span>
*/

of course, there's a lot more stuff.

Join in - we're fun, using semver, and moving fast:

        Twitter        
      Slack group      
      Mailing-list      
        Projects        
      Pull-requests      

    ☂️ Isn't javascript too...

      yeah!
      it wasn't built to compete with the stanford tagger, and may not fit every project.
      string stuff is synchronous too, and parallelizing is weird.
      See here for information about speed & performance, and here> for project motivations

    💃 Can it run on my arduino-watch?

      Only if it's water-proof!
      Read quickStart for all sorts of funny environments.

    🌎 Other Languages?

      okay! we've got work-in-progress forks for German and French, in the same philosophy.
      Get involved!

    ✨ Partial builds?

      compromise can't really be tree-shaken, because it's one function.
      .. and the tagging methods are competitive, so it's not recommended to pull things out.
      It's best to load the library fully, given it's smaller than this gif.
      A plug-in scheme is in the works.


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

abazhenov avatar anastasiia-zolochevska avatar andrewwalsh avatar brandonjy avatar coreylista avatar cranesandcaff avatar creatorrr avatar davidbuhler avatar dijs avatar ericcarraway avatar fay-jai avatar gunyarakun avatar hearsid avatar ilyankou avatar johnyesberg avatar kahwee avatar khtdr avatar kiran-rao avatar leoseccia avatar ndarville avatar nloveladyallen avatar roborourke avatar sebilasse avatar silentrob avatar soyjavi avatar spencermountain avatar stevebakh avatar tsavo avatar tscheys avatar wallali avatar

Watchers

 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.