This example is from here.
In the tokenization example, it uses the following commands:
fstdraw: Draw FST using symbol table files and Graphviz dot
fstunion: Compute the union of two fsts.
fstclosure: Compute the concatenative closure of a fst.
fstrmepsilon: Remove epsilon-transitions (when both the input and output label are an epsilon) from a transducer.
fstdeterminize: The result will be an equivalent FST that has the property that no state has two transitions with the same input label.
fstminimize: Perform the minimization of deterministic weighted automata and transducers.
First, we create three fst files using fstcompile:
fstcompile --isymbols=ascii.syms --osymbols=wotw.syms > Mars.fst << EOF
> 0 1 M Mars
> 1 2 a <epsilon>
> 2 3 r <epsilon>
> 3 4 s <epsilon>
> 4
> EOF
fstcompile --isymbols=ascii.syms --osymbols=wotw.syms > Martian.fst << EOF
> 0 1 M Martian
> 1 2 a <epsilon>
> 2 3 r <epsilon>
> 3 4 t <epsilon>
> 4 5 i <epsilon>
> 5 6 a <epsilon>
> 6 7 n <epsilon>
> 7
> EOF
fstcompile --isymbols=ascii.syms --osymbols=wotw.syms > man.fst << EOF
> 0 1 m man
> 1 2 a <epsilon>
> 2 3 n <epsilon>
> 3
> EOF
Then, run fstunion to compute the union of three fsts. And use fstclosure to compute the concatenative closure.
fstunion man.fst Mars.fst | fstunion - Martian.fst | fstclosure > lexicon.fst
Simplify fst using fstrmepsilon, fstdeterminize, and fstminimize.
fstrmepsilon lexicon.fst | fstdeterminize | fstminimize > lexicon_opt.fst
Print final output: lexicon_opt.fst
fstprint --isymbols=ascii.syms --osymbols=wotw.syms lexicon_opt.fst | head