Text 0.7.0 indelpattern normalizeddistance - CyrilB1531/lodestar GitHub Wiki
Lodestar.Text 0.7.0. This page is frozen at that release. Read the current documentation for what
mainsays now. A link to a decision or a migration page followsmain, and leaves the archive.
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.