pub struct MatchConfig {Show 13 fields
pub match_threshold: f64,
pub name_weight: f64,
pub description_weight: f64,
pub disambiguating_description_weight: f64,
pub identifiers_weight: f64,
pub url_weight: f64,
pub same_as_weight: f64,
pub image_weight: f64,
pub main_entity_of_page_weight: f64,
pub additional_types_weight: f64,
pub use_phonetic_matching: bool,
pub name_algorithm: SimilarityAlgorithm,
pub strict_mode: bool,
}Expand description
Tunable configuration for the matching engine.
All weights are dimensionless and contribute to a renormalised weighted
sum — they do not need to add to 1.0. The matching pipeline divides
the weighted sum by the sum of participating weights so that missing
fields neither contribute nor penalise. The score is then compared
against MatchConfig::match_threshold to produce the is_match
boolean.
Two presets cover most needs:
MatchConfig::strict—match_threshold = 0.95,strict_mode = true.MatchConfig::lenient—match_threshold = 0.65, phonetic on.
§Example
use thing_matcher::{MatchConfig, SimilarityAlgorithm};
let custom = MatchConfig {
match_threshold: 0.80,
name_weight: 0.30,
description_weight: 0.10,
disambiguating_description_weight: 0.05,
identifiers_weight: 0.25,
url_weight: 0.05,
same_as_weight: 0.15,
image_weight: 0.03,
main_entity_of_page_weight: 0.02,
additional_types_weight: 0.05,
use_phonetic_matching: true,
name_algorithm: SimilarityAlgorithm::Combined,
strict_mode: false,
};
assert_eq!(custom.match_threshold, 0.80);Fields§
§match_threshold: f64Threshold score for considering two things a match (0.0..=1.0).
name_weight: f64Weight for name similarity (best-of cartesian product across the
primary name and alternate_names on both sides).
description_weight: f64Weight for free-form description similarity.
disambiguating_description_weight: f64Weight for disambiguatingDescription similarity.
identifiers_weight: f64Weight for “shared identifier” (1.0 if any (property_id, value)
pair is shared, 0.0 otherwise).
url_weight: f64Weight for canonical url exact match (after URL normalisation).
same_as_weight: f64Weight for sameAs URL set similarity (Jaccard).
image_weight: f64Weight for image URL exact match (after URL normalisation).
main_entity_of_page_weight: f64Weight for mainEntityOfPage URL exact match (after URL
normalisation).
additional_types_weight: f64Weight for additionalType URI set similarity (Jaccard).
use_phonetic_matching: boolWhether to add a phonetic-name bonus when both names sound alike.
name_algorithm: SimilarityAlgorithmSimilarity algorithm to use when comparing names.
strict_mode: boolReserved flag for stricter deterministic enforcement.
Implementations§
Source§impl MatchConfig
impl MatchConfig
Sourcepub fn strict() -> Self
pub fn strict() -> Self
A stricter preset: match_threshold = 0.95, strict_mode = true.
Use when callers must rely on the answer and false positives are more dangerous than false negatives.
use thing_matcher::MatchConfig;
let c = MatchConfig::strict();
assert!((c.match_threshold - 0.95).abs() < 1e-9);
assert!(c.strict_mode);Sourcepub fn lenient() -> Self
pub fn lenient() -> Self
A more forgiving preset: match_threshold = 0.65, phonetic matching on.
Use when triaging large candidate sets where false negatives are worse than false positives.
use thing_matcher::MatchConfig;
let c = MatchConfig::lenient();
assert!((c.match_threshold - 0.65).abs() < 1e-9);
assert!(c.use_phonetic_matching);Trait Implementations§
Source§impl Clone for MatchConfig
impl Clone for MatchConfig
Source§fn clone(&self) -> MatchConfig
fn clone(&self) -> MatchConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MatchConfig
impl Debug for MatchConfig
Source§impl Default for MatchConfig
impl Default for MatchConfig
Source§impl<'de> Deserialize<'de> for MatchConfigwhere
MatchConfig: Default,
impl<'de> Deserialize<'de> for MatchConfigwhere
MatchConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for MatchConfig
impl RefUnwindSafe for MatchConfig
impl Send for MatchConfig
impl Sync for MatchConfig
impl Unpin for MatchConfig
impl UnsafeUnpin for MatchConfig
impl UnwindSafe for MatchConfig
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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