15 #ifndef TASK_OPTIMIZEFST_HPP 16 #define TASK_OPTIMIZEFST_HPP 32 template <
class Data,
class Arc = fst::StdArc >
34 typedef typename Arc::Label Label;
35 typedef typename Arc::Weight Weight;
41 bool stripHifstEpsilons_;
46 ,
const std::string& fstkey
47 ,
const std::string stripEps
50 , stripHifstEpsilons_(rg.getBool (stripEps) )
52 if (!stripHifstEpsilons_)
return;
63 ,
const std::string& optimizefstkey
64 ,
const std::string& fstkey
65 ,
const std::string& stripepskey
67 if ( rg.
getBool ( optimizefstkey ) )
79 inline bool run ( Data& d ) {
81 VectorFst<Arc> *auxfst = d.getFst(fstkey_);
83 LERROR(
"Lattice " << d.sidx <<
"not available under key " << fstkey_);
86 std::string parenskey = fstkey_ +
".parens";
87 if ( d.fsts.find ( parenskey ) != d.fsts.end() ) {
88 LWARN(
"Skipping optimization! PDTs are, in general, non-determinizable.");
91 if (stripHifstEpsilons_) {
96 Determinize(RmEpsilonFst<Arc>(*auxfst), auxfst);
#define ZDISALLOW_COPY_AND_ASSIGN(TypeName)
RelabelUtil & addIPL(typename Arc::Label labelfind, typename Arc::Label labelreplace)
Templated (hybrid) Interface for Task classes.
Utility functor for relabeling one or more lattices. Note that you can chain commands. See Unit test in fstutils.gtest.cpp for an example.
bool getBool(const std::string &key) const
To handle yes|no program option values.