Skip to main content

MatchConfig

Struct MatchConfig 

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

§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: f64

Threshold score for considering two things a match (0.0..=1.0).

§name_weight: f64

Weight for name similarity (best-of cartesian product across the primary name and alternate_names on both sides).

§description_weight: f64

Weight for free-form description similarity.

§disambiguating_description_weight: f64

Weight for disambiguatingDescription similarity.

§identifiers_weight: f64

Weight for “shared identifier” (1.0 if any (property_id, value) pair is shared, 0.0 otherwise).

§url_weight: f64

Weight for canonical url exact match (after URL normalisation).

§same_as_weight: f64

Weight for sameAs URL set similarity (Jaccard).

§image_weight: f64

Weight for image URL exact match (after URL normalisation).

§main_entity_of_page_weight: f64

Weight for mainEntityOfPage URL exact match (after URL normalisation).

§additional_types_weight: f64

Weight for additionalType URI set similarity (Jaccard).

§use_phonetic_matching: bool

Whether to add a phonetic-name bonus when both names sound alike.

§name_algorithm: SimilarityAlgorithm

Similarity algorithm to use when comparing names.

§strict_mode: bool

Reserved flag for stricter deterministic enforcement.

Implementations§

Source§

impl MatchConfig

Source

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

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

Source§

fn clone(&self) -> MatchConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MatchConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MatchConfig

Source§

fn default() -> Self

Production-ready defaults.

use thing_matcher::{MatchConfig, SimilarityAlgorithm};
let c = MatchConfig::default();
assert!((c.match_threshold - 0.80).abs() < 1e-9);
assert!(matches!(c.name_algorithm, SimilarityAlgorithm::Combined));
Source§

impl<'de> Deserialize<'de> for MatchConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for MatchConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,