Socket
Socket
Sign inDemoInstall

ngrammer

Package Overview
Dependencies
6
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngrammer

Frequency analysis for javascript code


Version published
Weekly downloads
0
Maintainers
1
Install size
693 kB
Created
Weekly downloads
 

Readme

Source

ngrammer

Build Status

Perform frequency analysis on a js code string

Uses nlp-compromise with nlp-ngram

Installation

node.js

Install using npm:

$ npm install ngrammer

Examples

Node.JS

const ngrammer = require('ngrammer');
const fs = require('fs');
const fileContents = fs.readFileSync('./testfile.js').toString();

/*
  options:
  - minCount: minimum gram frequency, default: 10
  - maxSize: max gram count, default: 3
*/
const ngram = ngrammer(fileContents, { minCount: 10, maxSize: 3 })
/*
  [
    [
      { word: 'someword', count: 100, size: 1 },
      { word: 'another', count: 90, size: 1 },
      { word: 'etc', count: 80, size: 1 },
      ...
    ],
    [
      { word: 'two words', count: 30, size: 2 },
      { word: 'some more', count: 20, size: 2 },
      { word: 'etc etc', count: 10, size: 2 },
      ...
    ],
    ...
  ]
*/

Testing

To run the tests:

$ npm test

Contributing

Feel free to create a pull request.

License

MIT - see LICENSE

Keywords

FAQs

Last updated on 07 Jun 2016

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.

Install

Related posts

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