Function rustfst::algorithms::invert

source ·
pub fn invert<F: ExpandedFst + MutableFst>(fst: &mut F) -> Result<(), Error>
Expand description

This operation inverts the transduction corresponding to an FST by exchanging the FST’s input and output labels.

Example

use rustfst::utils::{acceptor, transducer};
use rustfst::semirings::{Semiring, IntegerWeight};
use rustfst::fst_impls::VectorFst;
use rustfst::algorithms::invert;

let mut fst : VectorFst<IntegerWeight> = transducer(vec![2].into_iter(), vec![3].into_iter()).unwrap();
invert(&mut fst).unwrap();

assert_eq!(fst, transducer(vec![3].into_iter(), vec![2].into_iter()).unwrap());