Skip to content

Commit

Permalink
Update dependency for calculate the edit distance
Browse files Browse the repository at this point in the history
  • Loading branch information
jfmdev committed Nov 2, 2019
1 parent 4a597d6 commit 197bee5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// Load dependencies.
const BinarySearch = require('binarysearch');
const EditDistance = require('damerau-levenshtein')();
const Levenshtien = require('damerau-levenshtein');

// Use this object for consider accents and special characters when comparing UTF-8 strings.
var Collator = new Intl.Collator(undefined, {'sensitivity': 'accent'});
Expand Down Expand Up @@ -106,7 +106,7 @@ Dictionary.prototype.getSuggestions = function(word, limit, maxDistance) {
// The index 'k' is going to be 0, 1, -1, 2, -2...
k = closest + (i%2 != 0? ((i+1)/2) : (-i/2) );
if(k >=0 && k < this.wordlist.length) {
dist = EditDistance(word, this.wordlist[k].toLowerCase());
dist = Levenshtien(word, this.wordlist[k].toLowerCase()).steps;
if(dist <= maxDistance) res[dist].push(this.wordlist[k]);
}
}
Expand Down
7 changes: 4 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "simple-spellchecker",
"version": "0.9.9",
"version": "1.0.0",
"description": "A simple spellchecker compatible with Electron",
"main": "index.js",
"scripts": {
Expand All @@ -27,7 +27,7 @@
"dependencies": {
"adm-zip": "^0.4.13",
"binarysearch": "^0.2.4",
"damerau-levenshtein": "git://github.com/cbaatz/damerau-levenshtein.git",
"damerau-levenshtein": "^1.0.5",
"strip-bom": "^2.0.0",
"tmp": "^0.1.0"
},
Expand Down

0 comments on commit 197bee5

Please sign in to comment.