23 #include <fst/flags.h> 28 #include <fst/vector-fst.h> 33 "Specifies failure label (default: none)");
34 DEFINE_int32(max_length, INT_MAX,
"Maximum path length");
38 "Output tree weighted by path count vs. unweighted paths");
40 "Remove total weight when output weighted");
42 "Epsilon/phi-remove and minimize when output is weighted");
44 "Same as --weighted --remove_total_weight --minimal");
47 int main(
int argc,
char **argv) {
49 std::string usage =
"Generates random paths through an LM.\n\n Usage: ";
51 usage +=
" [in.fst [out.fst]]\n";
53 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
54 if (FST_FLAGS_stochastic) {
62 VLOG(1) << argv[0] <<
": Seed = " << FST_FLAGS_seed;
65 (argc > 1 && (strcmp(argv[1],
"-") != 0)) ? argv[1] :
"";
66 std::string out_name = argc > 2 ? argv[2] :
"";
68 f::StdFst *ifst = f::StdFst::Read(in_name);
72 LOG(ERROR) << argv[0] <<
": Input is not a normalized stochastic FST";
80 f::RandGenOptions<sfst::SFstArcSelector<f::StdArc>> opts(
81 selector, FST_FLAGS_max_length, FST_FLAGS_npath,
82 FST_FLAGS_weighted, FST_FLAGS_remove_total_weight);
83 f::RandGen(*ifst, &ofst, opts);
84 if (FST_FLAGS_weighted && FST_FLAGS_minimal)
86 if (!ofst.Write(out_name))
DEFINE_bool(weighted, false,"Output tree weighted by path count vs. unweighted paths")
void RandMinimize(MutableFst< A > *fst, typename A::Label phi_label)
DEFINE_int32(max_length, INT_MAX,"Maximum path length")
bool IsNormalized(const fst::Fst< Arc > &fst, typename Arc::Label phi_label=fst::kNoLabel, float delta=fst::kDelta)
int main(int argc, char **argv)
DEFINE_int64(phi_label, fst::kNoLabel,"Specifies failure label (default: none)")