https://github.com/gitbookio/hunspell-spellchecker
Parse and use Hunspell dictionaries in Javascript
https://github.com/gitbookio/hunspell-spellchecker
Last synced: 9 months ago
JSON representation
Parse and use Hunspell dictionaries in Javascript
- Host: GitHub
- URL: https://github.com/gitbookio/hunspell-spellchecker
- Owner: GitbookIO
- License: apache-2.0
- Created: 2015-03-14T10:06:15.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2021-07-13T13:26:35.000Z (over 4 years ago)
- Last Synced: 2025-03-30T10:06:50.861Z (10 months ago)
- Language: JavaScript
- Size: 16.6 KB
- Stars: 78
- Watchers: 4
- Forks: 17
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hunspell Spellchecker in Javascript
[](https://travis-ci.org/GitbookIO/hunspell-spellchecker)
[](http://badge.fury.io/js/hunspell-spellchecker)
A lightweight spellchecker written in Javascript, it can be used in Node.JS and in the browser. It has been build to be pre-parse Hunspell dictionary to JSON.
### Installation
```
$ npm install hunspell-spellchecker
```
### API
Initialize a spellchecker instance:
```js
var Spellchecker = require("hunspell-spellchecker");
var spellchecker = new Spellchecker();
```
Parse and serialize a dictionary
```js
// Parse an hunspell dictionary that can be serialized as JSON
var DICT = spellchecker.parse({
aff: fs.readFileSync("./en_EN.aff");
dic: fs.readFileSync("./en_EN.dic")
});
```
Load a serialized dictionary
```js
// Load a dictionary
spellchecker.use(DICT);
```
Check a word:
```js
// Check a word
var isRight = spellchecker.check("tll");
```