FST  openfst-1.7.3
OpenFst Library
fstscript.h
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 //
4 // The FST script interface permits users to interact with FSTs without knowing
5 // their arc type. It does this by mapping compile-time polymorphism (in the
6 // form of a arc-templated FST types) onto a shared virtual interface. It also
7 // supports arc extension via a DSO interface. Due to the overhead of virtual
8 // dispatch and registered function lookups, the script API is somewhat slower
9 // then library API provided by types like StdVectorFst, but has the advantage
10 // that it is designed not to crash (and to provide useful debugging
11 // information) upon common user errors like passing invalid indices or
12 // attempting comparison of incompatible FSTs. It is used both by the FST
13 // binaries and the Python extension.
14 //
15 // This header includes all of the FST script functionality.
16 
17 #ifndef FST_SCRIPT_FSTSCRIPT_H_
18 #define FST_SCRIPT_FSTSCRIPT_H_
19 
20 // Major classes
23 #include <fst/script/fst-class.h>
25 #include <fst/script/text-io.h>
27 
28 // Flag-to-enum parsers.
29 #include <fst/script/getters.h>
30 // Templates like Operation<> and Apply<>.
31 #include <fst/script/script-impl.h>
32 
33 // Operations.
34 #include <fst/script/arcsort.h>
35 #include <fst/script/closure.h>
36 #include <fst/script/compile.h>
37 #include <fst/script/compose.h>
38 #include <fst/script/concat.h>
39 #include <fst/script/connect.h>
40 #include <fst/script/convert.h>
41 #include <fst/script/decode.h>
42 #include <fst/script/determinize.h>
43 #include <fst/script/difference.h>
45 #include <fst/script/draw.h>
46 #include <fst/script/encode.h>
48 #include <fst/script/equal.h>
49 #include <fst/script/equivalent.h>
50 #include <fst/script/info.h>
51 #include <fst/script/intersect.h>
52 #include <fst/script/invert.h>
53 #include <fst/script/isomorphic.h>
54 #include <fst/script/map.h>
55 #include <fst/script/minimize.h>
56 #include <fst/script/print.h>
57 #include <fst/script/project.h>
58 #include <fst/script/prune.h>
59 #include <fst/script/push.h>
61 #include <fst/script/randgen.h>
62 #include <fst/script/relabel.h>
63 #include <fst/script/replace.h>
64 #include <fst/script/reverse.h>
65 #include <fst/script/reweight.h>
66 #include <fst/script/rmepsilon.h>
69 #include <fst/script/synchronize.h>
70 #include <fst/script/topsort.h>
71 #include <fst/script/union.h>
72 #include <fst/script/verify.h>
73 
74 // This class is necessary because registering each of the operations
75 // separately overfills the stack, as there's so many of them.
76 namespace fst {
77 namespace script {
78 
79 template <class Arc>
81  public:
83  RegisterBatch1();
84  RegisterBatch2();
85  }
86 
87  private:
88  void RegisterBatch1() {
118  }
119 
120  void RegisterBatch2() {
146  }
147 };
148 
149 } // namespace script
150 } // namespace fst
151 
152 #define REGISTER_FST_OPERATIONS(Arc) \
153  AllFstOperationsRegisterer<Arc> register_all_fst_operations##Arc;
154 
155 #endif // FST_SCRIPT_FSTSCRIPT_H_
void Minimize(MinimizeArgs *args)
Definition: minimize.h:19
void Synchronize(SynchronizeArgs *args)
Definition: synchronize.h:18
void Decode(DecodeArgs1 *args)
Definition: decode.h:21
std::pair< MutableFstClass *, ArcSortType > ArcSortArgs
Definition: arcsort.h:20
std::tuple< const FstClass &, const FstClass &, MutableFstClass *, const ComposeOptions & > ComposeArgs
Definition: compose.h:16
void Encode(EncodeArgs1 *args)
Definition: encode.h:23
std::tuple< uint32, EncodeType, EncodeMapperClass * > InitEncodeMapperClassArgs
std::pair< MutableFstClass *, const EncodeMapperClass & > DecodeArgs2
Definition: decode.h:32
std::tuple< const FstClass &, bool, const std::string &, const std::string &, bool, FstInfo * > GetInfoArgs
Definition: info.h:34
void Equivalent(EquivalentArgs *args)
Definition: equivalent.h:22
std::tuple< const FstClass &, const FstClass &, MutableFstClass *, const ComposeOptions & > IntersectArgs
Definition: intersect.h:17
std::tuple< MutableFstClass *, MutableFstClass *, float, bool > MinimizeArgs
Definition: minimize.h:16
void Replace(ReplaceArgs *args)
Definition: replace.h:39
void EpsNormalize(EpsNormalizeArgs *args)
Definition: epsnormalize.h:19
std::tuple< const FstClass &, MutableFstClass *, time_t, const RandGenOptions< RandArcSelection > & > RandGenArgs
Definition: randgen.h:18
std::pair< const FstClass &, StateIteratorClass * > InitStateIteratorClassArgs
std::pair< const FstClass &, MutableFstClass * > SynchronizeArgs
Definition: synchronize.h:15
std::tuple< const FstClass &, MutableFstClass *, const WeightClass &, int64, float > PruneArgs1
Definition: prune.h:18
std::tuple< const FstClass &, bool, const std::string &, const std::string &, bool, bool > InfoArgs
Definition: info.h:18
std::tuple< const FstClass &, MutableFstClass *, const DeterminizeOptions & > DeterminizeArgs
Definition: determinize.h:38
void GetFstInfo(GetInfoArgs *args)
Definition: info.h:37
void ShortestPath(ShortestPathArgs *args)
void TopSort(TopSortArgs *args)
Definition: topsort.h:17
void Disambiguate(DisambiguateArgs *args)
Definition: disambiguate.h:36
std::tuple< MutableFstClass *, const WeightClass &, int64, float > PruneArgs2
Definition: prune.h:30
void RmEpsilon(RmEpsilonArgs *args)
Definition: rmepsilon.h:98
void Compose(ComposeArgs *args)
Definition: compose.h:19
REGISTER_FST_OPERATION(Compress, StdArc, CompressArgs)
void ArcSort(ArcSortArgs *args)
Definition: arcsort.h:23
void Intersect(IntersectArgs *args)
Definition: intersect.h:20
std::tuple< const FstClass &, const FstClass &, MutableFstClass *, const ComposeOptions & > DifferenceArgs
Definition: difference.h:17
std::tuple< MutableFstClass *, int64, MutableArcIteratorClass * > InitMutableArcIteratorClassArgs
std::tuple< MutableFstClass *, const std::vector< LabelPair > &, const std::vector< LabelPair > & > RelabelArgs2
Definition: relabel.h:35
std::tuple< MutableFstClass *, ReweightType, float, bool > PushArgs1
Definition: push.h:15
void Difference(DifferenceArgs *args)
Definition: difference.h:20
void InitEncodeMapperClass(InitEncodeMapperClassArgs *args)
void Verify(VerifyArgs *args)
Definition: verify.h:17
void PrintFstInfo(InfoArgs *args)
Definition: info.h:21
void Equal(EqualArgs *args)
Definition: equal.h:21
void Relabel(RelabelArgs1 *args)
Definition: relabel.h:24
std::pair< MutableFstClass *, const std::string & > DecodeArgs1
Definition: decode.h:18
std::tuple< MutableFstClass *, const SymbolTable *, const SymbolTable *, const std::string &, bool, const SymbolTable *, const SymbolTable *, const std::string &, bool > RelabelArgs1
Definition: relabel.h:21
std::pair< MutableFstClass *, const FstClass & > UnionArgs
Definition: union.h:15
void Invert(MutableFstClass *fst)
Definition: invert.h:14
void PrintFst(FstPrinterArgs *args)
Definition: print.h:52
std::tuple< const std::vector< LabelFstClassPair > &, MutableFstClass *, const ReplaceOptions & > ReplaceArgs
Definition: replace.h:36
void ShortestDistance(ShortestDistanceArgs1 *args)
std::pair< MutableFstClass *, EncodeMapperClass * > EncodeArgs2
Definition: encode.h:35
std::tuple< const FstClass &, MutableFstClass *, const ShortestPathOptions & > ShortestPathArgs
std::tuple< const FstClass &, MutableFstClass *, const DisambiguateOptions & > DisambiguateArgs
Definition: disambiguate.h:33
void Union(UnionArgs *args)
Definition: union.h:18
std::tuple< const FstClass &, MutableFstClass *, EpsNormalizeType > EpsNormalizeArgs
Definition: epsnormalize.h:16
std::pair< MutableFstClass *, ProjectType > ProjectArgs
Definition: project.h:15
std::tuple< MutableFstClass *, const std::vector< WeightClass > &, ReweightType > ReweightArgs
Definition: reweight.h:19
void Reweight(ReweightArgs *args)
Definition: reweight.h:22
std::tuple< const FstClass &, std::vector< WeightClass > *, bool, double > ShortestDistanceArgs2
void Reverse(ReverseArgs *args)
Definition: reverse.h:18
void Project(ProjectArgs *args)
Definition: project.h:18
void Prune(PruneArgs1 *args)
Definition: prune.h:21
void Push(PushArgs1 *args)
Definition: push.h:18
std::pair< const FstClass &, MutableFstClass * > ConcatArgs2
Definition: concat.h:24
std::tuple< MutableFstClass *, uint32, bool, const std::string & > EncodeArgs1
Definition: encode.h:20
void InitStateIteratorClass(InitStateIteratorClassArgs *args)
void RandGen(RandGenArgs *args)
Definition: randgen.h:21
std::pair< MutableFstClass *, const ClosureType > ClosureArgs
Definition: closure.h:15
void DrawFst(FstDrawerArgs *args)
Definition: draw.h:67
void Determinize(DeterminizeArgs *args)
Definition: determinize.h:41
void InitArcIteratorClass(InitArcIteratorClassArgs *args)
void Convert(ConvertArgs *args)
Definition: convert.h:23
void Map(MapArgs *args)
Definition: map.h:61
std::tuple< const FstClass &, std::vector< WeightClass > *, const ShortestDistanceOptions & > ShortestDistanceArgs1
void CompileFstInternal(CompileFstArgs *args)
Definition: compile.h:62
std::pair< MutableFstClass *, const RmEpsilonOptions & > RmEpsilonArgs
Definition: rmepsilon.h:95
std::tuple< const FstClass &, MutableFstClass *, uint32, ReweightType, float > PushArgs2
Definition: push.h:24
std::tuple< const FstClass &, int64, ArcIteratorClass * > InitArcIteratorClassArgs
void Connect(MutableFstClass *fst)
Definition: connect.h:14
std::tuple< const FstClass &, MutableFstClass *, bool > ReverseArgs
Definition: reverse.h:15
std::pair< MutableFstClass *, const FstClass & > ConcatArgs1
Definition: concat.h:15
void RandEquivalent(RandEquivalentArgs *args)
void Closure(ClosureArgs *args)
Definition: closure.h:18
void Concat(ConcatArgs1 *args)
Definition: concat.h:18
void InitMutableArcIteratorClass(InitMutableArcIteratorClassArgs *args)