-
Notifications
You must be signed in to change notification settings - Fork 0
Text indelpattern distance
Development build. This page describes
main, not a released package. The latest published Lodestar.Text is 0.7.0 — read its documentation.
The Indel distance between the held pattern and a text.
public int Distance(ReadOnlySpan<char> text)Parameters — text is the string to scan against the pattern.
Returns — the fewest insertions and deletions that turn one into the other, the number
Indel.Distance gives for the same pair over UTF-16 units.
Exceptions — ObjectDisposedException when the handle has been disposed.
Example — the same answer as the pairwise call, with the table built once.
using Lodestar.Text.Distances;
using IndelPattern query = IndelPattern.For("kitten");
int held = query.Distance("sitting".AsSpan()); // => 5
int pairwise = Indel.Distance("kitten", "sitting"); // => 5Remarks — a substitution costs two here as it does everywhere in
Indel: this counts insertions and deletions, never replacements.
Scanning is thread-safe — the table is only read — but disposal is not, so do not dispose a handle another thread is still scanning with.
Applies to — net10.0, netstandard2.0.
See also — IndelPattern, Indel.Distance,
IndelPattern.NormalizedSimilarity.