The fastest .Net Levenshtein around.
I got tired of seeing slow Levenshtein implementations, think of the CPU cycles we could be saving! You owe it to your end user to use this.
Under the MIT license also available as NuGet package.
Find this useful? Let me know to make me happy.
int levenshteinDistance = Fastenshtein.Levenshtein.Distance("value1", "value2");
Alternative method for comparing one item against many (quicker due to less memory allocation)
Fastenshtein.Levenshtein lev = new Fastenshtein.Levenshtein("value1");
foreach (var item in new []{ "value2", "value3", "value4"})
{
int levenshteinDistance = lev.Distance(item);
}
If you are crazy enough to want to do this. Place the Fastenshtein.dll on the SQL Servers hard drive and do the following…
CREATE ASSEMBLY Fastenshtein from 'C:\Program Files\Microsoft SQL Server\MSSQL11.DEV\MSSQL\Binn\Fastenshtein.dll' WITH PERMISSION_SET = SAFE
CREATE FUNCTION [dbo].[Levenshtein](@s [nvarchar](4000), @t [nvarchar](4000))
RETURNS [int] WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [Fastenshtein].[Fastenshtein.Levenshtein].[Distance]
GO
-- Usage
DECLARE @retVal as integer
select @retVal = [dbo].[Levenshtein]('Test','test')
Select @retVal