0.1.9 • Published 6 years ago
spell-checker-blueheart v0.1.9
A simple spell checker - *do not use in production!
import { Trie } from "spell-checker-blueheart";
const trie = Trie.new();
async function loadDict(file) {
  const dict = await  fetch(file)
    .then(t => t.text()).then(t => trie.load(t));
}
loadDict("checker.txt").then(t =>
  {
    console.log(trie.search("memory"));
    console.log(trie.search("dog"));
    console.log(trie.search("resolution"));
    let result = "the foz/jumps\\the-killer!train and ctches fyre".split(/[^\w']+/);
    result = new Set(result);
    result = [...result].filter(w => !trie.search(w));
    console.log(result);
});