Latest commit 75c7385 Sep 7, 2017 @spencermountain spencermountain committed on GitHub Create LICENSE
Failed to load latest commit information.
builds 10.7.2 Aug 22, 2017
demo new debug mode for clientside Apr 13, 2017
docs noUnits method May 27, 2017
scripts 10.7.2 Aug 22, 2017
src move compressed data Jul 23, 2017
test 10.7.1 Jul 23, 2017
.esformatter move tests around Feb 3, 2017
.eslintrc 10 tests failing Jul 5, 2017
.gitignore v10.5.1 Jun 7, 2017
.npmignore cleanup scripts folder Feb 21, 2017
.travis.yml test build and src in travis now Jun 7, 2017
LICENSE Create LICENSE Sep 7, 2017 yolo Jul 6, 2017 10.7.2 Aug 22, 2017
compromise.d.ts init typefile May 1, 2017
package.json 10.7.2 Aug 22, 2017
scratch.js cleanup lex Jul 23, 2017

natural language processing, actually in the browser
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 }]
        one javascript file        
    on the Penn treebank    
    npm install compromise    
      caniuse, youbetcha      
with deliberate, rule-based nlp,
compromise makes working with text easy
no jargon,   |   no config,   |   no training       🙌 you can do it!

API doc       Demos       QuickStart       Tutorials

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

⚡️ Client-side!

<script src=""></script>
  var doc = nlp('dinosaur')

  var str = doc.nouns().toPlural().out('text')
  // 'dinosaurs'

🌋 Server-side!

var nlp = require('compromise')

var doc = nlp('London is calling')
// 'London is not calling'

Toss in text,

even if it's just one word:

doc = nlp('Ludwig van Beethoven wrote to Josephine Brunsvik')

// ['ludwig van beethoven', 'josephine brunsvik']

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

doc.match('#PastTense to').hyphenate().out()
// 'wrote-to'

    Throw stuff around:

doc = nlp('a bottle of beer on the wall.')
//'The bottles of beer on the wall.'
doc = nlp('ninety five thousand and fifty two')
// '95052'

doc = nlp('the 23rd of December')
// '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.')
//'she will sell seashells...'

// [{ PastTense: 'sold',
//    Infinitive: 'sell',
//    Gerund: 'selling', ...
// }]
doc = nlp('that opera about richard nixon visiting china')
// [
//   { text: 'richard nixon' },
//   { text: 'china' }
// ]
var lexicon={
  'boston': 'MusicalGroup'
doc = nlp('i heard Boston\'s set in Chicago', lexicon)
// 1

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

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

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

Join in - we're fun, using semver, and moving fast. get involved

      Slack group      

    🌎 Other Languages?

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

    ☂️ Isn't javascript too...

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

    💃 Can it run on my arduino-watch?

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

    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 )