38 std::string usage =
"Reweights an FST.\n\n Usage: ";
40 usage +=
" in.fst potential.txt [out.fst]\n";
43 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
44 if (argc < 3 || argc > 4) {
49 const std::string in_name = argv[1];
50 const std::string potentials_name = argv[2];
51 const std::string out_name = argc > 3 ? argv[3] :
"";
53 std::unique_ptr<MutableFstClass>
fst(MutableFstClass::Read(in_name,
true));
56 std::vector<WeightClass> potential;
63 LOG(ERROR) << argv[0] <<
": Unknown or unsupported reweight type: " 64 << FST_FLAGS_reweight_type;
70 return !fst->Write(out_name);
void ShowUsage(bool long_usage=true)
int fstreweight_main(int argc, char **argv)
DECLARE_string(reweight_type)
#define SET_FLAGS(usage, argc, argv, rmflags)
bool ReadPotentials(std::string_view weight_type, const std::string &source, std::vector< WeightClass > *potentials)
bool GetReweightType(std::string_view str, ReweightType *reweight_type)
void Reweight(MutableFst< Arc > *fst, const std::vector< typename Arc::Weight > &potential, ReweightType type)