Soenneker.Utils.Strings.DiceCoefficient
4.0.586
Prefix Reserved
See the version list below for details.
dotnet add package Soenneker.Utils.Strings.DiceCoefficient --version 4.0.586
NuGet\Install-Package Soenneker.Utils.Strings.DiceCoefficient -Version 4.0.586
<PackageReference Include="Soenneker.Utils.Strings.DiceCoefficient" Version="4.0.586" />
<PackageVersion Include="Soenneker.Utils.Strings.DiceCoefficient" Version="4.0.586" />
<PackageReference Include="Soenneker.Utils.Strings.DiceCoefficient" />
paket add Soenneker.Utils.Strings.DiceCoefficient --version 4.0.586
#r "nuget: Soenneker.Utils.Strings.DiceCoefficient, 4.0.586"
#:package Soenneker.Utils.Strings.DiceCoefficient@4.0.586
#addin nuget:?package=Soenneker.Utils.Strings.DiceCoefficient&version=4.0.586
#tool nuget:?package=Soenneker.Utils.Strings.DiceCoefficient&version=4.0.586
Soenneker.Utils.Strings.DiceCoefficient
Sørensen–Dice string similarity using overlapping character bigrams.
Installation
dotnet add package Soenneker.Utils.Strings.DiceCoefficient
Usage
using Soenneker.Utils.Strings.DiceCoefficient;
var text1 = "This is a test";
var text2 = "This is another test";
double score = DiceCoefficientStringUtil.Calculate(text1, text2);
double percentage = DiceCoefficientStringUtil.CalculatePercentage(text1, text2);
// score == 0.75
// percentage == 75
For each input, the utility creates overlapping two-character sequences and compares them as a multiset. Repeated bigrams therefore count up to the number present in both inputs. The coefficient is:
2 × shared bigram count / total bigram count across both inputs
Calculate returns a value from 0 to 1; CalculatePercentage multiplies it by 100.
Comparison rules
- Comparison is case-sensitive.
- Bigrams consist of adjacent UTF-16 code units.
- Whitespace and punctuation participate like any other character.
- Order inside each bigram matters, while the order of the resulting bigram collection does not.
- Two empty strings return
1; one empty input returns0. - Inputs shorter than two characters return
1only when they are exactly equal, otherwise0.
Call the static methods directly; no dependency-injection registration is required. Normalize casing, whitespace, punctuation, or Unicode representation before calling if your application needs those equivalences.
The implementation allocates a frequency dictionary for the shorter input and scans the longer input once, making it suitable for ordinary fuzzy matching and duplicate-candidate ranking. It is lexical comparison, not semantic similarity.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. |
-
net10.0
- Soenneker.Extensions.String (>= 4.0.744)
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 |
|---|---|---|
| 11.0.630 | 118 | 11/3/2026 |
| 11.0.629 | 83 | 11/3/2026 |
| 11.0.628 | 90 | 11/2/2026 |
| 11.0.626 | 126 | 10/26/2026 |
| 11.0.625 | 97 | 10/26/2026 |
| 4.0.623 | 143 | 10/15/2026 |
| 4.0.622 | 95 | 10/14/2026 |
| 4.0.621 | 105 | 10/14/2026 |
| 4.0.620 | 97 | 10/14/2026 |
| 4.0.618 | 93 | 10/14/2026 |
| 4.0.611 | 109 | 10/13/2026 |
| 4.0.608 | 104 | 10/11/2026 |
| 4.0.607 | 79 | 10/11/2026 |
| 4.0.606 | 101 | 10/11/2026 |
| 4.0.605 | 107 | 10/11/2026 |
| 4.0.604 | 147 | 9/30/2026 |
| 4.0.603 | 131 | 9/25/2026 |
| 4.0.602 | 105 | 9/25/2026 |
| 4.0.601 | 113 | 9/24/2026 |
| 4.0.586 | 115 | 9/8/2026 |
Updated Soenneker.Extensions.String to 4.0.744