# compromise-ngrams

> plugin for nlp-compromise

Latest version **0.0.6** (published 2020-12-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install compromise-ngrams
pnpm add compromise-ngrams
yarn add compromise-ngrams
bun add compromise-ngrams
```

## Health

**Score 50/100 (C)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score; popular repo.

Warnings: low downloads; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.6 |
| Published | 2020-12-18 |
| First published | 2019-11-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 35.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 12159 |
| Author | Spencer Kelly |
| Maintainers | spencermountain |

## Links

- npm: https://www.npmjs.com/package/compromise-ngrams
- Repository: https://github.com/spencermountain/compromise
- Homepage: https://github.com/spencermountain/compromise#readme
- Issues: https://github.com/spencermountain/compromise/issues
- npm.io page: https://npm.io/package/compromise-ngrams

## Recent versions

- 0.0.6 (latest) — 2020-12-18
- 0.0.5 — 2020-02-01
- 0.0.4 — 2020-01-11
- 0.0.3 — 2019-11-28
- 0.0.2 — 2019-11-22
- 0.0.1 — 2019-11-22

## README

<div align="center">
  <img src="https://cloud.githubusercontent.com/assets/399657/23590290/ede73772-01aa-11e7-8915-181ef21027bc.png" />

  <div>a plugin for <a href="https://github.com/spencermountain/compromise/">compromise</a></div>
  
  <!-- npm version -->
  <a href="https://npmjs.org/package/compromise-ngrams">
    <img src="https://img.shields.io/npm/v/compromise-ngrams.svg?style=flat-square" />
  </a>
  
  <!-- file size -->
  <a href="https://unpkg.com/compromise-ngrams/builds/compromise-ngrams.min.js">
    <img src="https://badge-size.herokuapp.com/spencermountain/compromise/master/plugins/ngrams/builds/compromise-ngrams.min.js" />
  </a>
   <hr/>
</div>

<div align="center">
  <code>npm install compromise-ngrams</code>
</div>

```js
const nlp = require('compromise')
nlp.extend(require('compromise-ngrams'))

let doc = nlp(`bake 'em away, toys`)
doc.bigrams().data()
//[{normal:'bake em', size:2, count:1}, {normal:'em away', size:2, count:1}, {normal:'em toys', size:2, count:1}]

//same for:
doc.unigrams()
doc.trigrams()
doc.ngrams({ size: 3 })
```

### [Demo](https://observablehq.com/@spencermountain/compromise-ngram)

### API:

- **.ngrams({})** - list all repeating sub-phrases, by word-count
- **.unigrams(n)** - n-grams with one word
- **.bigrams(n)** - n-grams with two words
- **.trigrams(n)** - n-grams with three words
- **.startgrams({})** - n-grams including the first term of a phrase
- **.endgrams({})** - n-grams including the last term of a phrase
- **.edgegrams({})** - n-grams including the first or last term of a phrase

MIT

---
_Source: https://npm.io/package/compromise-ngrams · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
