GithubHelp home page GithubHelp logo

difficulty's Introduction

Evaluating English word difficulty using word frequency data

Installation

cd ~/my-project/
npm install difficulty --save

Basic Usage

Async/Await

Welcome to ES7! ⎝( OωO)⎠

import { create } from 'difficulty';

(async () => {
  try {
    const difficulty = await create();
    const a = difficulty.getLevel('apple');
    const b = difficulty.getLevel('cappuccino');

    console.log(`apple is level ${a}, easy!`);
    console.log(`cappuccino is level ${b}, too hard!`);
  } catch(err) {
    console.error(err);
  }
})();

Output

apple is level 0, easy!
cappuccino is level 3, so hard!

Old schooler?

const Difficulty = require('difficulty');

// Using Promise
Difficulty.create().then((difficulty) => {
  ...
});

// Sync is available too!
const difficulty = Difficulty.createSync();

API

Difficulty.create(options)

filepath

Path to your csv file, in following format.

"Word","Freq_HAL"
"a","10610626"
...

Default: ./node_modules/difficulty/wordlist/wordlist.csv

levelsThreshold

Define your own levels with frequency threshold in descending order.

Default: [20000, 10000, 5000]

- Level 0: freq > 20000
- Level 1: 10001 to 20000
- Level 2: 5001 to 10000
- Level 3: < 5000 or **non exist words**

License

ISC

Important

The default word frequency data is generated from English Lexicon Project, which is for non-commercial research purposes only and may not be used in the development of speech technology. You should consider using your own wordlist for other purpose.

Author

github/auphone

Good luck! σ`∀´)σ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.