Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An async hunspell binding for node.js

branch: master
README.md

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)(<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.

Something went wrong with that request. Please try again.