pub struct SimpleSearch {
pub algorithm: Algorithm,
pub distance: fn(&str, &str) -> f64,
pub max_edits: Option<i32>,
pub similarity_threshold: Option<f64>,
pub targets: Vec<String>,
}Expand description
A struct to hold the input into a Simple Search.
Simple Search focuses on comparing strings which could be anything provided by the user.
Simple Search uses SimpleSearch and SimpleResult to hold the input and output data.
Fields§
§algorithm: AlgorithmThe Algorithm to use.
distance: fn(&str, &str) -> f64The distance function to use, based on the Algorithm selected.
max_edits: Option<i32>The maximum number of edits allowed.
This can be None if the user does not want to limit the results based on the number of edits.
This should be None if the Algorithm is not an edit distance.
similarity_threshold: Option<f64>The minimum similarity score required.
This can be None if the user does not want to limit the results based on the similarity score.
targets: Vec<String>The target search words in the format of a vector of strings.
Implementations§
Trait Implementations§
Source§impl Search for SimpleSearch
impl Search for SimpleSearch
Source§fn scan(
&self,
text: &str,
record: Option<String>,
state: &mut Option<HashMap<(String, String), f64>>,
) -> Vec<SearchOutput>
fn scan( &self, text: &str, record: Option<String>, state: &mut Option<HashMap<(String, String), f64>>, ) -> Vec<SearchOutput>
Scanning function to find matches.
Searches the input text for the target words. This also does some pre-processing to remove punctuation and other non-alphanumeric characters as well as upper-casing the input text.
The search will be limited by the number of edits and/or similarity threshold (if) provided in the SimpleSearch struct.
The results will be returned as a vector of SimpleResult structs.
§Examples
TODO: Add examples
let search = SimpleSearch::new(Algorithm::Levenshtein, levenshtein, None, None, &["hello", "world"]);
let results = search.scan("hello world", None);Auto Trait Implementations§
impl Freeze for SimpleSearch
impl RefUnwindSafe for SimpleSearch
impl Send for SimpleSearch
impl Sync for SimpleSearch
impl Unpin for SimpleSearch
impl UnwindSafe for SimpleSearch
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