pub struct BatchComparator { /* private fields */ }Expand description
A batch comparator that evaluates many string pairs in parallel.
Implementations§
Source§impl BatchComparator
impl BatchComparator
Sourcepub fn new(algorithm: Algo) -> Self
pub fn new(algorithm: Algo) -> Self
Create a new batch comparator with the specified algorithm.
Sourcepub fn for_intent(intent: Intent) -> Self
pub fn for_intent(intent: Intent) -> Self
Create a batch comparator pre-configured for a specific intent.
The intent is resolved at construction time (empty strings are used
for the length heuristic). For Intent::Auto, the caller should
prefer BatchComparator::auto_per_pair() or use new(Algo::*).
use simi::batch::BatchComparator;
use simi::router::Intent;
let docs = vec!["doc a".to_string(), "doc b".to_string()];
let cmp = BatchComparator::for_intent(Intent::Deduplication);
let results = cmp.compare_matrix(&docs, &docs).unwrap();Sourcepub fn auto() -> Self
pub fn auto() -> Self
Create a batch comparator that auto-detects the best algorithm.
This uses the empty-string heuristic for construction. For
per-pair auto-detection, use SimiFlow::compare_with_intent()
or construct a new BatchComparator per pair via the length
heuristic.
Sourcepub fn compare_pairs(
&self,
a: &[String],
b: &[String],
) -> Result<Vec<BatchResult>, SimiError>
pub fn compare_pairs( &self, a: &[String], b: &[String], ) -> Result<Vec<BatchResult>, SimiError>
Compare two arrays element-wise in parallel.
Each pair (A[i], B[i]) is compared using the configured algorithm.
The two slices must have the same length.
Sourcepub fn compare_one_to_many(
&self,
reference: &str,
candidates: &[String],
) -> Result<Vec<BatchResult>, SimiError>
pub fn compare_one_to_many( &self, reference: &str, candidates: &[String], ) -> Result<Vec<BatchResult>, SimiError>
Compare one string against many candidates in parallel.
Returns scores for (reference, candidates[0..n]).
Sourcepub fn compare_matrix(
&self,
a: &[String],
b: &[String],
) -> Result<Vec<BatchResult>, SimiError>
pub fn compare_matrix( &self, a: &[String], b: &[String], ) -> Result<Vec<BatchResult>, SimiError>
Compare all pairs in a cross-product (matrix) in parallel.
Returns n * m results comparing every element in a against
every element in b.
Trait Implementations§
Source§impl Clone for BatchComparator
impl Clone for BatchComparator
Source§fn clone(&self) -> BatchComparator
fn clone(&self) -> BatchComparator
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for BatchComparator
impl RefUnwindSafe for BatchComparator
impl Send for BatchComparator
impl Sync for BatchComparator
impl Unpin for BatchComparator
impl UnsafeUnpin for BatchComparator
impl UnwindSafe for BatchComparator
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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