pub struct Score {
pub value: f64,
pub weight: f64,
}Fields§
§value: f64§weight: f64Implementations§
Source§impl Score
impl Score
Sourcepub fn weighted(&self) -> f64
pub fn weighted(&self) -> f64
Examples found in repository?
examples/analysis.rs (line 81)
57fn main() {
58 // Create a matcher with two metrics
59 let matcher = Matcher::<String, String>::new()
60 .add(LevenshteinMetric, 0.7) // 70% weight
61 .add(JaccardMetric, 0.3) // 30% weight
62 .threshold(0.5);
63
64 // Define the query and candidate
65 let query = String::from("test");
66 let candidate = String::from("tent");
67
68 // Perform detailed analysis
69 println!("Detailed Analysis Example");
70 println!("========================");
71 let analysis = matcher.analyze(&query, &candidate);
72 println!("Query: {}", analysis.query);
73 println!("Candidate: {}", analysis.candidate);
74 println!("Overall score: {:.2}", analysis.score);
75 println!("Exact match: {}", analysis.exact);
76 println!("Is match: {}", matcher.matches(&query, &candidate));
77 println!("Individual metric scores:");
78 for (i, score) in analysis.scores.iter().enumerate() {
79 println!(
80 " Metric {}:\n Raw score: {:.2}\n Weight: {:.2}\n Weighted score: {:.2}",
81 i + 1, score.value, score.weight, score.weighted()
82 );
83 }
84}Trait Implementations§
Auto Trait Implementations§
impl Freeze for Score
impl RefUnwindSafe for Score
impl Send for Score
impl Sync for Score
impl Unpin for Score
impl UnwindSafe for Score
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