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

ngrammer

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ngrammer

Frequency analysis for javascript code

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
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

Package last updated on 07 Jun 2016

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc