pub struct SimiFlow { /* private fields */ }Expand description
The SimiFlow: a declarative pipeline builder for similarity checks.
use simi::router::{SimiFlow, Strategy, Threshold, Algo};
let result = SimiFlow::new()
.preprocess(true)
.strategy(Strategy::Cascade)
.tier_1(Algo::JaroWinkler, Threshold::GreaterThan(0.95), Threshold::LessThan(0.10))
.tier_2(Algo::Bm25, Threshold::Between(0.60, 0.94))
.compare("hello world", "hello there");Implementations§
Source§impl SimiFlow
impl SimiFlow
Sourcepub fn for_intent(intent: Intent) -> Self
pub fn for_intent(intent: Intent) -> Self
Create a SimiFlow pre-configured for a specific intent.
The intent picks the algorithm and reasonable default thresholds.
use simi::router::{SimiFlow, Intent};
let result = SimiFlow::for_intent(Intent::Names)
.compare("MARTHA", "MARHTA")
.unwrap();Sourcepub fn auto() -> Self
pub fn auto() -> Self
Create a SimiFlow that auto-detects the best algorithm from inputs.
The algorithm is re-resolved at each compare() call based on the
actual input lengths. Short equal-length strings get Hamming,
short-medium get Jaro-Winkler, medium get BM25, long get SimHash.
Sourcepub fn compare_with_intent(
&self,
intent: Intent,
a: &str,
b: &str,
) -> Result<ComparisonResult, SimiError>
pub fn compare_with_intent( &self, intent: Intent, a: &str, b: &str, ) -> Result<ComparisonResult, SimiError>
Compare two strings, picking the algorithm based on intent at call time.
This ignores any configured tiers and runs the intent-selected algorithm directly.
Sourcepub fn preprocess(self, enable: bool) -> Self
pub fn preprocess(self, enable: bool) -> Self
Enable or disable preprocessing.
Sourcepub fn with_preprocessor(self, pre: Preprocessor) -> Self
pub fn with_preprocessor(self, pre: Preprocessor) -> Self
Set a custom preprocessor.
Sourcepub fn tier_1(
self,
algo: Algo,
match_threshold: Threshold,
mismatch_threshold: Threshold,
) -> Self
pub fn tier_1( self, algo: Algo, match_threshold: Threshold, mismatch_threshold: Threshold, ) -> Self
Configure Tier 1 (Fast Pass) with algorithm and thresholds.
match_threshold: if score > this, return immediately as match.
mismatch_threshold: if score < this, return immediately as mismatch.
Sourcepub fn tier_2(self, algo: Algo, threshold: Threshold) -> Self
pub fn tier_2(self, algo: Algo, threshold: Threshold) -> Self
Configure Tier 2 (Heavy Local Pass) with algorithm and threshold range.
Sourcepub fn compare(&self, a: &str, b: &str) -> Result<ComparisonResult, SimiError>
pub fn compare(&self, a: &str, b: &str) -> Result<ComparisonResult, SimiError>
Compare two strings through the pipeline.
Returns a ComparisonResult with the final score and decision metadata.
When auto_mode is true (created via SimiFlow::auto()), the
algorithm is selected per pair based on input lengths.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SimiFlow
impl !UnwindSafe for SimiFlow
impl Freeze for SimiFlow
impl Send for SimiFlow
impl Sync for SimiFlow
impl Unpin for SimiFlow
impl UnsafeUnpin for SimiFlow
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> 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