Skip to main content

SimiFlow

Struct SimiFlow 

Source
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

Source

pub fn new() -> Self

Create a new SimiFlow with default settings.

Source

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();
Source

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.

Source

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.

Source

pub fn preprocess(self, enable: bool) -> Self

Enable or disable preprocessing.

Source

pub fn with_preprocessor(self, pre: Preprocessor) -> Self

Set a custom preprocessor.

Source

pub fn strategy(self, s: Strategy) -> Self

Set the comparison strategy.

Source

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.

Source

pub fn tier_2(self, algo: Algo, threshold: Threshold) -> Self

Configure Tier 2 (Heavy Local Pass) with algorithm and threshold range.

Source

pub fn fallback<F>(self, f: F) -> Self
where F: Fn(&str, &str) -> (Score, Option<String>) + Send + Sync + 'static,

Set the Tier 3 fallback (LLM/API hook).

Source

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§

Source§

impl Default for SimiFlow

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.