Soenneker.Utils.Strings.DiceCoefficient 4.0.604

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

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

alternate text is missing from this package README image 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 returns 0.
  • Inputs shorter than two characters return 1 only when they are exactly equal, otherwise 0.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
4.0.604 65 9/30/2026
4.0.603 115 9/25/2026
4.0.602 86 9/25/2026
4.0.601 94 9/24/2026
4.0.600 90 9/24/2026
4.0.599 115 9/16/2026
4.0.598 89 9/16/2026
4.0.597 96 9/16/2026
4.0.596 103 9/15/2026
4.0.595 92 9/13/2026
4.0.594 102 9/13/2026
4.0.593 97 9/13/2026
4.0.592 100 9/13/2026
4.0.591 106 9/12/2026
4.0.587 104 9/9/2026
4.0.586 100 9/8/2026
4.0.585 109 9/8/2026
4.0.584 102 9/7/2026
4.0.583 105 9/7/2026
4.0.582 104 9/7/2026
Loading failed

Updated Soenneker.Extensions.String to 4.0.770