-
Notifications
You must be signed in to change notification settings - Fork 0
Text indelpattern normalizeddistance
Development build. This page describes
main, not a released package. The latest published Lodestar.Text is 0.6.0 — read its documentation.
The distance scaled into [0, 1] by the sum of the two lengths.
public double NormalizedDistance(ReadOnlySpan<char> text)Parameters — text is the string to scan against the pattern.
Returns — double in [0, 1], 0 meaning identical. Two empty inputs give 0.
Exceptions — ObjectDisposedException 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.3846Remarks — 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 also — IndelPattern,
Indel.NormalizedDistance.