pub struct NGramKernel { /* private fields */ }Expand description
N-gram string kernel
Measures similarity by counting common n-grams.
§Example
use tensorlogic_sklears_kernels::{NGramKernel, NGramKernelConfig};
let config = NGramKernelConfig::new(2).unwrap(); // bigrams
let kernel = NGramKernel::new(config);
let text1 = "hello world";
let text2 = "hello there";
let sim = kernel.compute_strings(text1, text2).unwrap();
println!("Similarity: {}", sim);Implementations§
Source§impl NGramKernel
impl NGramKernel
Sourcepub fn new(config: NGramKernelConfig) -> Self
pub fn new(config: NGramKernelConfig) -> Self
Create a new n-gram kernel
Trait Implementations§
Auto Trait Implementations§
impl Freeze for NGramKernel
impl RefUnwindSafe for NGramKernel
impl Send for NGramKernel
impl Sync for NGramKernel
impl Unpin for NGramKernel
impl UnwindSafe for NGramKernel
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> 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