pub struct MultiMatcher<Q, C> { /* private fields */ }Implementations§
Source§impl<Q: Clone + Debug, C: Clone + Debug + PartialEq> MultiMatcher<Q, C>
impl<Q: Clone + Debug, C: Clone + Debug + PartialEq> MultiMatcher<Q, C>
Sourcepub fn new() -> Self
pub fn new() -> Self
Examples found in repository?
examples/multimatcher.rs (line 67)
56fn main() {
57 // Create two matchers with different metrics and thresholds
58 let matcher1 = Matcher::<String, String>::new()
59 .add(LevenshteinMetric, 1.0)
60 .threshold(0.6);
61
62 let matcher2 = Matcher::<String, String>::new()
63 .add(JaccardMetric, 1.0)
64 .threshold(0.4);
65
66 // Combine them into a MultiMatcher
67 let multi_matcher = MultiMatcher::<String, String>::new()
68 .add(matcher1)
69 .add(matcher2)
70 .threshold(0.5);
71
72 // Define the query and candidate strings
73 let query = String::from("example");
74 let candidates = vec![
75 String::from("example"),
76 String::from("examp"),
77 String::from("test"),
78 ];
79
80 // Find matches with a limit of 2
81 println!("MultiMatcher Example");
82 println!("===================");
83 let matches = multi_matcher.find_limit(&query, &candidates, 2);
84 println!("Matches found: {}", matches.len());
85 for (i, m) in matches.iter().enumerate() {
86 println!(
87 "Match {}:\n Score: {:.2}\n Candidate: {}\n Exact: {}",
88 i + 1, m.score, m.candidate, m.exact
89 );
90 }
91}Sourcepub fn add(self, matcher: Matcher<Q, C>) -> Self
pub fn add(self, matcher: Matcher<Q, C>) -> Self
Examples found in repository?
examples/multimatcher.rs (line 68)
56fn main() {
57 // Create two matchers with different metrics and thresholds
58 let matcher1 = Matcher::<String, String>::new()
59 .add(LevenshteinMetric, 1.0)
60 .threshold(0.6);
61
62 let matcher2 = Matcher::<String, String>::new()
63 .add(JaccardMetric, 1.0)
64 .threshold(0.4);
65
66 // Combine them into a MultiMatcher
67 let multi_matcher = MultiMatcher::<String, String>::new()
68 .add(matcher1)
69 .add(matcher2)
70 .threshold(0.5);
71
72 // Define the query and candidate strings
73 let query = String::from("example");
74 let candidates = vec![
75 String::from("example"),
76 String::from("examp"),
77 String::from("test"),
78 ];
79
80 // Find matches with a limit of 2
81 println!("MultiMatcher Example");
82 println!("===================");
83 let matches = multi_matcher.find_limit(&query, &candidates, 2);
84 println!("Matches found: {}", matches.len());
85 for (i, m) in matches.iter().enumerate() {
86 println!(
87 "Match {}:\n Score: {:.2}\n Candidate: {}\n Exact: {}",
88 i + 1, m.score, m.candidate, m.exact
89 );
90 }
91}Sourcepub fn threshold(self, threshold: f64) -> Self
pub fn threshold(self, threshold: f64) -> Self
Examples found in repository?
examples/multimatcher.rs (line 70)
56fn main() {
57 // Create two matchers with different metrics and thresholds
58 let matcher1 = Matcher::<String, String>::new()
59 .add(LevenshteinMetric, 1.0)
60 .threshold(0.6);
61
62 let matcher2 = Matcher::<String, String>::new()
63 .add(JaccardMetric, 1.0)
64 .threshold(0.4);
65
66 // Combine them into a MultiMatcher
67 let multi_matcher = MultiMatcher::<String, String>::new()
68 .add(matcher1)
69 .add(matcher2)
70 .threshold(0.5);
71
72 // Define the query and candidate strings
73 let query = String::from("example");
74 let candidates = vec![
75 String::from("example"),
76 String::from("examp"),
77 String::from("test"),
78 ];
79
80 // Find matches with a limit of 2
81 println!("MultiMatcher Example");
82 println!("===================");
83 let matches = multi_matcher.find_limit(&query, &candidates, 2);
84 println!("Matches found: {}", matches.len());
85 for (i, m) in matches.iter().enumerate() {
86 println!(
87 "Match {}:\n Score: {:.2}\n Candidate: {}\n Exact: {}",
88 i + 1, m.score, m.candidate, m.exact
89 );
90 }
91}pub fn best(&self, query: &Q, candidates: &[C]) -> Option<Match<Q, C>>
pub fn find(&self, query: &Q, candidates: &[C]) -> Vec<Match<Q, C>>
Sourcepub fn find_limit(
&self,
query: &Q,
candidates: &[C],
limit: usize,
) -> Vec<Match<Q, C>>
pub fn find_limit( &self, query: &Q, candidates: &[C], limit: usize, ) -> Vec<Match<Q, C>>
Examples found in repository?
examples/multimatcher.rs (line 83)
56fn main() {
57 // Create two matchers with different metrics and thresholds
58 let matcher1 = Matcher::<String, String>::new()
59 .add(LevenshteinMetric, 1.0)
60 .threshold(0.6);
61
62 let matcher2 = Matcher::<String, String>::new()
63 .add(JaccardMetric, 1.0)
64 .threshold(0.4);
65
66 // Combine them into a MultiMatcher
67 let multi_matcher = MultiMatcher::<String, String>::new()
68 .add(matcher1)
69 .add(matcher2)
70 .threshold(0.5);
71
72 // Define the query and candidate strings
73 let query = String::from("example");
74 let candidates = vec![
75 String::from("example"),
76 String::from("examp"),
77 String::from("test"),
78 ];
79
80 // Find matches with a limit of 2
81 println!("MultiMatcher Example");
82 println!("===================");
83 let matches = multi_matcher.find_limit(&query, &candidates, 2);
84 println!("Matches found: {}", matches.len());
85 for (i, m) in matches.iter().enumerate() {
86 println!(
87 "Match {}:\n Score: {:.2}\n Candidate: {}\n Exact: {}",
88 i + 1, m.score, m.candidate, m.exact
89 );
90 }
91}Trait Implementations§
Auto Trait Implementations§
impl<Q, C> Freeze for MultiMatcher<Q, C>
impl<Q, C> !RefUnwindSafe for MultiMatcher<Q, C>
impl<Q, C> !Send for MultiMatcher<Q, C>
impl<Q, C> !Sync for MultiMatcher<Q, C>
impl<Q, C> Unpin for MultiMatcher<Q, C>
impl<Q, C> !UnwindSafe for MultiMatcher<Q, C>
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