Skip to content

Text indelpattern normalizeddistance

github-actions[bot] edited this page Sep 23, 2026 · 1 revision

Development build. This page describes main, not a released package. The latest published Lodestar.Text is 0.6.0 — read its documentation.

HomeTextDistances

IndelPattern.NormalizedDistance

The distance scaled into [0, 1] by the sum of the two lengths.

public double NormalizedDistance(ReadOnlySpan<char> text)

Parameterstext is the string to scan against the pattern.

Returnsdouble in [0, 1], 0 meaning identical. Two empty inputs give 0.

ExceptionsObjectDisposedException when the handle has been disposed.

Example — five edits over thirteen units.

using Lodestar.Text.Distances;

using IndelPattern query = IndelPattern.For("kitten");

double d = Math.Round(query.NormalizedDistance("sitting".AsSpan()), 4);   // => 0.3846

Remarks — the same expression Indel.NormalizedDistance evaluates, over the same distance, so the two agree bit for bit.

Use this rather than Distance when scores from pairs of different lengths have to be compared: an edit count is not comparable across lengths and this is.

Applies to — net10.0, netstandard2.0.

See alsoIndelPattern, Indel.NormalizedDistance.

Clone this wiki locally