pub struct Measure { /* private fields */ }Expand description
Node similarity measurement calculator.
This struct calculates the content, child list and matched child list distance between nodes using the Q-gram distance algorithm.
Implementations§
Source§impl Measure
impl Measure
Sourcepub fn get_distance(&mut self, a: Option<&NodeRef>, b: Option<&NodeRef>) -> f64
pub fn get_distance(&mut self, a: Option<&NodeRef>, b: Option<&NodeRef>) -> f64
Returns content distance between nodes.
The distance is normalized between 0.0 and 1.0 (MAX_DIST). Returns 1.0 if node types are incompatible (element vs text).
Sourcepub fn string_dist_str(&mut self, a: &str, b: &str) -> i32
pub fn string_dist_str(&mut self, a: &str, b: &str) -> i32
Calculates string distance using Q-gram algorithm.
Sourcepub fn string_dist_chars(&mut self, a: &[char], b: &[char]) -> i32
pub fn string_dist_chars(&mut self, a: &[char], b: &[char]) -> i32
Calculates string distance for char arrays using Q-gram algorithm.
Sourcepub fn child_list_distance(&mut self, a: &NodeRef, b: &NodeRef) -> f64
pub fn child_list_distance(&mut self, a: &NodeRef, b: &NodeRef) -> f64
Calculates child list distance between nodes.
This compares children by their content hashes to measure structural similarity. Returns ZERO_CHILDREN_MATCH (1.0) if both nodes have no children.
Sourcepub fn matched_child_list_distance(
&mut self,
base: &NodeRef,
branch: &NodeRef,
_is_left: bool,
) -> i32
pub fn matched_child_list_distance( &mut self, base: &NodeRef, branch: &NodeRef, _is_left: bool, ) -> i32
Calculates matched child list distance.
This measures how well children of a base node match children of a branch node, based on their matching relationships (not content hashes).
§Arguments
base- The base nodebranch- The branch node_is_left- Whether the branch is the left branch (unused, for API compatibility)