Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mscdex/spellcheck
An async hunspell binding for node.js
https://github.com/mscdex/spellcheck
Last synced: 2 months ago
JSON representation
An async hunspell binding for node.js
- Host: GitHub
- URL: https://github.com/mscdex/spellcheck
- Owner: mscdex
- License: mit
- Created: 2012-05-06T10:38:16.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2015-04-23T03:44:13.000Z (over 9 years ago)
- Last Synced: 2024-10-14T12:07:32.243Z (3 months ago)
- Language: C++
- Size: 436 KB
- Stars: 82
- Watchers: 5
- Forks: 10
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Description
===========An async hunspell binding for [node.js](http://nodejs.org/).
Requirements
============* [node.js](http://nodejs.org/) -- v0.6.0 or newer
* [Dictionary and affix files](http://wiki.services.openoffice.org/wiki/Dictionaries)Install
============npm install spellcheck
Examples
========* Check a word:
```javascript
// 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.