// See www.openfst.org for extensive documentation on this weighted // finite-state transducer library. #ifndef FST_SCRIPT_RANDGEN_H_ #define FST_SCRIPT_RANDGEN_H_ #include #include #include #include #include namespace fst { namespace script { using RandGenArgs = std::tuple &>; template void RandGen(RandGenArgs *args) { const Fst &ifst = *(std::get<0>(*args).GetFst()); MutableFst *ofst = std::get<1>(*args)->GetMutableFst(); const time_t seed = std::get<2>(*args); const auto &opts = std::get<3>(*args); switch (opts.selector) { case UNIFORM_ARC_SELECTOR: { const UniformArcSelector selector(seed); const RandGenOptions> ropts( selector, opts.max_length, opts.npath, opts.weighted, opts.remove_total_weight); RandGen(ifst, ofst, ropts); return; } case FAST_LOG_PROB_ARC_SELECTOR: { const FastLogProbArcSelector selector(seed); const RandGenOptions> ropts( selector, opts.max_length, opts.npath, opts.weighted, opts.remove_total_weight); RandGen(ifst, ofst, ropts); return; } case LOG_PROB_ARC_SELECTOR: { const LogProbArcSelector selector(seed); const RandGenOptions> ropts( selector, opts.max_length, opts.npath, opts.weighted, opts.remove_total_weight); RandGen(ifst, ofst, ropts); return; } } } void RandGen(const FstClass &ifst, MutableFstClass *ofst, time_t seed = time(nullptr), const RandGenOptions &opts = RandGenOptions(UNIFORM_ARC_SELECTOR)); } // namespace script } // namespace fst #endif // FST_SCRIPT_RANDGEN_H_