40 std::string usage =
"Disambiguates an FST.\n\n Usage: ";
42 usage +=
" [in.fst [out.fst]]\n";
44 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
50 const std::string in_name =
51 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
52 const std::string out_name =
53 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
55 std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
58 VectorFstClass ofst(ifst->ArcType());
60 const auto weight_threshold =
61 FST_FLAGS_weight.empty()
62 ? WeightClass::Zero(ifst->WeightType())
63 : WeightClass(ifst->WeightType(), FST_FLAGS_weight);
65 const s::DisambiguateOptions opts(
66 FST_FLAGS_delta, weight_threshold, FST_FLAGS_nstate,
67 FST_FLAGS_subsequential_label);
71 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 >())