Text 0.6.0 bktreematch - CyrilB1531/lodestar GitHub Wiki

Lodestar.Text 0.6.0. 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.

BkTreeMatch

One hit from a BkTree query: the item, and how far it is.

public readonly record struct BkTreeMatch(string Item, int Distance)

ParametersItem is the indexed string. Distance is what the tree's own metric returned for it against the query.

Example — the exact match itself, at distance zero.

using Lodestar.Text.Indexing;

BkTree tree = BkTree.OverLevenshtein();
tree.AddRange(["book", "cook"]);

BkTreeMatch hit = tree.WithinDistance("book", 1)[0];
string item = hit.Item;       // => book
int distance = hit.Distance;  // => 0

RemarksDistance is an integer edit distance, not a normalized score. Comparing it against a similarity in [0, 100] — a Fuzz ratio, say — is comparing two different quantities.

A record struct, so equality is by value and two hits with the same item and distance compare equal.

Applies to — net10.0, netstandard2.0.

See alsoBkTree.WithinDistance, BkTree.Nearest.