Simple expandable tool for spell checking
- Farsi
- English
- Russian
Install:
npm i spell-checker-js
Code
const spell = require("spell-checker-js");
// Load dictionary
spell.load("en");
// Checking text
const check = spell.check("Some text to check, blahblahblah, olololo");
console.log(check);
// -> ['blahblahblah', 'olololo']
Examples:
// ways for load default dictionary:
spell.load("ru");
spell.load({ input: "ru" });
// load custom dictionary with utf-8:
spell.load("./my_custom_dictionary.txt");
// laod custom dictionary with charset:
spell.load({ input: "./my_custom_dictionary.txt", charset: "windows-1251" });
// Asynchronous load default dictionary:
spell.load({ input: "en", async: true }).then(len => {
console.log(len);
// len — amount of added words to base
spell.check("something");
});
List of default dictionaries:
en
— list of English wordsfa
— list of Farsi wordsru
— list of Russian wordsru_surnames
— list of Russian surnames
You can help by adding other languages or expand existing dictionaries
Setting: halfSpace: true dont check half Space in words
Returns: array of wrong words
Example:
spell.load("en");
const check = spell.check("Some text to check, blahblahblah, olololo");
console.log(check);
// -> ['blahblahblah', 'olololo']
Example:
spell.load("en");
spell.clear();
spell.check("something");
// -> ERROR! Dictionaries are not loaded
Example
spell.load("en");
spell.load("ru");
console.log(spell.size);
// -> 1956898
MIT © 2020 Mehdi Rezaei