Comments (2)
I'm having the same issue...
According to the WIKI article (https://en.wikipedia.org/wiki/Levenshtein_distance) the implemented function is known to be a little inefficient.
There is a pseudocode example in the same article of a better implementation using a matrix.
I have implemented it and it returns in about 6ms with verified results.
public static int LevenshteinDistanceMatrix(this string source, string target)
{
var sourceLength = source.Length;
var targetLength = target.Length;
var matrix = new int[sourceLength + 1, targetLength + 1];
// First calculation, if one entry is empty return full length
if (sourceLength == 0)
return targetLength;
if (targetLength == 0)
return sourceLength;
// Initialization of matrix with row size sourceLength and columns size targetLength
for (var i = 0; i <= sourceLength; matrix[i, 0] = i++) { }
for (var j = 0; j <= targetLength; matrix[0, j] = j++) { }
// Calculate rows and collumns distances
for (var i = 1; i <= sourceLength; i++)
{
for (var j = 1; j <= targetLength; j++)
{
var cost = (target[j - 1] == source[i - 1]) ? 0 : 1;
matrix[i, j] = Math.Min(
Math.Min(matrix[i - 1, j] + 1, matrix[i, j - 1] + 1),
matrix[i - 1, j - 1] + cost);
}
}
// return result
return matrix[sourceLength, targetLength];
}
from fuzzystring.
levenshtien algo in this lib was taking 5+ second for me on such a 15 character string. other algorithms complete this same task in milliseconds. don't use this libs levenshtien algo...
from fuzzystring.
Related Issues (12)
- fuzzyString.dll will not run HOT 2
- Jaro Distance Issues
- Tanimoto Coefficient doesn't work properly for the equal strings.
- Wrong example code on the main project page. HOT 1
- Quick change to make this work in Unity
- Does this work for non-english alphabet?
- NuGet package
- fuzzystring is slow. Less than 1% as fast as FuzzySharp
- add LICENCE file HOT 1
- RatcliffObershelpSimilarity wrong at repeat case
- Slow Running HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fuzzystring.