38 std::string usage =
"Disambiguates an FST.\n\n Usage: ";
40 usage +=
" [in.fst [out.fst]]\n";
43 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
49 const std::string in_name =
50 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
51 const std::string out_name =
52 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
54 std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
57 VectorFstClass ofst(ifst->ArcType());
59 const auto weight_threshold =
60 FST_FLAGS_weight.empty()
61 ? WeightClass::Zero(ifst->WeightType())
62 : WeightClass(ifst->WeightType(), FST_FLAGS_weight);
64 const s::DisambiguateOptions opts(
65 FST_FLAGS_delta, weight_threshold, FST_FLAGS_nstate,
66 FST_FLAGS_subsequential_label);
70 return !ofst.Write(out_name);
void ShowUsage(bool long_usage=true)
int fstdisambiguate_main(int argc, char **argv)
#define SET_FLAGS(usage, argc, argv, rmflags)
void Disambiguate(const Fst< Arc > &ifst, MutableFst< Arc > *ofst, const DisambiguateOptions< Arc > &opts=DisambiguateOptions< Arc >())