Text 0.6.0 lshindex query - 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.

LshIndex.Query

The keys sharing at least one band with a signature.

public IReadOnlyList<string> Query(ReadOnlySpan<uint> signature)

Parameterssignature is at least Banding.Permutations long.

ReturnsIReadOnlyList<string>, each candidate once, in the order it was added.

ExceptionsArgumentException when the signature is too short.

Example — a band differing in one slot does not collide.

using Lodestar.Text.Similarity;

var index = new LshIndex(new LshBanding(2, 2));
index.Add("stored", [1u, 2u, 3u, 4u]);

IReadOnlyList<string> missed = index.Query([1u, 99u, 3u, 99u]);

int howMany = missed.Count;  // => 0

Remarks — a key colliding on several bands is returned once, and the order does not encode how many bands agreed. That is deliberate: a band count is not a similarity, and returning candidates ranked by it would invite treating it as one. Score them with MinHash.Jaccard instead.

The band's index is part of its bucket key, so two different bands holding the same slot values do not collide with each other — which they otherwise would, and silently.

Applies to — net10.0, netstandard2.0.

See alsoLshIndex.Add, MinHash.Jaccard.

⚠️ **GitHub.com Fallback** ⚠️