FST  openfst-1.7.8
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() {
116  }
117 
118  void RegisterBatch2() {
144  }
145 };
146 
147 } // namespace script
148 } // namespace fst
149 
150 #define REGISTER_FST_OPERATIONS(Arc) \
151  AllFstOperationsRegisterer<Arc> register_all_fst_operations##Arc;
152 
153 #endif // FST_SCRIPT_FSTSCRIPT_H_
void Minimize(MinimizeArgs *args)
Definition: minimize.h:19
void Union(UnionArgs1 *args)
Definition: union.h:19
void Synchronize(SynchronizeArgs *args)
Definition: synchronize.h:18
std::pair< MutableFstClass *, ArcSortType > ArcSortArgs
Definition: arcsort.h:17
std::tuple< const FstClass &, const FstClass &, MutableFstClass *, const ComposeOptions & > ComposeArgs
Definition: compose.h:16
std::tuple< MutableFstClass *, EncodeMapperClass * > EncodeArgs
Definition: encode.h:17
void Equivalent(EquivalentArgs *args)
Definition: equivalent.h:22
std::tuple< const FstClass &, const FstClass &, MutableFstClass *, const ComposeOptions & > IntersectArgs
Definition: intersect.h:17
std::pair< const std::vector< FstClass * > &, MutableFstClass * > ConcatArgs3
Definition: concat.h:34
std::tuple< MutableFstClass *, MutableFstClass *, float, bool > MinimizeArgs
Definition: minimize.h:16
void Replace(ReplaceArgs *args)
Definition: replace.h:39
void Draw(DrawArgs *args)
Definition: draw.h:65
void EpsNormalize(EpsNormalizeArgs *args)
Definition: epsnormalize.h:19
std::tuple< const FstClass &, MutableFstClass *, const RandGenOptions< RandArcSelection > &, uint64 > RandGenArgs
Definition: randgen.h:20
std::pair< const FstClass &, StateIteratorClass * > InitStateIteratorClassArgs
void Print(PrintArgs *args)
Definition: print.h:50
std::pair< const FstClass &, MutableFstClass * > SynchronizeArgs
Definition: synchronize.h:15
std::tuple< const FstClass &, MutableFstClass *, const WeightClass &, int64, float > PruneArgs1
Definition: prune.h:18
void Isomorphic(IsomorphicArgs *args)
Definition: isomorphic.h:22
std::tuple< const FstClass &, MutableFstClass *, const DeterminizeOptions & > DeterminizeArgs
Definition: determinize.h:38
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:99
void Compose(ComposeArgs *args)
Definition: compose.h:19
std::tuple< const FstClass &, MutableFstClass *, uint8, ReweightType, float > PushArgs2
Definition: push.h:25
void ArcSort(ArcSortArgs *args)
Definition: arcsort.h:20
void Encode(EncodeArgs *args)
Definition: encode.h:20
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 *, ReweightType, float, bool > PushArgs1
Definition: push.h:16
void Difference(DifferenceArgs *args)
Definition: difference.h:20
void Verify(VerifyArgs *args)
Definition: verify.h:17
std::tuple< const std::vector< std::pair< int64, const FstClass * >> &, MutableFstClass *, const ReplaceOptions & > ReplaceArgs
Definition: replace.h:36
void Equal(EqualArgs *args)
Definition: equal.h:21
void Relabel(RelabelArgs1 *args)
Definition: relabel.h:25
std::tuple< MutableFstClass *, const SymbolTable *, const SymbolTable *, const std::string &, bool, const SymbolTable *, const SymbolTable *, const std::string &, bool > RelabelArgs1
Definition: relabel.h:22
void Invert(MutableFstClass *fst)
Definition: invert.h:14
std::pair< MutableFstClass *, const EncodeMapperClass & > DecodeArgs
Definition: decode.h:17
void ShortestDistance(ShortestDistanceArgs1 *args)
std::tuple< MutableFstClass *, const std::vector< std::pair< int64, int64 >> &, const std::vector< std::pair< int64, int64 >> & > RelabelArgs2
Definition: relabel.h:34
REGISTER_FST_OPERATION(OpenFarReaderClass, StdArc, OpenFarReaderClassArgs)
void Info(InfoArgs *args)
Definition: info.h:21
std::tuple< const FstClass &, MutableFstClass *, const ShortestPathOptions & > ShortestPathArgs
Definition: shortest-path.h:99
std::tuple< const FstClass &, MutableFstClass *, const DisambiguateOptions & > DisambiguateArgs
Definition: disambiguate.h:33
std::pair< MutableFstClass *, const FstClass & > UnionArgs1
Definition: union.h:16
std::tuple< const FstClass &, MutableFstClass *, EpsNormalizeType > EpsNormalizeArgs
Definition: epsnormalize.h:16
std::tuple< const FstClass &, bool, const std::string &, const std::string &, bool > InfoArgs
Definition: info.h:18
std::pair< MutableFstClass *, ProjectType > ProjectArgs
Definition: project.h:15
std::tuple< MutableFstClass *, const std::vector< WeightClass > &, ReweightType > ReweightArgs
Definition: reweight.h:19
std::tuple< MutableFstClass *, const std::vector< const FstClass * > & > UnionArgs2
Definition: union.h:26
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:19
std::pair< const FstClass &, MutableFstClass * > ConcatArgs2
Definition: concat.h:24
void InitStateIteratorClass(InitStateIteratorClassArgs *args)
void RandGen(RandGenArgs *args)
Definition: randgen.h:23
std::pair< MutableFstClass *, const ClosureType > ClosureArgs
Definition: closure.h:15
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
void Decode(DecodeArgs *args)
Definition: decode.h:20
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:96
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)