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>
impl<L: ArcLabel> CompactLatticeWeight<L>
Sourcepub fn new(weight: LatticeWeight, alignment: Alignment<L>) -> Self
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.
Sourcepub fn from_weight(weight: LatticeWeight) -> Self
pub fn from_weight(weight: LatticeWeight) -> Self
A weight with no alignment yet.
Sourcepub fn weight(&self) -> &LatticeWeight
pub fn weight(&self) -> &LatticeWeight
The cost half.
Trait Implementations§
Source§impl<L: Clone + ArcLabel> Clone for CompactLatticeWeight<L>
impl<L: Clone + ArcLabel> Clone for CompactLatticeWeight<L>
Source§fn clone(&self) -> CompactLatticeWeight<L>
fn clone(&self) -> CompactLatticeWeight<L>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<L: ArcLabel> CommonDivisor<CompactLatticeWeight<L>> for CompactLatticeCommonDivisor
impl<L: ArcLabel> CommonDivisor<CompactLatticeWeight<L>> for CompactLatticeCommonDivisor
Source§fn divisor(
&self,
w1: &CompactLatticeWeight<L>,
w2: &CompactLatticeWeight<L>,
) -> CompactLatticeWeight<L>
fn divisor( &self, w1: &CompactLatticeWeight<L>, w2: &CompactLatticeWeight<L>, ) -> CompactLatticeWeight<L>
Source§impl<L: Default + ArcLabel> Default for CompactLatticeWeight<L>
impl<L: Default + ArcLabel> Default for CompactLatticeWeight<L>
Source§fn default() -> CompactLatticeWeight<L>
fn default() -> CompactLatticeWeight<L>
Source§impl<L: ArcLabel> Display for CompactLatticeWeight<L>
impl<L: ArcLabel> Display for CompactLatticeWeight<L>
Source§impl<L: ArcLabel> Divide for CompactLatticeWeight<L>
impl<L: ArcLabel> Divide for CompactLatticeWeight<L>
Source§fn divide(&self, rhs: &Self, side: DivideType) -> Self
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.
impl<L: ArcLabel> Eq for CompactLatticeWeight<L>
Source§impl<L: ArcLabel> FromStr for CompactLatticeWeight<L>
impl<L: ArcLabel> FromStr for CompactLatticeWeight<L>
Source§impl<L: ArcLabel> Hash for CompactLatticeWeight<L>
impl<L: ArcLabel> Hash for CompactLatticeWeight<L>
impl<L: ArcLabel> IdempotentWeight for CompactLatticeWeight<L>
impl<L: ArcLabel> LeftSemiring for CompactLatticeWeight<L>
Source§impl<L: ArcLabel> PartialEq for CompactLatticeWeight<L>
impl<L: ArcLabel> PartialEq for CompactLatticeWeight<L>
impl<L: ArcLabel> PathWeight for CompactLatticeWeight<L>
impl<L: ArcLabel> RightSemiring for CompactLatticeWeight<L>
Source§impl<L: ArcLabel> Weight for CompactLatticeWeight<L>
impl<L: ArcLabel> Weight for CompactLatticeWeight<L>
Source§fn type_name() -> WeightType
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>
type ReverseWeight = CompactLatticeWeight<L>
Source§fn zero() -> Self
fn zero() -> Self
plus).
Also represents a non-existent or invalid path (e.g., infinity for costs).Source§fn one() -> Self
fn one() -> Self
times).
Represents a zero-cost path.Source§fn no_weight() -> Self
fn no_weight() -> Self
Option<Self> to maintain strict memory layout performance
in graph algorithms.Source§fn properties() -> u64
fn properties() -> u64
Source§fn plus(&self, rhs: &Self) -> Self
fn plus(&self, rhs: &Self) -> Self
min(a, b) in Tropical, or -log(e^-a + e^-b) in Log).Source§fn reverse(&self) -> Self::ReverseWeight
fn reverse(&self) -> Self::ReverseWeight
self.Source§fn is_member(&self) -> bool
fn is_member(&self) -> bool
no_weight()).Source§fn approx_equal(&self, other: &Self, delta: f32) -> bool
fn approx_equal(&self, other: &Self, delta: f32) -> bool
other within delta.
For discrete weights (like Strings), delta is ignored.Auto Trait Implementations§
impl<L> Freeze for CompactLatticeWeight<L>
impl<L> RefUnwindSafe for CompactLatticeWeight<L>
impl<L> Send for CompactLatticeWeight<L>
impl<L> Sync for CompactLatticeWeight<L>
impl<L> Unpin for CompactLatticeWeight<L>
impl<L> UnsafeUnpin for CompactLatticeWeight<L>
impl<L> UnwindSafe for CompactLatticeWeight<L>
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.