Giter Club home page Giter Club logo

propose's Introduction

propose

Propse a word when the input word is not in the dictionary

build status

This module can be used to propse the right command in the scenario when there is a typo or mis-spell in the command line, it looks up the given dictionary and identifies the most similar word. It can also be used in any case that the string is formed by one or a series of known words, for example URL, directory path etc.

Example

var propose = require('propose');
var dictionary = ['hello', 'world'];
var word = 'hallo';
propose(word, dictionary); //hello

Options

threshold [0~1] specifies only the word with similarity equals to or higher than that value will be returned

var propose = require('propose');
var dictionary = ['aaaaaaaa', 'baabbbb', 'ccccc'];
var word = 'ab';
propose(word, dictionary, {
    threshold: 0.5
}); // null as the most similar word does not meet the threshold value

ignoreCase [true, false] specifies whether ignore case when comparing two words

var propose = require('propose');
var dictionary = ['HELLO', 'hallo'];
var word = 'hello';
propose(word, dictionary, {
    ignoreCase: true
}); //'HELLO'

Test

Make sure mocha is installed globally

npm install mocha -g

Run npm test to run unit test

Dependencies

levenshtein-edit-distance

License

MIT

propose's People

Contributors

liushuping avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.