36 std::string usage =
"Prunes states and arcs of an FST.\n\n Usage: ";
38 usage +=
" [in.fst [out.fst]]\n";
41 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
47 const std::string in_name =
48 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
49 const std::string out_name =
50 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
52 std::unique_ptr<MutableFstClass>
fst(MutableFstClass::Read(in_name,
true));
55 const auto weight_threshold =
56 FST_FLAGS_weight.empty()
57 ? WeightClass::Zero(fst->WeightType())
58 : WeightClass(fst->WeightType(), FST_FLAGS_weight);
60 s::Prune(fst.get(), weight_threshold, FST_FLAGS_nstate,
63 return !fst->Write(out_name);
void ShowUsage(bool long_usage=true)
int fstprune_main(int argc, char **argv)
#define SET_FLAGS(usage, argc, argv, rmflags)
void Prune(MutableFst< Arc > *fst, const PruneOptions< Arc, ArcFilter > &opts=PruneOptions< Arc, ArcFilter >())