@planeshifter/spell-check

0.1.1 • Public • Published

NPM version Build Status Dependencies

spell-check

simple spelling checker

Introduction

The language model is constructed from the newspaper corpus of http://www.corpora.heliohost.org/, a collection of corpora for various languages freely available to download and collected by Hans Christensen. Unigram counts were extracted and stored in a sqlite database for the spell-checker.

API

spell( word [, callback] )

Given an input string consisting of a single word, the spell function returns the most probable correction according to an error and language model. If no valid correction can be found, the original argument is returned.

The function is asynchronous and either calls the callback function upon completion if the parameter is supplied or otherwise returns a Promise.

Example:

Callback Style

JavaScript:

spell("haert", function(err, res){
  console.log(res);
});
// returns: heart 

CoffeeScript:

spell("haert", (err, res) ->
  console.log res
)
# returns: heart 

Using Promises

JavaScript:

spell("lagauge").then(function(res){
  console.log(res);
});
// returns: language

CoffeeScript:

spell("langauge").then( (res) -> console.log res )
# returns: language

Unit Tests

Run tests via the command npm test


License

MIT license.

Package Sidebar

Install

npm i @planeshifter/spell-check

Weekly Downloads

2

Version

0.1.1

License

MIT

Last publish

Collaborators

  • planeshifter