Skip to content

dongyuwei/SymSpell

 
 

Repository files navigation

Forked from Isaac Sukin's SymSpell, the code can run on nodejs now, to support chinese words, you need to write a custom tokenizer, see demo:

run npm install symspell first. demo:

#! /usr/local/bin/node
var assert = require('assert');
var SpellChecker = require('symspell');

function tokenizer(words){
    return words.toLowerCase().split(' ');
}

var maxEditDistance = 4;

var corrector = new SpellChecker(maxEditDistance);

corrector.addWords('adapt adept adopt appraise apprise 暴露 毕恭毕敬', null, tokenizer);

console.log(corrector.lookup('adept'));
console.log(corrector.lookup('apprese'));

assert.equal(corrector.lookup('adept').length, 3);

console.log(corrector.lookup('曝露'));
console.log(corrector.lookup('必恭必敬'));

assert.equal(corrector.lookup('曝露')[0].term, '暴露')
assert.equal(corrector.lookup('必恭必敬')[0].distance, 2)

An implementation of the Symmetric Delete spelling correction algorithm. It is fast and language-independent, but there is some setup cost to construct the dictionary.

Currently the results are not as accurate as expected; there are probably some bugs in the port.

Based on C# code and algorithm version 1.6, originally written by Wolf Garbe.

License: LGPL 3.0

About

A JavaScript implementation of the Symmetric Delete spelling correction algorithm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 77.9%
  • HTML 22.1%