Socket
Socket
Sign inDemoInstall

compromise

Package Overview
Dependencies
Maintainers
2
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compromise - npm Package Compare versions

Comparing version 10.4.2 to 10.5.0

5

changelog.md

@@ -32,2 +32,7 @@ `compromise` uses semver, with occasional releases to npm and bower.

- accept Terms & Result objects in .match() and .replace()
* 10.5.0
- add increment/decrement/add/subtract methods to .values()
- add units(), noUnits() methods to .values()
- 'uncountable' nouns are no longer assumed to be singular
- money tag is no longer always a value

@@ -34,0 +39,0 @@ ### v9  

27

docs/subsets/values.js

@@ -14,2 +14,7 @@ 'use strict';

},
noUnits: {
desc: 'remove \'books\' from \'12 books\'',
returns: 'Text',
example: 'nlp(\'harry potter and the 12 sequels\').values().noUnits().out()\n//\'12\''
},
toNumber: {

@@ -59,3 +64,23 @@ desc: 'turn a written number like `five thousand five hundred` into it\'s numerical form, like `5500`',

example: 'nlp(\'his 7th birthday\').values().isEqual(7).out(\'array\')\n// [\'7th\']'
}
},
add: {
desc: 'increment the current number by a given integer',
returns: 'Text',
example: 'nlp(\'his 7th birthday\').values().add(2).out()\n// \'his 9th birthday\''
},
subtract: {
desc: 'subtract the current number by a given integer',
returns: 'Text',
example: 'nlp(\'his seventh birthday\').values().subtract(2).out()\n// \'his fifth birthday\''
},
increment: {
desc: 'add one to the current number',
returns: 'Text',
example: 'nlp(\'his seventh birthday\').values().increment().out()\n// \'his eighth birthday\''
},
decrement: {
desc: 'subtract one from the current number',
returns: 'Text',
example: 'nlp(\'his 7th birthday\').values().decrement().out()\n// \'his 6th birthday\''
},
};

4

package.json

@@ -5,3 +5,3 @@ {

"description": "natural language processing in the browser",
"version": "10.4.2",
"version": "10.5.0",
"main": "./builds/compromise.js",

@@ -51,2 +51,2 @@ "repository": {

"license": "MIT"
}
}
<div align="center">
<img src="https://cloud.githubusercontent.com/assets/399657/21955696/46e882d4-da3e-11e6-94a6-720c34e27df7.jpg" />
<div>natural language processing, actually in the browser</div>
</div>
<div align="center">
<a href="https://www.codacy.com/app/spencerkelly86/nlp_compromise">

@@ -16,5 +17,3 @@ <img src="https://api.codacy.com/project/badge/grade/82cc8ebd98b64ed199d7be6021488062" />

</a>
</div>
<div align="center">
<div>natural language processing, actually in the browser</div>
<sub>

@@ -28,28 +27,12 @@ by

