Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
compromise
Advanced tools
npm install compromise
let r = nlp('I look just like buddy holly.')
r.sentences().toPastTense()
r.out('text')
// "I looked just like buddy holly."
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(chomskyFanFic)
r.places().sort('freq').unique().data()
/*[
{text: 'MIT lecture hall'},
{text: '23 Desperado dr.'},
{text: 'desert island'},
]*/
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="Person Noun MalePerson">Tony Hawk</span>
<span> </span>
<span class="Verb PastTense">won</span>
</span>
*/
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!)
FAQs
modest natural language processing
The npm package compromise receives a total of 41,136 weekly downloads. As such, compromise popularity was classified as popular.
We found that compromise demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new license scanner with an improved suite of features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.