What is typo-js?
The typo-js npm package is a JavaScript library for spell checking. It uses Hunspell dictionaries to provide spell checking functionalities, which makes it highly customizable and capable of supporting multiple languages.
What are typo-js's main functionalities?
Spell Checking
This feature allows you to check if a word is spelled correctly. In this example, the word 'example' is checked against the 'en_US' dictionary.
const Typo = require('typo-js');
const dictionary = new Typo('en_US');
const isCorrect = dictionary.check('example');
console.log(isCorrect); // true
Suggesting Corrections
This feature provides suggestions for misspelled words. In this example, the word 'exampel' is misspelled, and the dictionary suggests 'example', 'exemplar', and 'exemplary' as corrections.
const Typo = require('typo-js');
const dictionary = new Typo('en_US');
const suggestions = dictionary.suggest('exampel');
console.log(suggestions); // ['example', 'exemplar', 'exemplary']
Loading Custom Dictionaries
This feature allows you to load custom dictionaries from a specified path. In this example, the 'en_US' dictionary is loaded from a custom path.
const Typo = require('typo-js');
const dictionary = new Typo('en_US', false, false, { dictionaryPath: '/path/to/dictionaries' });
const isCorrect = dictionary.check('example');
console.log(isCorrect); // true
Other packages similar to typo-js
spellchecker
The spellchecker package provides similar spell checking functionalities but is more focused on integration with native spell checking libraries on different operating systems. It is less customizable compared to typo-js but can be easier to set up for basic spell checking needs.
nodehun
Nodehun is another package that uses Hunspell dictionaries for spell checking. It offers similar functionalities to typo-js but is written in C++ for better performance. It can be more complex to set up due to its native dependencies.
nspell
Nspell is a spell checker that also uses Hunspell dictionaries. It is written in JavaScript and offers a good balance between performance and ease of use. It provides similar functionalities to typo-js but with a different API design.
2006-02-07 release.
This dictionary is based on a subset of the original English wordlist created by Kevin Atkinson for Pspell and Aspell and thus is covered by his original LGPL license. The affix file is a heavily modified version of the original english.aff file which was released as part of Geoff Kuenning's Ispell and as such is covered by his BSD license.
Thanks to both authors for their wonderful work.