pub struct SimHashDocumentEncoder { /* private fields */ }Expand description
SimHash Document Encoder.
Encodes documents and text into SDRs where similar documents will have similar representations. Uses the SimHash algorithm with SHA3/SHAKE256 hashing.
§Example
use mokosh::encoders::{SimHashDocumentEncoder, SimHashDocumentEncoderParams, Encoder};
let encoder = SimHashDocumentEncoder::new(SimHashDocumentEncoderParams {
size: 400,
active_bits: 21,
..Default::default()
}).unwrap();
let tokens = vec!["hello".to_string(), "world".to_string()];
let sdr = encoder.encode_to_sdr(tokens).unwrap();
assert_eq!(sdr.get_sum(), 21);Implementations§
Source§impl SimHashDocumentEncoder
impl SimHashDocumentEncoder
Sourcepub fn new(params: SimHashDocumentEncoderParams) -> Result<Self>
pub fn new(params: SimHashDocumentEncoderParams) -> Result<Self>
Creates a new SimHash Document Encoder.
Sourcepub fn size_param(&self) -> UInt
pub fn size_param(&self) -> UInt
Returns the size.
Sourcepub fn active_bits(&self) -> UInt
pub fn active_bits(&self) -> UInt
Returns the number of active bits.
Trait Implementations§
Source§impl Clone for SimHashDocumentEncoder
impl Clone for SimHashDocumentEncoder
Source§fn clone(&self) -> SimHashDocumentEncoder
fn clone(&self) -> SimHashDocumentEncoder
Returns a duplicate of the value. Read more
1.0.0§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SimHashDocumentEncoder
impl Debug for SimHashDocumentEncoder
Source§impl Encoder<&str> for SimHashDocumentEncoder
Convenience implementation for string slices.
impl Encoder<&str> for SimHashDocumentEncoder
Convenience implementation for string slices.
Source§impl Encoder<String> for SimHashDocumentEncoder
Convenience implementation for String.
impl Encoder<String> for SimHashDocumentEncoder
Convenience implementation for String.
Source§impl Encoder<Vec<String>> for SimHashDocumentEncoder
impl Encoder<Vec<String>> for SimHashDocumentEncoder
Auto Trait Implementations§
impl Freeze for SimHashDocumentEncoder
impl RefUnwindSafe for SimHashDocumentEncoder
impl Send for SimHashDocumentEncoder
impl Sync for SimHashDocumentEncoder
impl Unpin for SimHashDocumentEncoder
impl UnwindSafe for SimHashDocumentEncoder
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)