45 std::string usage =
"Generates random paths through an FST.\n\n Usage: ";
47 usage +=
" [in.fst [out.fst]]\n";
49 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
55 const std::string in_name =
56 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
57 const std::string out_name =
58 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
60 std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
63 VectorFstClass ofst(ifst->ArcType());
67 LOG(ERROR) << argv[0] <<
": Unknown or unsupported select type " 73 VLOG(1) << argv[0] <<
": Seed = " << seed;
76 RandGenOptions<s::RandArcSelection>(
77 ras, FST_FLAGS_max_length,
78 FST_FLAGS_npath, FST_FLAGS_weighted,
79 FST_FLAGS_remove_total_weight),
82 return !ofst.Write(out_name);
void ShowUsage(bool long_usage=true)
bool GetRandArcSelection(std::string_view str, RandArcSelection *ras)
int fstrandgen_main(int argc, char **argv)
#define SET_FLAGS(usage, argc, argv, rmflags)
uint64_t GetSeed(uint64_t seed)
void RandGen(const Fst< FromArc > &ifst, MutableFst< ToArc > *ofst, const RandGenOptions< Selector > &opts)
DECLARE_int32(max_length)