Description
An async hunspell binding for node.js.
Requirements
- node.js -- v0.6.0 or newer
- Dictionary and affix files
Install
npm install spellcheck
Examples
- Check a word:
// this example uses the en_US hunspell files from SCOWL: // http://wordlist.sourceforge.net/ var SpellCheck = base = __dirname + processplatform === 'win32' ? '\\' : '/' spell = base + 'en_US.aff' base + 'en_US.dic'; spell; // output: // Word not recognized. Suggestions: chain,sin,saint,satin,stain,slain,swain,rain,sail,lain,said,gain,main,spin,pain
API
Methods
-
(constructor)(<String>affixPath, <Integer>dictPath) - Creates and returns a new SpellCheck instance. affixPath is an absolute path that points to an affix (.aff) file. dictPath is an absolute path that points to a dictionary (.dic) file.
-
check(<String>word, <Function>callback) - (void) - Spell checks the given word. The callback receives three arguments: an <Error> object in case of error (null otherwise), a <Boolean> indicating if the word was spelled correctly, and if the word was not recognized, an <Array> of suggested words.