Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

n-gram

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n-gram - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

History.md

16

index.js

@@ -17,3 +17,2 @@ 'use strict';

*/
function nGram(n) {

@@ -31,3 +30,3 @@ if (

/**
/*
* Create n-grams from a given value.

@@ -44,5 +43,7 @@ *

return function (value) {
var nGrams = [],
var nGrams,
index;
nGrams = [];
if (value === null || value === undefined) {

@@ -53,6 +54,7 @@ return nGrams;

value = String(value);
index = value.length - n + 1;
if (index < 1) {
return [];
return nGrams;
}

@@ -68,3 +70,3 @@

/**
/*
* Export `n-gram`.

@@ -75,3 +77,3 @@ */

/**
/*
* Create bigrams from a given value.

@@ -89,3 +91,3 @@ *

/**
/*
* Create trigrams from a given value.

@@ -92,0 +94,0 @@ *

{
"name": "n-gram",
"version": "0.1.1",
"version": "0.1.2",
"description": "Get n-grams from text",

@@ -22,21 +22,30 @@ "license": "MIT",

"devDependencies": {
"eslint": "^0.9.0",
"browserify": "^8.0.0",
"eslint": "^0.12.0",
"esmangle": "^1.0.0",
"istanbul": "^0.3.0",
"jscs": "^1.0.0",
"matcha": "^0.5.0",
"mocha": "^2.0.0"
"jscs-jsdoc": "^0.4.0",
"matcha": "^0.6.0",
"mocha": "^2.0.0",
"ngram": "madbence/node-ngram"
},
"scripts": {
"install-benchmark": "npm install ngram && git clone git@github.com:madbence/node-ngram.git node_modules/madbence-ngram",
"benchmark": "node_modules/.bin/matcha benchmark.js",
"test": "node_modules/.bin/_mocha --reporter spec --check-leaks -u exports test.js",
"test-travis": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha --report lcovonly -- --reporter spec --check-leaks -u exports test.js",
"coverage": "node_modules/.bin/istanbul cover node_modules/.bin/_mocha -- -- test.js",
"test-api": "_mocha --check-leaks test.js",
"test-coveralls": "istanbul cover _mocha --report lcovonly -- --check-leaks test.js",
"test-coverage": "istanbul cover _mocha -- test.js",
"test-travis": "npm run test-coveralls",
"test": "npm run test-api",
"lint-api": "eslint index.js",
"lint-test": "eslint --env mocha test.js",
"lint-benchmark": "eslint --global set,suite,bench benchmark.js",
"lint-style": "jscs --reporter inline index.js test.js benchmark.js",
"lint": "npm run lint-api && npm run lint-test && npm run lint-benchmark && npm run lint-style",
"lint-api": "node_modules/.bin/eslint index.js",
"lint-test": "node_modules/.bin/eslint test.js --env mocha",
"lint-benchmark": "node_modules/.bin/eslint benchmark.js --global set,suite,bench",
"lint-style": "node_modules/.bin/jscs index.js test.js benchmark.js --reporter=inline",
"make": "npm run lint && npm run coverage"
"make": "npm run lint && npm run test-coverage",
"benchmark": "matcha benchmark.js",
"bundle": "browserify index.js -s nGram > n-gram.js",
"postbundle": "esmangle n-gram.js > n-gram.min.js",
"build": "npm run bundle",
"prepublish": "npm run build"
}
}

@@ -7,20 +7,38 @@ # n-gram [![Build Status](https://img.shields.io/travis/wooorm/n-gram.svg?style=flat)](https://travis-ci.org/wooorm/n-gram) [![Coverage Status](https://img.shields.io/coveralls/wooorm/n-gram.svg?style=flat)](https://coveralls.io/r/wooorm/n-gram?branch=master)

npm:
```sh
[npm](https://docs.npmjs.com/cli/install):
```bash
$ npm install n-gram
```
Component:
```sh
[Component.js](https://github.com/componentjs/component):
```bash
$ component install wooorm/n-gram
```
Bower:
```sh
[Bower](http://bower.io/#install-packages):
```bash
$ bower install n-gram
```
[Duo](http://duojs.org/#getting-started):
```javascript
var nGram = require('wooorm/n-gram');
```
UMD (globals/AMD/CommonJS) ([uncompressed](n-gram.js) and [compressed](n-gram.min.js)):
```html
<script src="path/to/n-gram.js"></script>
<script>
nGram.bigram('n-gram'); // ['n-', '-g', 'gr', 'ra', 'am']
</script>
```
## Usage
```js
```javascript
var nGram = require('n-gram');

@@ -55,34 +73,20 @@

```sh
$ npm run install-benchmark # Just once of course.
$ npm run benchmark
```
On a MacBook Air, it runs about 583,367 op/s on a sentence.
On a MacBook Air, it runs about 506,112 op/s on a ssentence.
```
```text
nGram -- this module
584,668 op/s » bigrams on a sentence
4,607 op/s » bigrams on an article
566,130 op/s » trigrams on a sentence
4,558 op/s » trigrams on an article
498,405 op/s » ten-grams on a sentence
4,085 op/s » ten-grams on an article
583,367 op/s » bigrams on a sentence
4,250 op/s » bigrams on an article
566,931 op/s » trigrams on a sentence
4,204 op/s » trigrams on an article
542,756 op/s » ten-grams on a sentence
3,597 op/s » ten-grams on an article
madbence/ngram
489,280 op/s » bigrams on a sentence
8,747 op/s » bigrams on an article
487,999 op/s » trigrams on a sentence
8,901 op/s » trigrams on an article
533,071 op/s » ten-grams on a sentence
7,788 op/s » ten-grams on an article
ngram
359,137 op/s » bigrams on a sentence
5,634 op/s » bigrams on an article
365,814 op/s » trigrams on a sentence
5,186 op/s » trigrams on an article
367,451 op/s » ten-grams on a sentence
4,781 op/s » ten-grams on an article
538,421 op/s » bigrams on a sentence
9,842 op/s » bigrams on an article
525,198 op/s » trigrams on a sentence
9,253 op/s » trigrams on an article
539,926 op/s » ten-grams on a sentence
6,403 op/s » ten-grams on an article
```

@@ -92,2 +96,2 @@

MIT © Titus Wormer
[MIT](LICENSE) © [Titus Wormer](http://wooorm.com)

Sorry, the diff of this file is not supported yet

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