pub struct SimHash(pub u64);Expand description
64-bit SimHash fingerprint for near-duplicate content detection.
Based on Charikar’s locality-sensitive hashing algorithm: tokenise → hash each token with FNV-1a → accumulate ±1 per bit → sign-collapse.
Tuple Fields§
§0: u64Implementations§
Source§impl SimHash
impl SimHash
Sourcepub fn compute(text: &str) -> Self
pub fn compute(text: &str) -> Self
Compute a SimHash fingerprint from arbitrary text.
Algorithm:
- Split text into whitespace-delimited tokens, lowercased.
- For each token: compute FNV-1a-64 hash; for each bit position, add +1 if the bit is set, −1 otherwise.
- Collapse: bit[i] = 1 iff counter[i] > 0.
Sourcepub fn distance(&self, other: &SimHash) -> u32
pub fn distance(&self, other: &SimHash) -> u32
Hamming distance between two fingerprints (number of differing bits, 0–64).
Sourcepub fn is_similar(&self, other: &SimHash, threshold: u32) -> bool
pub fn is_similar(&self, other: &SimHash, threshold: u32) -> bool
Returns true if the two fingerprints are similar (Hamming distance ≤ threshold).
A threshold of 6 means ≤6/64 bits differ (≥90% bit-level agreement).
Trait Implementations§
impl Copy for SimHash
impl Eq for SimHash
impl StructuralPartialEq for SimHash
Auto Trait Implementations§
impl Freeze for SimHash
impl RefUnwindSafe for SimHash
impl Send for SimHash
impl Sync for SimHash
impl Unpin for SimHash
impl UnsafeUnpin for SimHash
impl UnwindSafe for SimHash
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
impl<T> Fruit for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more