Soenneker.Utils.String.LongestCommonSequence 11.0.1041

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

Longest common subsequence scoring for strings, with normalized and percentage results.

Installation

dotnet add package Soenneker.Utils.String.LongestCommonSequence

Usage

using Soenneker.Utils.String.LongestCommonSequence;

var text1 = "This is a test";
var text2 = "This is another test";

double score = LcsStringUtil.CalculateSimilarity(text1, text2);
double percentage = LcsStringUtil.CalculateSimilarityPercentage(text1, text2);

// score == 0.7
// percentage == 70

The longest common subsequence preserves character order but does not require matching characters to be adjacent. The normalized score is:

LCS length / length of the longer input

CalculateSimilarity returns a value from 0 to 1; CalculateSimilarityPercentage multiplies it by 100. Identical strings, including two empty strings, return 1 (or 100%).

Comparison rules and cost

  • Comparison is case-sensitive.
  • The algorithm compares UTF-16 code units, not words, Unicode scalar values, or grapheme clusters.
  • Whitespace and punctuation participate like any other character.
  • Runtime is O(m × n) for input lengths m and n.
  • CalculateSimilarity uses O(min(m, n)) working memory.

For long inputs, the quadratic runtime can be significant. Normalize casing or Unicode representation before calling when your application requires those equivalences.

Prefix lengths

CalculateSimilarityArray(first, second) exposes the final dynamic-programming row. Element j contains the LCS length between first and the first j characters of second; the returned array therefore has second.Length + 1 elements. Use its last element for the complete LCS length.

All methods require non-null strings.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net11.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
11.0.1041 563 10/27/2026
11.0.1040 101 10/26/2026
11.0.1039 92 10/26/2026
4.0.1038 102 10/25/2026
4.0.1037 127 10/14/2026
4.0.1036 100 10/14/2026
4.0.1030 100 10/13/2026
4.0.1028 120 10/11/2026
4.0.1027 157 9/24/2026
4.0.1026 126 9/15/2026
4.0.1025 112 9/14/2026
4.0.1024 128 9/8/2026
4.0.1023 132 8/30/2026
4.0.1022 131 8/26/2026
4.0.1021 131 8/12/2026
4.0.1020 129 7/27/2026
4.0.1019 4,994 7/16/2026
4.0.1018 129 7/14/2026
4.0.1017 188 6/18/2026
4.0.1016 177 6/9/2026
Loading failed

Remove redundant framework conditions