Skip to content

Text 0.3.2 levenshtein normalizedsimilarity

github-actions[bot] edited this page Aug 16, 2026 · 1 revision

Lodestar.Text 0.3.2. This page is frozen at that release. Read the current documentation for what main says now. A link to a decision or a migration page follows main, and leaves the archive.

Levenshtein.NormalizedSimilarity

1 - NormalizedDistance: 1 when the two are identical, 0 when nothing survives.

public static double NormalizedSimilarity(ReadOnlySpan<char> a, ReadOnlySpan<char> b, TextElement element = TextElement.Utf16Unit)

Parametersa and b are the two strings to compare; element says what counts as one character, exactly as it does for NormalizedDistance, which this is computed from.

Returnsdouble in [0, 1], larger meaning more alike. Two empty inputs give 1.

Example — the same three edits, read as a score.

using Lodestar.Text.Distances;

double s = Levenshtein.NormalizedSimilarity("kitten", "sitting");   // => 0.5714…

Remarks — this is the member to reach for by default when you want one number saying how alike two strings are and you have no particular reason to prefer another measure. It matches Levenshtein.normalized_similarity in rapidfuzz exactly.

Two traps. Two empty inputs return 1, a perfect match between two blanks — filter empties first if that is wrong for your data. And this is not fuzz.ratio: that is Indel.NormalizedSimilarity times 100, and substituting this for it is the single most common porting mistake in this area.

Applies to — net10.0, netstandard2.0.

See alsoLevenshtein.NormalizedDistance, Indel.NormalizedSimilarity, DamerauLevenshtein.NormalizedSimilarity, the Python equivalence table.

Lodestar

Project

Clone this wiki locally