Raffinert.FuzzySharp 7.0.0

dotnet add package Raffinert.FuzzySharp --version 7.0.0
                    
NuGet\Install-Package Raffinert.FuzzySharp -Version 7.0.0
                    
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="Raffinert.FuzzySharp" Version="7.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Raffinert.FuzzySharp" Version="7.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Raffinert.FuzzySharp" />
                    
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 Raffinert.FuzzySharp --version 7.0.0
                    
#r "nuget: Raffinert.FuzzySharp, 7.0.0"
                    
#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 Raffinert.FuzzySharp@7.0.0
                    
#: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=Raffinert.FuzzySharp&version=7.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Raffinert.FuzzySharp&version=7.0.0
                    
Install as a Cake Tool

Stand With Ukraine

Terms of use<sup>?</sup>

By using this project or its source code, for any purpose and in any shape or form, you grant your implicit agreement to all the following statements:

  • You condemn Russia and its military aggression against Ukraine
  • You recognize that Russia is an occupant that unlawfully invaded a sovereign state
  • You support Ukraine's territorial integrity, including its claims over temporarily occupied territories of Crimea and Donbas
  • You reject false narratives perpetuated by Russian state propaganda

To learn more about the war and how you can help, click here. Glory to Ukraine! πŸ‡ΊπŸ‡¦

Raffinert.FuzzySharp

nuget version nuget downloads

Raffinert.FuzzySharp is a high-performance .NET fuzzy string matching library inspired by SeatGeek's FuzzyWuzzy and RapidFuzz.

It is a bit-parallel accelerated version of the original FuzzySharp, with multiple fixes to the partial_ratio implementation, lower-level distance APIs, cached scorers, and reusable extraction pipelines.

Overview

Use Raffinert.FuzzySharp when you need to:

  • Score two strings for similarity.
  • Find the best match in a list of choices.
  • Match strings while ignoring word order, duplicate words, case, punctuation, or abbreviations.
  • Reuse cached scorers for one-to-many comparisons.
  • Run extraction pipelines sequentially or in parallel.
  • Access fast Levenshtein, Indel, and Longest Common Subsequence distance APIs directly, plus OSA, Damerau-Levenshtein, Jaro, Jaro-Winkler, Hamming, Prefix and Postfix.

Contents

Installation

Install-Package Raffinert.FuzzySharp

or

dotnet add package Raffinert.FuzzySharp

Compatibility

Raffinert.FuzzySharp targets:

  • .NET Standard 2.0 and 2.1
  • .NET Framework 4.5, 4.6, 4.6.2, 4.7.2, and 4.8
  • .NET Core 3.1
  • .NET 6, .NET 8, .NET 9, and .NET 10

Quick Start

Find the best match from a list of choices:

var choices = new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" };

var result = Process.ExtractOne("cowboys", choices);
// (string: Dallas Cowboys, score: 90, index: 3)

Compare two strings directly:

Fuzz.Ratio("mysmilarstring", "mysimilarstring");
// 96.55172413793103

Fuzz.WeightedRatio(
    "The quick brown fox jimps ofver the small lazy dog",
    "the quick brown fox jumps over the small lazy dog");
// 94.94949494949495

Similarity scores are double values in the range 0–100.

By default, Fuzz methods compare strings as-is. Process extraction methods use StringPreprocessor.Full by default, which normalizes whitespace, lowercases, and strips non-alphanumeric characters.

Choosing a Scorer

Scorer Use when
Fuzz.Ratio You need direct similarity between two strings.
Fuzz.PartialRatio One string may be a substring or close substring of the other.
Fuzz.TokenSortRatio Word order should not matter.
Fuzz.TokenSetRatio Duplicate words or extra common words should have less impact.
Fuzz.TokenInitialismRatio You need to compare an initialism with its expanded phrase.
Fuzz.TokenAbbreviationRatio You need abbreviation-aware matching.
Fuzz.WeightedRatio You want a general-purpose scorer that combines several strategies.
Process.ExtractOne / ExtractTop / ExtractAll You need to search a collection of choices.
Process.Configure() You want reusable extraction with caching, custom scorers, or parallel execution.

