NinjaNye.SearchExtensions.Levenshtein 4.0.1

dotnet add package NinjaNye.SearchExtensions.Levenshtein --version 4.0.1                
NuGet\Install-Package NinjaNye.SearchExtensions.Levenshtein -Version 4.0.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="NinjaNye.SearchExtensions.Levenshtein" Version="4.0.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add NinjaNye.SearchExtensions.Levenshtein --version 4.0.1                
#r "nuget: NinjaNye.SearchExtensions.Levenshtein, 4.0.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install NinjaNye.SearchExtensions.Levenshtein as a Cake Addin
#addin nuget:?package=NinjaNye.SearchExtensions.Levenshtein&version=4.0.1

// Install NinjaNye.SearchExtensions.Levenshtein as a Cake Tool
#tool nuget:?package=NinjaNye.SearchExtensions.Levenshtein&version=4.0.1                

SearchExtensions : Levenshtein

Library of IQueryable and IEnumerable extension methods to perform searching

This project is available for download as a nuget package

PM> Install-Package NinjaNye.SearchExtensions

Levenshtein Searching

Levenshtein search allows you to calculate the Levenshtein distance between a string property and any string value.

Methods

Levenshtein search methods are only able to be performed on IEnumerable data, meaning using this on an IQueryable data collections will evaluate the query into memory before the Levenshtein calculation is performed.

The following is a list of current and future methods that are available on IEnumerable data.

  • CompareTo - calculates the levenshtein distance between the supplied term and a given string property.

In order to perform a Levenshtein search you must first use LevenshteinDistanceOf supplying the property you wish to calculate the levenshtein distance from.

The following calculates the levenshtein distance between "test" and the StringOne property of TestModel.

context.TestModels.LevenshteinDistanceOf(x => x.StringOne)
                  .ComparedTo("test");

The levenshtein distance can also be calculated between two properties on the same model. The following snippet calculates the levenshtein distance between StringOne and StringTwo

context.TestModels.LevenshteinDistanceOf(x => x.StringOne)
                  .ComparedTo(x => x.StringTwo);

The result

The result of the above is defined as IEnumerable<ILevenshteinDistance<T>>.

In order to return the Levenshtein distance for a particular record, a new interface has been created. This interface allows us to return the result of the comparison as well as the source item itself and is defined as follows:

public interface ILevenshteinDistance<out T>
{
    int Distance { get; }
    T Item { get; }
}

This interface means that you can begin to filter out results based on the Levenshtein Distance. For example if we wanted to retrieve records where the Levenshtein Distance from "test" is less than 5 we would write the following:

var result = data.LevenshteinDistanceOf(x => x.StringOne)
                 .ComparedTo("test")
                 .Where(x => x.Distance < 5)
                 .Select(x => x.Item);

If you have any new feature requests, questions, or comments, please get in touch, either, via my website, through twitter: @ninjanye or by creating an issue through the projects github page .

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.0 is compatible.  netstandard1.1 was computed.  netstandard1.2 was computed.  netstandard1.3 was computed.  netstandard1.4 was computed.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 is compatible. 
.NET Framework net45 was computed.  net451 was computed.  net452 was computed.  net46 was computed.  net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Windows Phone wp8 was computed.  wp81 was computed.  wpa81 was computed. 
Windows Store netcore was computed.  netcore45 was computed.  netcore451 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on NinjaNye.SearchExtensions.Levenshtein:

Package Downloads
LShared.Frameworks

Package Description

RezisFramework

Package Description

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on NinjaNye.SearchExtensions.Levenshtein:

Repository Stars
DanHarltey/Fastenshtein
The fastest .Net Levenshtein around
Version Downloads Last updated
4.0.1 20,058 7/5/2024
4.0.0.3 123 7/3/2024
4.0.0.2 95 7/3/2024
4.0.0.1 96 7/3/2024
4.0.0 111 7/3/2024
3.0.1 181,725 6/17/2019
3.0.0 5,295 2/4/2019

NinjaNye.SearchExtensions.Levenshtein library.