</div>
<br/>
<div align="center">
<sub>(formerly nlp_compromise)</sub>
</div>
```javascript
var nlp = require('compromise')
<div align="center">
inspect and play with english text.
<div>
focus on being <a href="https://github.com/nlp-compromise/compromise/wiki/Justification">handy, and not overly-fancy.</a>
</div>
</div>
<br/>
nlp('Wee-ooh, I look just like buddy holly.').sentences().toPastTense()
// 'Wee-ooh, I looked just like buddy holly.'
<div align="center">
📯 Welcome to <b>v7</b> 📯
<div>
<a href="https://github.com/nlp-compromise/compromise/wiki/v7-Upgrade,-welcome">a lot</a>
has changed!
</div>
</div>
```javascript
let r = nlp('I look just like buddy holly.')
r.sentences().toPastTense()
r.out('text')
// "I looked just like buddy holly."
nlp('..then consider me Miles Davis!').people().out('freq')
// [{ text:'Miles Davis', count:1 }]
```

@@ -63,7 +46,7 @@

<a href="https://unpkg.com/compromise@latest/builds/compromise.min.js">
200k
210k
</a>
</b>
<div>
&nbsp; one javascript file &nbsp;
&nbsp; &nbsp; one javascript file &nbsp; &nbsp;
</div>

@@ -79,3 +62,3 @@ </td>

<div>
&nbsp; on the Penn treebank &nbsp;
&nbsp; &nbsp; on the Penn treebank &nbsp; &nbsp;
</div>

@@ -98,115 +81,164 @@ </td>

</div>
<h3 align="center">
<a href="http://compromise.cool/demos">demos</a>
<span>&nbsp; | &nbsp;</span>
<a href="https://github.com/nlp-compromise/compromise/wiki/Getting-Started">quickStart</a>
<span>&nbsp; | &nbsp;</span>
<a href="http://compromise.cool/docs">docs</a>
</h3>
<br/>
<div align="center">
<b>no training, configuration, or prolog</b>
<sub>with <a href="https://github.com/nlp-compromise/compromise/wiki/Justification">deliberate, rule-based</a> nlp,</sub>
<br/>
<b>compromise</b> makes working with text easy
</div>
<br/>
the idea is, **[reach-in](https://github.com/nlp-compromise/compromise/wiki/Match-syntax)** 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,
```javascript
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
```javascript
r.sentences().toNegative()
// "JOHN is not bad. SARA doesn't sing."
```
or grab specific parts, and **analyze-the-heck** out of them:
```javascript
r = nlp(freshPrince)
r.places().sort('freq').unique().data()
/*[
{text: 'West Philadelphia'},
{text: 'Bel-Air'}
]*/
```
<table align="center">
<h6 align="center">
no jargon, &nbsp; | &nbsp; no config, &nbsp; | &nbsp; no training
</h6>
<table>
<tr>
<td>Part-of-Speech Tagging️</td>
<td>Named-Entity Recognition️</td>
<td>🍾Verb Conjugation</td>
<td>✨Inflection/Pluralization</td>
<td>
<a href="https://nlp-expo.firebaseapp.com/expo/show-all-the-nouns-760733">
Part-of-Speech tags
</a>
</td>
<td>
<sub><i>nouns, verbs, adjectives..</i></sub>
</td>
<td>
<a href="https://nlp-expo.firebaseapp.com/expo/change-sentence-tense-203483">
Verb conjugation
</a>
</td>
<td>
<sub><i>change tense of a verb or sentence</i></sub>
</td>
</tr>
<tr>
<td>
<a href="https://nlp-expo.firebaseapp.com/expo/parse-all-the-numbers-278986">
Number parsing
</a>
</td>
<td>
<sub><i>seven hundred and fifty -> 750</i></sub>
</td>
<td>
<a href="https://nlp-expo.firebaseapp.com/expo/named-entity-recognition-208197">
Named-entities
</a>
</td>
<td>
<sub><i>all the people, places, orgs..</i></sub>
</td>
</tr>
<tr>
<td>
<a href="https://nlp-expo.firebaseapp.com/expo/custom-pos-tagging-161281">
Template-matches
</a>
</td>
<td>
<sub><i>match natural-language forms</i></sub>
</td>
<td>
<a href="https://github.com/nlp-compromise/compromise/wiki/Normalization">
Text cleanup
</a>
</td>
<td>
<sub><i>contractions, hyphenation, punctuation</i></sub>
</td>
</tr>
</table>
<div align="right">
<sub><i>🙌 you can do it!</i></sub>
</div>
### Client-side:
<h3 align="center">
<a href="http://compromise.cool/docs">API docs</a>
&nbsp; | &nbsp;
<a href="http://compromise.cool/demos">Demos list</a>
</h3>
#### Client-side!
```html
<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
var doc = nlp('dinosaur')
doc.nouns().toPlural()
console.log(doc.out('text'))
// 'dinosaurs'
</script>
```
### Tense:
#### 🌋 Server-side!
```javascript
let r = nlp('she sells seashells by the seashore.')
r.sentences().toFutureTense().out('text')
//'she will sell seashells...'
var nlp = require('compromise')
r.verbs().conjugate()
// [{ PastTense: 'sold',
// Infinitive: 'sell',
// Gerund: 'selling', ...
// }]
var doc = nlp('London is calling')
doc.sentences().toNegative()
// 'London is not calling'
```
## Grab some words,
the [match() syntax](https://github.com/nlp-compromise/compromise/wiki/Match-syntax) lets you grab non-specific words or patterns:
```js
doc = nlp('Ludwig van Beethoven wrote to Josephine Brunsvik')
doc.match('#TitleCase van #LastName').out()
// 'Ludwig van Beethoven'
doc.match('#PastTense to').hyphenate().out()
// 'wrote-to'
```
common match-patterns have handy methods like `.nouns()`, or `.people()`,
```js
doc.people().out('list')
// ['ludwig van beethoven', 'josephine brunsvik']
```
### Plural/singular:
grab your noun-phrases, make em plural:
```javascript
r = nlp('a bottle of beer on the wall.')
r.nouns().first().toPlural()
r.out('text')
doc = nlp('a bottle of beer on the wall.')
doc.nouns().first().toPlural()
doc.out('text')
//'The bottles of beer on the wall.'
```
### Negation:
### Number parsing:
parse written numbers, and change their form:
```javascript
r = nlp('london is calling')
r.sentences().toNegative()
// 'london is not calling'
```
doc = nlp('ninety five thousand and fifty two')
doc.values().toNumber().out('text')
// '95052'
### Number interpretation:
```javascript
r = nlp('fifth of december')
r.values().toCardinal().out('text')
// 'five of december'
r.values().toNumber().out('text')
// '5 of december'
doc = nlp('the 23rd of December')
doc.values().toText()
doc.out('text')
// 'the twenty third of December'
```
### Normalization:
some wrappers for common changes:
```javascript
r = nlp("the guest-singer's björk at seven thirty.").normalize().out('text')
doc = nlp("the guest-singer's björk at seven thirty.").normalize().out('text')
// 'The guest singer is Bjork at 7:30.'
```
### Named-entity recognition:
### Tense:
_all your base are belong:_
```javascript
r = nlp('the opera about richard nixon visiting china')
r.topics().data()
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', ...
// }]
```
### Named-entity spotting:
find the people, places, organizations:
```javascript
doc = nlp('that opera about richard nixon visiting china')
doc.topics().data()
// [

@@ -218,11 +250,30 @@ // { text: 'richard nixon' },

### Fancy outputs:
### Error correction:
make it say what you'd like:
```javascript
r = nlp('Tony Hawk won').out('html')
var lexicon={
'boston': 'MusicalGroup'
}
doc = nlp('i heard Boston\'s set in Chicago', lexicon)
doc.match('#MusicalGroup').length
// 1
//alternatively, fix it all 'in-post':
doc.match('heard #Possessive set').terms(1).tag('MusicalGroup')
doc.match('#MusicalGroup').length
// 1
```
### Handy outputs:
get some data:
```javascript
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-Noun nl-FirstName">Tony</span>
<span class="nl-Person nl-Noun nl-LastName">Hawk</span>
<span class="nl-Person nl-FirstName">Tony</span>
<span>&nbsp;</span>
<span class="nl-Verb nl-PastTense">won</span>
<span class="nl-Person nl-LastName">Hawk</span>
</span>

@@ -234,7 +285,8 @@ */

</h3>
<h4 align="center">
<b>Join in -</b>
we're fun, we're using <b>semver</b>, and moving fast.
<a href="https://github.com/nlp-compromise/compromise/wiki/Contributing">get involved</a>
</h4>
**Join in!**
we're fun, we're using <b>semver</b>, and moving fast.
[get involved](https://github.com/nlp-compromise/compromise/wiki/Contributing)
<table>

@@ -261,2 +313,8 @@ <tr align="center">

<td>
<a href="https://github.com/nlp-compromise/nlp_compromise/wiki/Downstream-projects">
<img src="https://cloud.githubusercontent.com/assets/399657/26513481/a755ac38-4239-11e7-960a-1c26d85ddc1c.png"/>
<div>&nbsp; &nbsp; &nbsp; Applications &nbsp; &nbsp; &nbsp; </div>
</a>
</td>
<td>
<a href="https://github.com/nlp-compromise/compromise/wiki/Contributing">

@@ -277,8 +335,8 @@ <img src="https://cloud.githubusercontent.com/assets/399657/21956742/5985a89c-da55-11e6-87bc-4f0f1549d202.jpg"/>

### Don't forget about:
* **[naturalNode](https://github.com/NaturalNode/natural)** - decidedly fancier, statistical nlp in javascript, too
* **[SuperScript](http://superscriptjs.com/)** - clever conversation engine in js
* **[NodeBox Linguistics](https://www.nodebox.net/code/index.php/Linguistics)** - conjugation, inflection in javascript
* **[reText](https://github.com/wooorm/retext)** - very impressive [text utilities](https://github.com/wooorm/retext/blob/master/doc/plugins.md) in javascript
* **[jsPos](https://code.google.com/archive/p/jspos/)** - js-build of the time-tested Brill-tagger
* **[spaCy](https://spacy.io/)** - speedy, multilingual tagger in C/python
* ✨ &nbsp; **[naturalNode](https://github.com/NaturalNode/natural)** - decidedly fancier, statistical nlp in javascript
* 🍭 &nbsp; **[SuperScript](http://superscriptjs.com/)** - clever conversation engine in js
* 💗 &nbsp; **[NodeBox Linguistics](https://www.nodebox.net/code/index.php/Linguistics)** - conjugation, inflection in javascript
* 🎀 &nbsp; **[reText](https://github.com/wooorm/retext)** - very impressive [text utilities](https://github.com/wooorm/retext/blob/master/doc/plugins.md) in javascript
* 💎 &nbsp; **[jsPos](https://code.google.com/archive/p/jspos/)** - javascript build of the time-tested Brill-tagger
* 🚗 &nbsp; **[spaCy](https://spacy.io/)** - speedy, multilingual tagger in C/python

@@ -289,3 +347,3 @@ For the former promise-library, see [jnewman/compromise](https://github.com/jnewman/compromise)

<div align="right">
(also don't forget
(also don't forget 🙇
<a href="http://www.nltk.org/">NLTK</a>,

@@ -292,0 +350,0 @@ <a href="https://gate.ac.uk">GATE</a>,

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc