pub struct MinHashSignature {
pub values: Vec<u32>,
pub doc_id: usize,
}Expand description
A MinHash signature for a document.
The signature is a vector of hash values (typically 64-256 values). Similar documents will have similar signatures.
Fields§
§values: Vec<u32>The hash values forming this signature.
doc_id: usizeDocument index (if part of a collection).
Implementations§
Source§impl MinHashSignature
impl MinHashSignature
Sourcepub fn similarity(&self, other: &Self) -> f64
pub fn similarity(&self, other: &Self) -> f64
Compute estimated Jaccard similarity with another signature.
The similarity is the fraction of hash values that match between the two signatures. This approximates the true Jaccard similarity of the original sets.
Sourcepub fn band(&self, start: usize, length: usize) -> &[u32]
pub fn band(&self, start: usize, length: usize) -> &[u32]
Get a band of the signature for LSH.
Returns the slice values[start .. start + length], gracefully clamped
to the signature bounds: a start at or past the end yields an empty
slice, and an over-long length is truncated to the available tail. It
never panics.
This clamp is safe (not a silent recall loss) because the callers that
require exact band tiling, the LshIndex,
validate signature.len() == num_bands * rows_per_band before slicing,
so a band is never silently shortened on the indexing path.
Trait Implementations§
Source§impl Clone for MinHashSignature
impl Clone for MinHashSignature
Source§fn clone(&self) -> MinHashSignature
fn clone(&self) -> MinHashSignature
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more