Socket
Socket
Sign inDemoInstall

compromise-stats

Package Overview
Dependencies
4
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.3 to 0.1.0

49

index.d.ts
import nlp from 'compromise'
/** **/
declare const nlpNgrams: nlp.Plugin<
{
/** list all repeating sub-phrases, by word-count*/
ngrams(options?: any): any
/** n-grams with one word*/
unigrams(index?: number): any
/** n-grams with two words*/
bigrams(index?: number): any
/** n-grams with three words*/
trigrams(index?: number): any
/** n-grams including the first term of a phrase*/
startgrams(options?: any): any
/** n-grams including the last term of a phrase*/
endgrams(options?: any): any
/** n-grams including the first or last term of a phrase*/
edgegrams(options?: any): any
},
{}
>
export type Freq = [word: string, freq: number]
export default nlpNgrams
type Gram = { size: number, count: number, normal: string }
type Opts = { min: number, max: number }
export interface StatsMethods {
/** list all repeating sub-phrases, by word-count*/
ngrams(options?: Opts): Gram[]
/** n-grams with one word*/
unigrams(index?: number): Gram[]
/** n-grams with two words*/
bigrams(index?: number): Gram[]
/** n-grams with three words*/
trigrams(index?: number): Gram[]
/** n-grams including the first term of a phrase*/
startgrams(options?: Opts): Gram[]
/** n-grams including the last term of a phrase*/
endgrams(options?: Opts): Gram[]
/** n-grams including the first or last term of a phrase*/
edgegrams(options?: Opts): Gram[]
/** compute word-importance in this document */
tfidf(): Freq[]
}
/** extended compromise lib **/
declare const nlpStats: nlp.TypedPlugin<StatsMethods>
export default nlpStats
{
"name": "compromise-stats",
"description": "plugin for nlp-compromise",
"version": "0.0.3",
"version": "0.1.0",
"author": "Spencer Kelly <spencermountain@gmail.com> (http://spencermounta.in)",
"main": "./src/plugin.js",
"unpkg": "./builds/compromise-stats.min.js",
"type": "module",
"module": "./builds/compromise-stats.mjs",
"type": "module",
"types": "index.d.ts",
"sideEffects": false,

@@ -11,0 +12,0 @@ "exports": {

@@ -7,13 +7,13 @@ <div align="center">

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

@@ -64,3 +64,25 @@ </div>

all methods support the same option params:
```js
let doc = nlp('one two three. one two foo.')
doc.ngrams({ size: 2 }) // only two-word grams
/*[
{ size: 2, count: 2, normal: 'one two' },
{ size: 2, count: 1, normal: 'two three' },
{ size: 2, count: 1, normal: 'two foo' }
]
*/
```
or all gram-sizes under/over a limit:
```js
let doc = nlp('one two three. one two foo.')
let res = doc.ngrams({ min: 3 }) // or max:2
/*[
{ size: 3, count: 1, normal: 'one two three' },
{ size: 3, count: 1, normal: 'one two foo' }
]
*/
```
MIT
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc