spellcheck

An async hunspell binding for node.js

npm install spellcheck
1 downloads in the last day
5 downloads in the last week
34 downloads in the last month

Description

An async hunspell binding for node.js.

Requirements

Install

npm install spellcheck

Examples

  • Check a word:

    // this example uses the en_US hunspell files from SCOWL:
    //   http://wordlist.sourceforge.net/
    var SpellCheck = require('spellcheck'),
          base = __dirname + (process.platform === 'win32' ? '\\' : '/'),
          spell = new SpellCheck(base + 'en_US.aff', base + 'en_US.dic');
    
    spell.check('sain', function(err, correct, suggestions) {
        if (err) throw err;
        if (correct)
          console.log('Word is spelled correctly!');
        else
          console.log('Word not recognized. Suggestions: ' + suggestions);
    });
    
    // output:
    // Word not recognized. Suggestions: chain,sin,saint,satin,stain,slain,swain,rain,sail,lain,said,gain,main,spin,pain
    

API

Methods

  • (constructor)(affixPath, 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(word, callback) - (void) - Spell checks the given word. The callback receives three arguments: an object in case of error (null otherwise), a indicating if the word was spelled correctly, and if the word was not recognized, an of suggested words.

npm loves you