Ratio Examples

Simple Ratios

<p align="right"><a href="https://dotnetfiddle.net/9JpFTQ">Run .NET fiddle</a></p>

Fuzz.Ratio("mysmilarstring", "myawfullysimilarstirng");
// 72.22222222222221
Fuzz.Ratio("mysmilarstring", "mysimilarstring");
// 96.55172413793103

Partial Ratio

<p align="right"><a href="https://dotnetfiddle.net/rk0dIO">Run .NET fiddle</a></p>

Fuzz.PartialRatio("similar", "somewhresimlrbetweenthisstring");
// 71.42857142857143

Token Sort Ratio

<p align="right"><a href="https://dotnetfiddle.net/b5RVp2">Run .NET fiddle</a></p>

Fuzz.TokenSortRatio("order words out of", "  words out of order");
// 100
Fuzz.PartialTokenSortRatio("order words out of", "  words out of order");
// 100

Token Set Ratio

<p align="right"><a href="https://dotnetfiddle.net/ZfZRGb">Run .NET fiddle</a></p>

Fuzz.TokenSetRatio("fuzzy was a bear", "fuzzy fuzzy fuzzy bear");
// 100
Fuzz.PartialTokenSetRatio("fuzzy was a bear", "fuzzy fuzzy fuzzy bear");
// 100

Token Initialism Ratio

<p align="right"><a href="https://dotnetfiddle.net/87181A">Run .NET fiddle</a></p>

Fuzz.TokenInitialismRatio("NASA", "National Aeronautics and Space Administration");
// 88.88888888888889
Fuzz.TokenInitialismRatio("NASA", "National Aeronautics Space Administration");
// 100

Fuzz.TokenInitialismRatio("NASA", "National Aeronautics Space Administration, Kennedy Space Center, Cape Canaveral, Florida 32899");
// 53.333333333333336
Fuzz.PartialTokenInitialismRatio("NASA", "National Aeronautics Space Administration, Kennedy Space Center, Cape Canaveral, Florida 32899");
// 100

Token Abbreviation Ratio

<p align="right"><a href="https://dotnetfiddle.net/MVlwrW">Run .NET fiddle</a></p>

Fuzz.TokenAbbreviationRatio("bl 420", "Baseline section 420", StringPreprocessor.Full);
// 40
Fuzz.PartialTokenAbbreviationRatio("bl 420", "Baseline section 420", StringPreprocessor.Full);
// 66.66666666666667

Weighted Ratio

<p align="right"><a href="https://dotnetfiddle.net/n9QxAk">Run .NET fiddle</a></p>

Fuzz.WeightedRatio("The quick brown fox jimps ofver the small lazy dog", "the quick brown fox jumps over the small lazy dog");
// 94.94949494949495

WeightedRatio intentionally retains its legacy full TokenSortRatio/TokenSetRatio partial branch for compatibility.

Process Extraction

Find the best match(es) from a collection of choices.

<p align="right"><a href="https://dotnetfiddle.net/8lEzk3">Run .NET fiddle</a></p>

