41 std::string usage =
"Removes epsilons from an FST.\n\n Usage: ";
43 usage +=
" [in.fst [out.fst]]\n";
46 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
52 const std::string in_name =
53 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
54 const std::string out_name =
55 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
57 std::unique_ptr<MutableFstClass>
fst(MutableFstClass::Read(in_name,
true));
60 const auto weight_threshold =
61 FST_FLAGS_weight.empty()
62 ? WeightClass::Zero(fst->WeightType())
63 : WeightClass(fst->WeightType(), FST_FLAGS_weight);
67 LOG(ERROR) << argv[0] <<
": Unknown or unsupported queue type: " 68 << FST_FLAGS_queue_type;
72 const s::RmEpsilonOptions opts(queue_type, FST_FLAGS_connect,
73 weight_threshold, FST_FLAGS_nstate,
78 return !fst->Write(out_name);
void ShowUsage(bool long_usage=true)
void RmEpsilon(MutableFst< Arc > *fst, std::vector< typename Arc::Weight > *distance, const RmEpsilonOptions< Arc, Queue > &opts)
int fstrmepsilon_main(int argc, char **argv)
#define SET_FLAGS(usage, argc, argv, rmflags)
DECLARE_string(queue_type)
bool GetQueueType(std::string_view str, QueueType *queue_type)