33 ,
bool detOut,
bool minimize,
bool exitOnFirstPassFailure
40 , exitOnFirstPassFailure_(exitOnFirstPassFailure)
41 , useOpenFst_(useOpenFst)
48 , minimize_(df.minimize_)
49 , exitOnFirstPassFailure_(df.exitOnFirstPassFailure_)
51 , useOpenFst_(df.useOpenFst_)
59 boost::scoped_ptr<fst::VectorFst<ArcT> >mfst
60 (fst::VectorFstRead<ArcT> ( in_ ) );
61 if (mfst->NumStates()) {
67 std::string ns =
toString(mfst->NumStates());
71 LINFO(
"Only determinize");
75 LINFO(
"Determinize, Minimize and Push!");
80 ssd_.
setTimeEnd(
"disambig-" + out_ +
", NS=" + ns);
81 std::string nsd =
toString(mfst->NumStates());
82 FORCELINFO(out_ <<
": NS=" << ns <<
",NSD=" << nsd);
87 #if OPENFSTVERSION >= 1004001 88 LINFO(
"Openfst Determinize...");
89 DeterminizeFstOptions<ArcT> dto;
90 #if OPENFSTVERSION >= 1005000 91 dto.type = DETERMINIZE_DISAMBIGUATE;
93 dto.disambiguate_output =
true;
95 *mfst = DeterminizeFst<ArcT>(*mfst, dto);
97 LERROR(
"Openfst Determinize for non-functional FSTs is not supported (" 101 ssd_.
setTimeEnd(
"disambig-" + out_ +
", NS=" + ns);
105 ssd_.
setTimeEnd(
"disambig-" + out_ +
", NS=0");
110 FstWrite<StdArc> (*mfst,
out_ );
111 ssd_.
write(std::cerr);
118 template<
class ArcT,
class ThreadPoolT >
135 , detOut, minimize, exitOnFirstPassFailure
148 unsigned nthreads = (rg_->exists(
kNThreads) )
153 FORCELINFO(
"Multithreading with " << nthreads <<
" threads");
155 ::run<fst::StdArc, TrivialThreadPool>(*rg_, tp);
158 ::run<fst::StdArc, NoThreadPool>(*rg_, ntp);
161 LERROR(
"Unknown semiring!");
std::string const kHifstSemiring
bool const exitOnFirstPassFailure_
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
std::string toString(const T &x, uint pr=2)
Converts an arbitrary type to string Converts to string integers, floats, doubles Quits execution if ...
#define LDBG_EXECUTE(order)
T get(const std::string &key) const
Returns parsed value associated to key.
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
void run()
Include all necessary headers here.
Trivial implementation of a threadpool based on boost::asio methods When initiated, creates a threadpool of n threads (n <= number of cpus). Jobs should be submitted with the templated operator(). When the object is deleted it will wait for all threads to finish.
std::string const kOutput
ucam::fsttools::SpeedStatsData ssd_
std::string const kExitOnFirstPassFailure
Trivial struct that can replace seamlessly the threadpool for single threaded executions.
std::string const kDeterminizeOutput
std::string const kHifstSemiringStdArc
Static variables for logger. Include only once from main file.
const std::string kNThreads
std::string const kUseOpenFst
bool getBool(const std::string &key) const
To handle yes|no program option values.
void run(ucam::util::RegistryPO const &rg, ThreadPoolT &tp)
DisambigFunctor(DisambigFunctor const &df)
DisambigFunctor(std::string const &in, std::string const &out, bool detOut, bool minimize, bool exitOnFirstPassFailure, bool useOpenFst)
const std::string kRangeOne
Included headers for all the binary should be defined here. This file should be included only once...
std::string const kMinimize
Static variable for custom_assert. Include only once from main file.