Process.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" });
// (string: Dallas Cowboys, score: 90, index: 3)
Process.ExtractTop("goolge", new[] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" }, limit: 3);
// [(string: google, score: 83.33333333333334, index: 0), (string: googleplus, score: 75.00000000000001, index: 5), (string: plexoogl, score: 42.85714285714286, index: 7)]
Process.ExtractAll("goolge", new[] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" });
// [(string: google, score: 83.33333333333334, index: 0), (string: bing, score: 36, index: 1), ...]

// With score cutoff
Process.ExtractAll("goolge", new[] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" }, cutoff: 40);
// [(string: google, score: 83.33333333333334, index: 0), (string: googleplus, score: 75.00000000000001, index: 5), (string: plexoogl, score: 42.85714285714286, index: 7)]
Process.ExtractSorted("goolge", new[] { "google", "bing", "facebook", "linkedin", "twitter", "googleplus", "bingnews", "plexoogl" });
// [(string: google, score: 83.33333333333334, index: 0), (string: googleplus, score: 75.00000000000001, index: 5), (string: plexoogl, score: 42.85714285714286, index: 7), ...]

Extraction uses WeightedRatio and Full preprocessing by default. Override these in the method parameters to use different scorers and processing:

Process.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" }, s => s, ScorerCache.Get<DefaultRatioScorer>());
// (string: Dallas Cowboys, score: 57.14285714285714, index: 3)

All-Pairs Scoring (Cdist)

Process.Cdist scores every query against every choice and returns a double[queries, choices] matrix, like RapidFuzz's cdist. With DefaultRatioScorer on .NET 8+, short queries are packed into SIMD lanes and scored together.

string[] queries = { "new york mets", "chicago cubs" };
string[] choices = { "New York Yankees", "Chicago Cubs", "New York Mets" };

// Defaults as in RapidFuzz: simple ratio, no preprocessing.
double[,] scores = Process.Cdist(queries, choices, processor: StringPreprocessor.Full, maxDegreeOfParallelism: -1);
// scores[0, 2] == 100: "new york mets" vs "New York Mets" after full preprocessing

Generic Type Extraction

<p align="right"><a href="https://dotnetfiddle.net/YDtl6k">Run .NET fiddle</a></p>

Extraction can operate on objects of any type. Use the extractor parameter to reduce the object to the string it should be compared on:

var events = new[]
{
    new[] { "chicago cubs vs new york mets", "CitiField", "2011-05-11", "8pm" },
    new[] { "new york yankees vs boston red sox", "Fenway Park", "2011-05-11", "8pm" },
    new[] { "atlanta braves vs pittsburgh pirates", "PNC Park", "2011-05-11", "8pm" },
};
var query = new[] { "new york mets vs chicago cubs", "CitiField", "2017-03-19", "8pm" };
var best = Process.ExtractOneBy(query, events, strings => strings[0]);
// (value: { "chicago cubs vs new york mets", "CitiField", "2011-05-11", "8pm" }, score: 95, index: 0)

If the query is already a string, it can be matched directly against generic choices by providing only a choice extractor:

var events = new[]
{
    new { Name = "new york mets vs chicago cubs", Venue = "CitiField" },
    new { Name = "chicago cubs vs chicago white sox", Venue = "Wrigley Field" },
    new { Name = "philadelphia phillies vs atlanta braves", Venue = "Citizens Bank Park" },
};

var query = "new york mets at chicago cubs";

var best = Process.ExtractOneBy(query, events, e => e.Name);
// best.Value.Name == "new york mets vs chicago cubs"

var top = Process.ExtractTopBy(query, events, e => e.Name, limit: 2);

Fluent Pipeline API

The Process.Configure() fluent builder creates reusable, immutable pipelines with preconfigured scoring, caching, and parallel execution.

Basic Pipeline

Equivalent to the static Process methods, but reusable across multiple queries:

<p align="right"><a href="https://dotnetfiddle.net/KEFXxm">Run .NET fiddle</a></p>

var pipeline = Process.Configure().Build();

var result1 = pipeline.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" });
//(string: Dallas Cowboys, score: 90, index: 3)
var result2 = pipeline.ExtractOne(
    "chicago cubs",
    new[]
    {
        "Boston Red Sox",
        "Los Angeles Dodgers",
        "New York Yankees",
        "San Francisco Giants",
        "St. Louis Cardinals",
        "Houston Astros"
    });
//(string: San Francisco Giants, score: 45, index: 3)

Custom Scorer

<p align="right"><a href="https://dotnetfiddle.net/6JVmU9">Run .NET fiddle</a></p>

var pipeline = Process.Configure()
    .WithScorer(ScorerCache.Get<DefaultRatioScorer>())
    .Build();

var result = pipeline.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" });
//(string: Dallas Cowboys, score: 66.66666666666667, index: 3)

Parallel Execution

Enable multi-threaded processing for large choice sets:

var pipeline = Process.Configure()
    .Parallel()
    .Build();

var results = pipeline.ExtractAll("goolge", largeChoicesList);

With ParallelOptions for fine-grained control:

var pipeline = Process.Configure()
    .Parallel(new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount })
    .Build();

Cached Execution

<p align="right"><a href="https://dotnetfiddle.net/y6qMJm">Run .NET fiddle</a></p>

Automatic caching creates a CachedWeightedRatioScorer per extraction call, pre-initializing internal data structures for the query string:

var pipeline = Process.Configure()
    .Cached()
    .Build();

var result = pipeline.ExtractOne("cowboys", new[] { "Atlanta Falcons", "New York Jets", "New York Giants", "Dallas Cowboys" });

Caching pays off when the query is compared with many candidates or reused across calls. For a single score, call Fuzz.Ratio or Fuzz.WeightedRatio directly; constructing a cached scorer for one comparison adds work and allocations.

Cached + Parallel

Combine caching and parallelism. Builder methods are order independent -- .Cached().Parallel() and .Parallel().Cached() produce identical results:

var pipeline = Process.Configure()
    .Cached()
    .Parallel(new ParallelOptions { MaxDegreeOfParallelism = Environment.ProcessorCount })
    .Build();

var results = pipeline.ExtractAll("goolge", largeChoicesList);

External Cached Scorer

For maximum performance when running the same query against different choice sets, provide an externally managed ICachedRatioScorer. The scorer pre-initializes once and is reused across all extraction calls:

using var scorer = new CachedWeightedRatioScorer("new york mets at atlanta braves");

var pipeline = Process.Configure()
    .Cached(scorer)
    .Parallel()
    .Build();

var results1 = pipeline.ExtractAll(choiceSet1);
var results2 = pipeline.ExtractAll(choiceSet2);

Note: External cached scorers implement IDisposable. Use using to ensure proper cleanup.

CancellationToken Support

Pass a CancellationToken via ParallelOptions to cancel long-running parallel extractions:

var cts = new CancellationTokenSource();

var pipeline = Process.Configure()
    .Cached()
    .Parallel(new ParallelOptions { CancellationToken = cts.Token })
    .Build();

// Throws OperationCanceledException if cancelled
var results = pipeline.ExtractAll(query, largeChoicesList).ToList();

Using Different Scorers

Non-Cached Scorers (IRatioScorer)

Stateless scorers for use with Process static methods and the WithScorer() builder method:

var ratio              = ScorerCache.Get<DefaultRatioScorer>();
var partialRatio       = ScorerCache.Get<PartialRatioScorer>();
var tokenSet           = ScorerCache.Get<TokenSetScorer>();
var partialTokenSet    = ScorerCache.Get<PartialTokenSetScorer>();
var tokenSort          = ScorerCache.Get<TokenSortScorer>();
var partialTokenSort   = ScorerCache.Get<PartialTokenSortScorer>();
var tokenAbbreviation  = ScorerCache.Get<TokenAbbreviationScorer>();
var partialTokenAbbrev = ScorerCache.Get<PartialTokenAbbreviationScorer>();
var weighted           = ScorerCache.Get<WeightedRatioScorer>();

Cached Scorers (ICachedRatioScorer)

<p align="right"><a href="https://dotnetfiddle.net/Ykr94M">Run .NET fiddle</a></p>

Pre-initialize with a query string for repeated comparisons. These implement IDisposable:

using var scorer = new CachedWeightedRatioScorer("search query");
double score = scorer.Score("candidate string");
// 27.14285714285714

Available cached scorers:

  • CachedWeightedRatioScorer -- weighted combination (default for .Cached())
  • CachedDefaultRatioScorer -- simple Levenshtein ratio
  • CachedTokenSortScorer -- token sort ratio
  • CachedTokenSetScorer -- token set ratio
  • CachedPartialTokenSetScorer -- partial token set ratio
  • CachedTokenDifferenceScorer -- token difference ratio

Distance APIs

Levenshtein Distance API

<p align="right"><a href="https://dotnetfiddle.net/JzzcwS">Run .NET fiddle</a></p>

Low-level access to the bit-parallel Levenshtein distance implementation:

// Edit distance
int distance = Levenshtein.Distance("kitten", "sitting");
// 3

// Normalized similarity (1.0 = identical, 0.0 = completely different)
double similarity = Levenshtein.NormalizedSimilarity("kitten", "sitting");
// 0.5714285714285714

// With a cutoff: a distance above it is returned as scoreCutoff + 1
int capped = Levenshtein.Distance("kitten", "sitting", scoreCutoff: 2);
// 3

// Edit operations to transform one string into another
EditOp[] ops = Levenshtein.GetEditOps("kitten", "sitting");
// [REPLACE(0, 0), REPLACE(4, 4), INSERT(6, 6)]

With a cutoff, long inputs (over 128 characters) only compute the band of the bit-parallel matrix that an alignment within the cutoff can pass through, so a tight cutoff is much faster than computing the full distance.

Other Distance Metrics

OSA, DamerauLevenshtein, Jaro, JaroWinkler, Hamming, Prefix and Postfix follow RapidFuzz and have the same Distance, Similarity, NormalizedDistance and NormalizedSimilarity methods, with an optional scoreCutoff:

int osa = OSA.Distance("CA", "ABC");
// 3 (no substring is edited twice)
int damerau = DamerauLevenshtein.Distance("CA", "ABC");
// 2
double jaro = Jaro.Similarity("MARTHA", "MARHTA");
// 0.944...
double jaroWinkler = JaroWinkler.Similarity("MARTHA", "MARHTA");             // prefixWeight: 0.1
// 0.961...
int hamming = Hamming.Distance("karolin", "kathrin");
// 3 (different lengths count the extra elements as mismatches; pad: false throws instead)
int prefix = Prefix.Similarity("prefix", "prelude");
// 3
int postfix = Postfix.Similarity("walking", "talking");
// 6

Instance Distance Classes

The Levenshtein, Indel, LongestCommonSubsequence, Jaro and JaroWinkler classes also offer an instance API for one-to-many comparisons. The constructor pre-computes a bit-parallel pattern match vector from the source string, which is then reused across all subsequent calls. This avoids rebuilding the internal data structure on every comparison, giving a significant speedup when comparing one source against many targets.

All of them implement IDisposable -- use using to return pooled arrays.

Levenshtein Instance

<p align="right"><a href="https://dotnetfiddle.net/hxUB72">Run .NET fiddle</a></p>

using var lev = new Levenshtein("chicago cubs vs new york mets");

int d1 = lev.DistanceFrom("new york mets vs chicago cubs");
// 22
int d2 = lev.DistanceFrom("atlanta braves vs pittsburgh pirates");
// 26
Indel Instance

<p align="right"><a href="https://dotnetfiddle.net/UkyXk2">Run .NET fiddle</a></p>

Indel distance counts only insertions and deletions (no replacements). NormalizedSimilarityWith returns a value between 0.0 (completely different) and 1.0 (identical):

using var indel = new Indel("chicago cubs");

int distance = indel.DistanceFrom("chicago white sox");
// 11
double similarity = indel.NormalizedSimilarityWith("chicago white sox");
// 0.6206896551724138

A generic variant IndelT<T> is available for comparing sequences of any IEquatable<T>:

using var indel = new IndelT<string>(new[] { "hello", "world" });

int distance = indel.DistanceFrom(new[] { "hello", "there" });
// 2
double similarity = indel.NormalizedSimilarityWith(new[] { "hello", "there" });
// 0.5
LongestCommonSubsequence Instance

<p align="right"><a href="https://dotnetfiddle.net/s60rZT">Run .NET fiddle</a></p>

LCS distance is defined as max(len1, len2) - LCS_length:

using var lcs = new LongestCommonSubsequence("chicago cubs");

int distance = lcs.DistanceFrom("chicago white sox");
// 8
Jaro and JaroWinkler Instances

Jaro and JaroWinkler index the source once: 64-bit masks when it has up to 64 characters, a position index otherwise. SimilarityWith and DistanceFrom return exactly what the static methods return with the source as the first argument, and accept a scoreCutoff. Instances are safe to share between threads.

using var jaro = new Jaro("MARTHA");
double similarity = jaro.SimilarityWith("MARHTA");
// 0.944...

using var jaroWinkler = new JaroWinkler("MARTHA", prefixWeight: 0.1);
double score = jaroWinkler.SimilarityWith("MARHTA", scoreCutoff: 0.9);
// 0.961...

String Preprocessors

<p align="right"><a href="https://dotnetfiddle.net/cIQ6PB">Run .NET fiddle</a></p>

By default, Fuzz methods compare strings as-is. Pass StringPreprocessor.Full to normalize whitespace, lowercase, and strip non-alphanumeric characters before comparing:

Fuzz.Ratio("new york mets", "NEW YORK METS");
// < 100 (case sensitive)

Fuzz.Ratio("new york mets", "NEW YORK METS", StringPreprocessor.Full);
// 100 (case insensitive after preprocessing)

Process extraction methods use StringPreprocessor.Full by default. The default processor lowercases with invariant Unicode casing, so its results are deterministic across request cultures. Pass StringPreprocessor.None (or a custom processor function) to override this behavior or provide locale-specific matching.

Performance

The large Levenshtein workload generates 20 seeded words with lengths in [3, 1024) and computes 400 ordered pairs per operation. Fastenshtein and Raffinert.FuzzySharp reuse an instance per source word. Lodestar.Text has no instance API, so it calls its static Levenshtein.Distance for each pair, and the "(static)" row does the same with Raffinert.FuzzySharp for a like-for-like comparison. Lodestar.Text's distances are checked against Raffinert.FuzzySharp's for every pair before timing. The FuzzySharp row is Classic 2.0.2; ratios are relative to naive DP. Times and allocations are per batch.

Measured on 2026-12-05 with Raffinert.FuzzySharp 7.0.0 (PR 41 head, bf4130d) and Lodestar.Text 0.7.0 (the dependency of Lodestar.Fuzzy 0.5.0): BenchmarkDotNet 0.15.8, Release, .NET 10.0.15 / SDK 10.0.115, Ubuntu 24.04 cloud VM, Intel Xeon 2.70 GHz (4 cores, AVX-512), pinned to one core (logical CPU 1), tiered compilation disabled, two launches of five warmups and seven 200 ms iterations, no outliers removed. This host is slower than the desktop of the previous measurement, so compare the ratios rather than the absolute times.

Method Mean Error StdDev Ratio Gen0 Allocated Alloc Ratio
NaiveDp 243.520 ms 6.1344 ms 5.4380 ms 1.00 1000.0000 275312720 B 1.000
FuzzySharp 153.307 ms 8.1017 ms 7.1820 ms 0.63 - 1545632 B 0.006
Fastenshtein 143.047 ms 3.0124 ms 2.6704 ms 0.59 - 33928 B 0.000
Quickenshtein 17.741 ms 1.6513 ms 1.4639 ms 0.07 - - 0.000
Lodestar.Text 2.661 ms 0.0997 ms 0.0884 ms 0.01 - - 0.000
Raffinert.FuzzySharp (static) 2.936 ms 0.0570 ms 0.0505 ms 0.01 - - 0.000
Raffinert.FuzzySharp 2.805 ms 0.1172 ms 0.1039 ms 0.01 - 2080 B 0.000

See benchmark results and reproduction instructions for cache/parallel variants, multiword cases, allocations and inputs. These microbenchmarks cover specific inputs on one machine; small differences need longer measurements. Partial-ratio algorithms and score rounding differ between the libraries.

Linear-time Jaro

For inputs longer than 64 characters, Jaro and Jaro-Winkler run in O(m + n). Each symbol of the first string has a chain of its positions and a pointer to the first one that is still free. Both edges of the matching window only move forward, so each pointer skips a position once and never moves back. RapidFuzz scans multiword bit masks instead, which costs O(n Β· ⌈m / 64βŒ‰), so the gap grows with the length. When the first string fits in 64 characters, one 64-bit mask per symbol handles a second string of any length.

The same 20 pairs per length (half a text and a copy with 2% edits, half two unrelated texts) were run through both libraries. Every sum of scores is bit-for-bit equal to RapidFuzz's. Times are mean per pair. Raffinert.FuzzySharp ran under BenchmarkDotNet on .NET 10 with tiered compilation off. RapidFuzz C++ (194bcb3) was built with g++ 13 -O3 -march=native and timed natively as the median of 15 runs. There is no interop on either side. Both ran on the same 4-core Linux x64 cloud VM (Intel Xeon), on 2026-12-05.

Length Metric RapidFuzz C++ Raffinert.FuzzySharp Speedup
100 Jaro 948 ns 591 ns 1.6Γ—
100 Jaro-Winkler 945 ns 631 ns 1.5Γ—
1,000 Jaro 17.8 ΞΌs 5.4 ΞΌs 3.3Γ—
1,000 Jaro-Winkler 17.8 ΞΌs 5.1 ΞΌs 3.5Γ—
10,000 Jaro 408 ΞΌs 54 ΞΌs 7.6Γ—
10,000 Jaro-Winkler 409 ΞΌs 51 ΞΌs 8.1Γ—

The C++ program and the steps to rerun it are in the benchmarks README. This comparison is for single pairs; RapidFuzz's SIMD batch scorer (process.cdist over many short strings) was not measured.

Migration Notes

From original FuzzySharp

The package name is Raffinert.FuzzySharp, and the default namespace is Raffinert.FuzzySharp. This package keeps the familiar FuzzyWuzzy-style API while adding faster distance implementations, fixed partial-ratio behavior, cached scorers, and the fluent process pipeline.

From Raffinert.FuzzySharp v4 to v5

  • PreprocessMode-based APIs were replaced with Func<string, string> preprocessors.
  • Use StringPreprocessor.Full, StringPreprocessor.None, or a custom delegate instead of PreprocessMode.Full or PreprocessMode.None.
  • Generic extraction methods that use extractor delegates are now named Extract*By, such as ExtractOneBy and ExtractTopBy.

From Raffinert.FuzzySharp v5 to v6

Similarity scoring now uses double throughout the library so fractional scores are preserved instead of being rounded to integers:

double score = Fuzz.Ratio("new york mets", "new york mets!");

ExtractedResult<string> match = Process.ExtractOne(
    "goolge",
    new[] { "google", "bing", "facebook" });

double matchScore = match.Score;

The following APIs changed from int to double:

  • Fuzz similarity methods
  • Scorer and CachedScorer delegates
  • IRatioScorer, ICachedRatioScorer, and their generic variants
  • scoring strategies, including ICachedStrategy
  • ExtractedResult<T>.Score
  • extraction cutoff parameters across standard, cached, parallel, and pipeline APIs

Extraction cutoffs can therefore retain fractional thresholds:

var matches = Process.ExtractAll(
    "goolge",
    new[] { "google", "bing", "facebook" },
    cutoff: 87.5);

Custom scorers and method-group targets must update their return types accordingly:

public sealed class CustomScorer : IRatioScorer
{
    public double Score(string input1, string input2) => /* calculate score */ 0.0;

    public double Score(
        string input1,
        string input2,
        Func<string, string> preprocessor) =>
        Score(preprocessor(input1), preprocessor(input2));
}

The optional scoreCutoff argument was removed from Indel, Levenshtein, and longest-common-subsequence distance and similarity APIs (v7 restores it). Compute the result first and apply any threshold explicitly:

// v5
int limitedDistance = Levenshtein.Distance("kitten", "sitting", scoreCutoff: 2);

// v6
int distance = Levenshtein.Distance("kitten", "sitting");
bool isWithinCutoff = distance <= 2;

This does not remove extraction filtering: Process and ResultExtractor still accept cutoff, now as a double. Raw edit distances and unnormalized similarity counts remain int; normalized distance and similarity values remain double in the range 0–1.

From Raffinert.FuzzySharp v6 to v7

Scorers and distance APIs accept a score cutoff again. Below the cutoff a scorer returns 0, and the built-in ones skip work for pairs that cannot reach it:

double score = Fuzz.WeightedRatio("new york mets", "atlanta braves", scoreCutoff: 80);
// 0 (the exact score is below 80)

int distance = Levenshtein.Distance("kitten", "sitting", scoreCutoff: 2);
// 3 (= scoreCutoff + 1: the distance exceeds the cutoff)
  • IRatioScorer gained double Score(string input1, string input2, double scoreCutoff) and ICachedRatioScorer gained double Score(string input2, double scoreCutoff) (likewise the generic interfaces). Scorers derived from ScorerBase inherit a default that scores in full and filters. A class that implements an interface directly must add the method, for example:
public double Score(string input1, string input2, double scoreCutoff)
{
    double score = Score(input1, input2);
    return score >= scoreCutoff ? score : 0;
}
  • WeightedRatioScorer is sealed; wrap it instead of deriving from it.
  • Extraction passes the cutoff, the current best (ExtractOne) or the lowest kept score (ExtractTop) to the scorer, so custom scorers that implement the cutoff method can skip work too.

Credits

Support

Support the project through GitHub Sponsors or via PayPal.

See CHANGELOG.md for release history.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  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.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 is compatible. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net45 is compatible.  net451 was computed.  net452 was computed.  net46 is compatible.  net461 was computed.  net462 is compatible.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 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 (1)

Showing the top 1 NuGet packages that depend on Raffinert.FuzzySharp:

Package Downloads
DSharpPlus.Commands

An all in one package for managing commands.

GitHub repositories (3)

Showing the top 3 popular GitHub repositories that depend on Raffinert.FuzzySharp:

Repository Stars
DSharpPlus/DSharpPlus
A .NET library for making bots using the Discord API.
iPromKnight/zilean
maxensas/xiletrade
PoE & PoE2 Price Check Overlay
Version Downloads Last Updated
7.0.0 0 12/5/2026
6.0.4 938 11/29/2026
6.0.3 208 11/28/2026
6.0.2 2,895 11/14/2026
6.0.1 20,928 9/17/2026
6.0.0 12,792 8/21/2026
5.0.3 33,836 7/14/2026
5.0.2 147,053 5/23/2026
5.0.1 726 5/22/2026
5.0.0 9,374 5/17/2026
4.0.2 1,097 5/15/2026
4.0.1 8,349 4/25/2026
4.0.0 18,651 2/12/2026
3.0.9 12,374 2/7/2026
3.0.8 5,949 1/21/2026
3.0.7 1,868 1/14/2026
3.0.6 25,992 9/21/2025
3.0.5 1,552 9/5/2025
3.0.4 20,632 9/2/2025
3.0.3 3,724 7/18/2025
Loading failed