Skip to content
This repository has been archived by the owner on May 8, 2019. It is now read-only.
/ wordsworth Public archive
forked from mrmarbles/wordsworth

Basic spell-checker / spelling correcter module for Nodejs.

Notifications You must be signed in to change notification settings

erelsgl-nlp/wordsworth

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wordsworth

Spell-checker / spelling correcter module for Nodejs based off of Peter Norvig's spelling corrector publication (http://norvig.com/spell-correct.html) and John Resig's instructions on string-based binary searching (http://ejohn.org/blog/revised-javascript-dictionary-search/).

Installation

 npm install wordsworth

Use

The sample /data/en_US/seed.txt and /data/en_US/training.txt files are fairly large and as such have been compressed and provided in an archive located in /data/. To run the examples, extract the contents of the archive into /en_US.

var sp = require('wordsworth').getInstance();

sp.initialize(

  '../data/en_US/seed.txt',
  '../data/en_US/training.txt', function() {

    console.log('Initialized!');

    // indicates whether or not the spell-checker knows the given word
    console.log(sp.exists('hello'));
    console.log(sp.exists('polymorphism'));

    /**
     * Accepts a single word and will return an ordered Array, most probable to
     * least probable, of suggested spelling corrections IF the given word has been
     * mis-spelled.
     */
    console.log(sp.suggest('polymrphism'));

    /**
     * Will return an Object containing keys representing any misspelled
     * words in the provided text along with an ordered Array of potential
     * spelling corrections for each key.
     */
    console.log(sp.analyze('This sentense will havv a fiw speling errorrs.'));

  }
);

license

MIT License

About

Basic spell-checker / spelling correcter module for Nodejs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%