Skip to content

A utility library for comparing strings via the Longest Common Sequence algorithm

License

Notifications You must be signed in to change notification settings

soenneker/soenneker.utils.string.longestcommonsequence

Repository files navigation

Soenneker.Utils.String.LongestCommonSequence

A utility library for comparing strings via the Longest Common Sequence algorithm

Installation

dotnet add package Soenneker.Utils.String.LongestCommonSequence

Why?

Clarity in Similarity:

LCS gives a straightforward measure of similarity. The longer the common subsequence, the more similar the sequences.

Length-Flexible:

No bias for longer or shorter sequences. Focuses on shared elements, not sequence length.

Meaningful Over Quantity:

Emphasizes the meaning of elements, not just their frequency. Great for identifying shared meaningful content.

Efficient for Big Data:

Handles large datasets and extensive sequences efficiently. Practical for tasks involving substantial amounts of data.

Usage

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

double result = LcsStringUtil.CalculateSimilarityPercentage(text1, text2); // 70