41 std::string usage =
"Reweights an FST.\n\n Usage: ";
43 usage +=
" in.fst potential.txt [out.fst]\n";
45 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
46 if (argc < 3 || argc > 4) {
51 const std::string in_name = argv[1];
52 const std::string potentials_name = argv[2];
53 const std::string out_name = argc > 3 ? argv[3] :
"";
55 std::unique_ptr<MutableFstClass>
fst(MutableFstClass::Read(in_name,
true));
58 std::vector<WeightClass> potential;
65 LOG(ERROR) << argv[0] <<
": Unknown or unsupported reweight type: " 66 << FST_FLAGS_reweight_type;
72 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)