37 std::string usage =
"Minimizes a deterministic FST.\n\n Usage: ";
39 usage +=
" [in.fst [out1.fst [out2.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 out1_name =
50 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
51 const std::string out2_name =
52 (argc > 3 && strcmp(argv[3],
"-") != 0) ? argv[3] :
"";
54 if (out1_name.empty() && out2_name.empty() && argc > 3) {
55 LOG(ERROR) << argv[0] <<
": Both outputs can't be standard output.";
59 std::unique_ptr<MutableFstClass> fst1(MutableFstClass::Read(in_name,
true));
63 std::unique_ptr<MutableFstClass> fst2(
new VectorFstClass(fst1->ArcType()));
64 s::Minimize(fst1.get(), fst2.get(), FST_FLAGS_delta,
65 FST_FLAGS_allow_nondet);
66 if (!fst2->Write(out2_name))
return 1;
69 FST_FLAGS_allow_nondet);
72 return !fst1->Write(out1_name);
void ShowUsage(bool long_usage=true)
DECLARE_bool(allow_nondet)
#define SET_FLAGS(usage, argc, argv, rmflags)
void Minimize(MutableFst< Arc > *fst, MutableFst< Arc > *sfst=nullptr, float delta=kShortestDelta, bool allow_nondet=false)
int fstminimize_main(int argc, char **argv)