[][src]Macro rustfst::fst

macro_rules! fst {
    ( $( $x:expr ),* ) => { ... };
    ( $( $x:expr ),* => $( $y:expr ),* ) => { ... };
    ( $( $x:expr ),* ; $weight:expr ) => { ... };
    ( $( $x:expr ),* => $( $y:expr ),* ; $weight:expr ) => { ... };
}

Creates a linear Fst containing the arguments.

There are multiple forms to this macro :

  • Create an unweighted linear acceptor :

This will return a linear FST with one transition for each label given (same input and output, weight one).

let fst : VectorFst<ProbabilityWeight> = fst![1,2,3];
assert_eq!(fst.paths_iter().count(), 1);
assert_eq!(fst.paths_iter().next().unwrap(), fst_path![1,2,3]);
  • Create an unweighted linear transducer from two list of labels :

The only accepted path in the FST has for input the first list of labels and for output the second list of labels.

let fst : VectorFst<ProbabilityWeight> = fst![1,2,3 => 1,2,4];
assert_eq!(fst.paths_iter().count(), 1);
assert_eq!(fst.paths_iter().next().unwrap(), fst_path![1,2,3 => 1,2,4]);
  • Create a weighted linear acceptor :

This will return a linear FST with one transition for each label given (same input and output, weight one).

let fst : VectorFst<ProbabilityWeight> = fst![1,2,3; 0.2];
assert_eq!(fst.paths_iter().count(), 1);
assert_eq!(fst.paths_iter().next().unwrap(), fst_path![1,2,3; 0.2]);
  • Create a weighted linear transducer from two list of labels and a weight :

The only accepted path in the FST has for input the first list of labels and for output the second list of labels.

let fst : VectorFst<ProbabilityWeight> = fst![1,2,3 => 1,2,4; 0.2];
assert_eq!(fst.paths_iter().count(), 1);
assert_eq!(fst.paths_iter().next().unwrap(), fst_path![1,2,3 => 1,2,4; 0.2]);