Skip to main content

CharacteristicVector

Struct CharacteristicVector 

Source
pub struct CharacteristicVector {
    pub counts: [u32; 23],
    pub max_depth: u32,
    pub node_count: u32,
}
Expand description

Shape-tag counts plus tree size and depth: a candidate filter.

The count vector is a cheap lower-bound proxy for tree edit distance: two subtrees within edit distance d differ by at most 2 * d in L1 count distance, so a large CharacteristicVector::l1_distance rules a pair out without touching either tree. That is what CharacteristicVector::shape_divergence gates candidate pairs on, and what CharacteristicVector::cosine_similarity contributes to the structural dimension of a verdict.

Fields§

§counts: [u32; 23]

Node count per shape tag; index = tag, index 0 unused.

§max_depth: u32

Number of nodes on the longest root-to-leaf path of the unit subtree; a lone node has depth 1.

§node_count: u32

Total number of nodes in the unit subtree.

Implementations§

Source§

impl CharacteristicVector

Source

pub fn l1_distance(&self, other: &Self) -> u64

L1 distance between the two count vectors. Depth and node count do not participate.

Source

pub fn shape_divergence(&self, other: &Self) -> f64

How far apart the two shape mixes are, on a 0.01.0 scale: the L1 count distance over the nodes the two units have between them. 0.0 when they hold the same shapes in the same numbers, 1.0 when they share no shape at all. 0.0 for two empty vectors, which are not divergent — they are simply nothing to tell apart.

Size is part of it, and deliberately so: the vectors sum to their unit node counts, so the distance is at least |na - nb| / (na + nb) and a pair whose sizes differ by a factor of r scores at least (r - 1) / (r + 1) before any difference in shape mix is counted. A limit of 0.5 therefore says exactly what max_length_ratio’s 3.0 says about size, and says it about the shape mix too.

Source

pub fn cosine_similarity(&self, other: &Self) -> f64

Cosine similarity of the two count vectors, 0.0 when either vector is all-zero. Depth and node count do not participate.

Trait Implementations§

Source§

impl Clone for CharacteristicVector

Source§

fn clone(&self) -> CharacteristicVector

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 CharacteristicVector

Source§

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

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

impl Default for CharacteristicVector

Source§

fn default() -> CharacteristicVector

Returns the “default value” for a type. Read more
Source§

impl Eq for CharacteristicVector

Source§

impl PartialEq for CharacteristicVector

Source§

fn eq(&self, other: &CharacteristicVector) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CharacteristicVector

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. 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.