46 std::string usage =
"Determinizes an FST.\n\n Usage: ";
48 usage +=
" [in.fst [out.fst]]\n";
50 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
58 LOG(ERROR) << argv[0] <<
": Unknown or unsupported determinization type: " 59 << FST_FLAGS_det_type;
63 const std::string in_name =
64 (argc > 1 && strcmp(argv[1],
"-") != 0) ? argv[1] :
"";
65 const std::string out_name =
66 (argc > 2 && strcmp(argv[2],
"-") != 0) ? argv[2] :
"";
68 std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
71 VectorFstClass ofst(ifst->ArcType());
73 const auto weight_threshold =
74 FST_FLAGS_weight.empty()
75 ? WeightClass::Zero(ifst->WeightType())
76 : WeightClass(ifst->WeightType(), FST_FLAGS_weight);
78 const s::DeterminizeOptions opts(
79 FST_FLAGS_delta, weight_threshold, FST_FLAGS_nstate,
80 FST_FLAGS_subsequential_label, det_type,
81 FST_FLAGS_increment_subsequential_label);
85 return !ofst.Write(out_name);
void ShowUsage(bool long_usage=true)
void Determinize(const Fst< Arc > &ifst, MutableFst< Arc > *ofst, const DeterminizeOptions< Arc > &opts=DeterminizeOptions< Arc >())
DECLARE_bool(increment_subsequential_label)
bool GetDeterminizeType(std::string_view str, DeterminizeType *det_type)
#define SET_FLAGS(usage, argc, argv, rmflags)
int fstdeterminize_main(int argc, char **argv)