45 std::string usage =
"Pushes weights and/or olabels in 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));
64 FST_FLAGS_push_labels,
65 FST_FLAGS_remove_total_weight,
66 FST_FLAGS_remove_common_affix);
68 VectorFstClass ofst(ifst->ArcType());
72 LOG(ERROR) << argv[0] <<
": Unknown or unsupported reweight type: " 73 << FST_FLAGS_reweight_type;
77 s::Push(*ifst, &ofst, flags, reweight_type, FST_FLAGS_delta);
79 return !ofst.Write(out_name);
void ShowUsage(bool long_usage=true)
int fstpush_main(int argc, char **argv)
#define SET_FLAGS(usage, argc, argv, rmflags)
void Push(MutableFst< Arc > *fst, ReweightType type=REWEIGHT_TO_INITIAL, float delta=kShortestDelta, bool remove_total_weight=false)
DECLARE_string(reweight_type)
uint8_t GetPushFlags(bool push_weights, bool push_labels, bool remove_total_weight, bool remove_common_affix)
DECLARE_bool(push_weights)
bool GetReweightType(std::string_view str, ReweightType *reweight_type)