MyersBitParallelAlgorithm 0.1.1

The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package MyersBitParallelAlgorithm --version 0.1.1
                    
NuGet\Install-Package MyersBitParallelAlgorithm -Version 0.1.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="MyersBitParallelAlgorithm" Version="0.1.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MyersBitParallelAlgorithm" Version="0.1.1" />
                    
Directory.Packages.props
<PackageReference Include="MyersBitParallelAlgorithm" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MyersBitParallelAlgorithm --version 0.1.1
                    
#r "nuget: MyersBitParallelAlgorithm, 0.1.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.
#:package MyersBitParallelAlgorithm@0.1.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MyersBitParallelAlgorithm&version=0.1.1
                    
Install as a Cake Addin
#tool nuget:?package=MyersBitParallelAlgorithm&version=0.1.1
                    
Install as a Cake Tool

MyersBitParallelAlgorithm

A small, dependency-free .NET 8, .NET 9, and .NET 10 library for repeatedly calculating the exact Levenshtein distance from one prepared search term to many candidate strings.

Source code on GitHub

The matcher uses the single-word form of Gene Myers's bit-vector algorithm, so the search term is limited to 64 UTF-16 code units. Candidate strings are not length-limited.

Install

dotnet add package MyersBitParallelAlgorithm --version 0.1.1

Use

using MyersBitParallelAlgorithm;

string term = TextNormalizer.ToLowerInvariantAndTrim("  Jose  ");
var matcher = MyersMatcher.ForUtf16(term);

foreach (string patientName in patientNames)
{
    string candidate = TextNormalizer.ToLowerInvariantAndTrim(patientName);
    int distance = matcher.Distance(candidate);
    // Rank or filter in the application.
}

Use MyersMatcher.ForAscii when both the search term and every candidate are guaranteed to contain only ASCII characters. It rejects non-ASCII input rather than silently changing comparison semantics. Use ForUtf16 for general .NET text.

Matchers are immutable and safe to reuse concurrently. Preparing a matcher allocates its character-mask lookup once; calls to Distance do not allocate.

Comparison semantics

  • Distance is the number of unit-cost insertions, deletions, and substitutions.
  • Matching is ordinal and case-sensitive.
  • UTF-16 code units are compared. A supplementary Unicode character, such as most emoji, therefore occupies two positions.
  • An empty search term is supported.
  • A search term longer than 64 code units is rejected.

Normalization is deliberately optional. TextNormalizer.RemoveDiacritics removes Unicode combining marks and is lossy. ToLowerInvariantAndTrim performs invariant lowercasing and trims only leading and trailing whitespace. Apply the same normalization to both the search term and candidates. Name-handling rules are domain decisions; this library does not remove punctuation, collapse internal whitespace, transliterate scripts, or apply culture-specific casing.

Scope

This package computes full-string distance from one prepared term. It does not provide substring search, thresholds, similarity ratios, result ranking, custom character mapping, or patterns longer than 64 code units.

Benchmarks

The benchmark console app uses Bogus to generate deterministic fake patient names, normalizes one shared ASCII dataset, and uses BenchmarkDotNet to compare the following NuGet packages:

  • MyersBitParallelAlgorithm (this project)
  • FastBatchLevenshtein 1.0.0
  • FuzzySharp 2.0.2 (currently commented out)
  • MyersBitParallel 0.2.4

Each benchmark materializes every matching candidate ID into a preallocated result buffer and runs two independent threshold scenarios: edit distance at most three, and normalized similarity of at least 60%. FastBatchLevenshtein uses its native batch-search operation; the other libraries scan the same candidate array and apply the equivalent threshold. Each invocation searches 16 names back-to-back, sampled deterministically from the candidates: 12 two-part names and 4 three-part names. Setup verifies that all implementations return the same query-and-candidate match set before measurement. Fake-data generation, normalization, engine construction, and prepared-pattern creation are outside the timed methods.

Each active implementation also has a parallel benchmark that searches all 16 prepared queries concurrently. Each query uses an isolated preallocated result buffer or slice, and setup verifies every complete match set against the sequential baseline.

For the edit-distance threshold, this library's benchmark first rejects names whose length difference is greater than three. ExactDistanceBenchmarks separately compares exact, unbounded distance calculations without threshold shortcuts.

Run it in Release configuration:

dotnet run --project benchmarks/MyersBitParallelAlgorithm.Benchmarks -c Release

Use BenchmarkDotNet command-line arguments to filter or adjust a run, for example --filter *FuzzySharp*. Benchmark results are written under BenchmarkDotNet.Artifacts/.

The benchmark project references the AGPL-3.0-licensed MyersBitParallel package. It is isolated from the runtime library and is not included in the MyersBitParallelAlgorithm NuGet package. Distribution of the compiled benchmark application must comply with that dependency's license.

Algorithm and license

The implementation is based on the algorithm described in:

Gene Myers, "A Fast Bit-Vector Algorithm for Approximate String Matching Based on Dynamic Programming," Journal of the ACM 46(3), 1999. https://doi.org/10.1145/316542.316550

The project is available under the MIT License. CureMD should approve the copyright and employment-IP wording before public publication.

Product Compatible and additional computed target framework versions.
.NET 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.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.
  • net8.0

    • No dependencies.
  • net9.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated