Skip to main content

CompactLatticeWeight

Struct CompactLatticeWeight 

Source
pub struct CompactLatticeWeight<L: ArcLabel> { /* private fields */ }
Expand description

A cost and the input labels that earned it.

Implementations§

Source§

impl<L: ArcLabel> CompactLatticeWeight<L>

Source

pub fn new(weight: LatticeWeight, alignment: Alignment<L>) -> Self

A weight from its cost and its alignment.

The empty alignment is forced when the cost is zero(): a semiring has exactly one zero, and (zero, [5]) would be a second one. It would absorb under ⊗ and lose under ⊕ exactly as (zero, []) does, but be unequal to it, so every algorithm that compares against zero() would miss it.

Source

pub fn from_weight(weight: LatticeWeight) -> Self

A weight with no alignment yet.

Source

pub fn weight(&self) -> &LatticeWeight

The cost half.

Source

pub fn alignment(&self) -> &[L]

The input labels this weight spans, in order.

Trait Implementations§

Source§

impl<L: Clone + ArcLabel> Clone for CompactLatticeWeight<L>

Source§

fn clone(&self) -> CompactLatticeWeight<L>

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<L: ArcLabel> CommonDivisor<CompactLatticeWeight<L>> for CompactLatticeCommonDivisor

Source§

fn divisor( &self, w1: &CompactLatticeWeight<L>, w2: &CompactLatticeWeight<L>, ) -> CompactLatticeWeight<L>

Combines a running divisor with one more member’s weight.
Source§

impl<L: Debug + ArcLabel> Debug for CompactLatticeWeight<L>

Source§

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

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

impl<L: Default + ArcLabel> Default for CompactLatticeWeight<L>

Source§

fn default() -> CompactLatticeWeight<L>

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

impl<L: ArcLabel> Display for CompactLatticeWeight<L>

Source§

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

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

impl<L: ArcLabel> Divide for CompactLatticeWeight<L>

Source§

fn divide(&self, rhs: &Self, side: DivideType) -> Self

Undoes a ⊗ from one side: the costs subtract and the alignment gives back the part rhs did not contribute.

SICADA-DIVERGE: upstream aborts the process on every case this returns Weight::no_weight for: dividing by zero, an alignment rhs is not a prefix or suffix of, or DivideType::Any, which has no answer when ⊗ does not commute. sicada already has a value for “this division has no result”, and the algorithms that divide already test for it, so there is nothing to gain by stopping.

Source§

impl<L: ArcLabel> Eq for CompactLatticeWeight<L>

Source§

impl<L: ArcLabel> FromStr for CompactLatticeWeight<L>

Source§

type Err = String

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<L: ArcLabel> Hash for CompactLatticeWeight<L>

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<L: ArcLabel> IdempotentWeight for CompactLatticeWeight<L>

Source§

impl<L: ArcLabel> LeftSemiring for CompactLatticeWeight<L>

Source§

impl<L: ArcLabel> PartialEq for CompactLatticeWeight<L>

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl<L: ArcLabel> PathWeight for CompactLatticeWeight<L>

Source§

impl<L: ArcLabel> RightSemiring for CompactLatticeWeight<L>

Source§

impl<L: ArcLabel> Weight for CompactLatticeWeight<L>

Source§

fn type_name() -> WeightType

Kaldi’s name for this weight, as recorded in an FST file header.

It carries the sizes: "compact", then the inner weight’s name ("lattice4" for a pair of f32), then the width of one alignment label in bytes. So a lattice over i32 labels is compactlattice44, and one over i64 labels is compactlattice48.

Source§

type ReverseWeight = CompactLatticeWeight<L>

The type returned by reversing this weight (used for Reverse FST operations).
Source§

fn zero() -> Self

The semiring’s zero element (identity for plus). Also represents a non-existent or invalid path (e.g., infinity for costs).
Source§

fn one() -> Self

The semiring’s one element (identity for times). Represents a zero-cost path.
Source§

fn no_weight() -> Self

Represents an invalid weight (often represented by NaN internally). Used instead of Option<Self> to maintain strict memory layout performance in graph algorithms.
Source§

fn properties() -> u64

A bitmask of the semiring properties (e.g., LEFT_SEMIRING | COMMUTATIVE).
Source§

fn plus(&self, rhs: &Self) -> Self

Semiring addition (e.g., min(a, b) in Tropical, or -log(e^-a + e^-b) in Log).
Source§

fn times(&self, rhs: &Self) -> Self

Semiring multiplication (e.g., a + b in Tropical/Log).
Source§

fn reverse(&self) -> Self::ReverseWeight

Returns the reversed weight. For commutative weights, this is typically self.
Source§

fn is_member(&self) -> bool

Returns true if this is a valid member of the semiring (not no_weight()).
Source§

fn approx_equal(&self, other: &Self, delta: f32) -> bool

Returns true if this weight is approximately equal to other within delta. For discrete weights (like Strings), delta is ignored.
Source§

fn quantize(&self, delta: f32) -> Self

Quantizes the weight to the nearest multiple of delta. Essential for epsilon-removal and equivalence testing with floating-point weights.
Source§

impl<L: ArcLabel + FstScalar> WeightIo for CompactLatticeWeight<L>

The bytes Kaldi’s CompactLatticeWeightTpl::Write produces: the cost, then the alignment’s length as an i32, then the labels.

Source§

fn read<R: Read>(reader: &mut R) -> Result<Self>

Reads one weight.
Source§

fn write<W: Write>(&self, writer: &mut W) -> Result<()>

Writes one weight.

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

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> Same for T

Source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.