Norvig inspired spellchecker and autocorrect implementation in javascript