Function rustfst::algorithms::compose::compose

source ·
pub fn compose<W: Semiring, F1: ExpandedFst<W>, F2: ExpandedFst<W>, F3: MutableFst<W> + AllocableFst<W>, B1: Borrow<F1> + Debug + Clone, B2: Borrow<F2> + Debug + Clone>(
    fst1: B1,
    fst2: B2
) -> Result<F3>
Expand description

This operation computes the composition of two transducers. If A transduces string x to y with weight a and B transduces y to z with weight b, then their composition transduces string x to z with weight a ⊗ b.

§Example

let fst_1 : VectorFst<IntegerWeight> = fst![1,2 => 2,3];

let fst_2 : VectorFst<IntegerWeight> = fst![2,3 => 3,4];

let fst_ref : VectorFst<IntegerWeight> = fst![1,2 => 3,4];

let composed_fst : VectorFst<_> = compose(fst_1, fst_2)?;
assert_eq!(composed_fst, fst_ref);