Skip to main content

FromScore

Trait FromScore 

Source
pub trait FromScore: Weight {
    // Required methods
    fn from_cost(cost: f32) -> Self;
    fn to_cost(&self) -> f32;
}
Expand description

A weight that can be built from one acoustic score.

The scores are costs, that is, negative log probabilities where smaller is better, which is already what both the tropical and the log semiring mean by a weight’s value. Keeping the trait rather than hard-wiring TropicalWeight lets the same decoder run Viterbi (tropical) and forward-sum (log) without a second implementation.

Required Methods§

Source

fn from_cost(cost: f32) -> Self

The weight for a score of cost nats.

Source

fn to_cost(&self) -> f32

The score back out, for a decoder that wants to compare in f32.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl FromScore for Log64Weight

Source§

fn from_cost(cost: f32) -> Self

Source§

fn to_cost(&self) -> f32

Source§

impl FromScore for LogWeight

Source§

fn from_cost(cost: f32) -> Self

Source§

fn to_cost(&self) -> f32

Source§

impl FromScore for TropicalWeight

Source§

fn from_cost(cost: f32) -> Self

Source§

fn to_cost(&self) -> f32

Source§

impl FromScore for TropicalWeight64

Source§

fn from_cost(cost: f32) -> Self

Source§

fn to_cost(&self) -> f32

Implementors§