20 #include <fst/flags.h> 23 #include <fst/vector-fst.h> 28 "Specifies failure label (default: none)");
30 "Removes useless states and transitions");
31 DEFINE_string(trim_type,
"needed_final",
"Trim type, one of: " 32 "\"needed_trim\", \"needed_final\", " 35 int main(
int argc,
char **argv) {
37 std::string usage =
"Intersects two canonical stochastic FSAs.\n\n Usage: ";
39 usage +=
" in1.fst in2.fst [out.fst]\n";
41 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
47 const std::string in1_name = strcmp(argv[1],
"-") != 0 ? argv[1] :
"";
48 const std::string in2_name =
49 (argc > 2 && (strcmp(argv[2],
"-") != 0)) ? argv[2] :
"";
50 const std::string out_name = argc > 3 ? argv[3] :
"";
52 if (in1_name.empty() && in2_name.empty()) {
53 LOG(ERROR) << argv[0] <<
": Can't take both inputs from standard input";
57 f::StdFst *ifst1 = f::StdFst::Read(in1_name);
60 f::StdFst *ifst2 = f::StdFst::Read(in2_name);
64 if (FST_FLAGS_trim_type ==
"needed_trim") {
66 }
else if (FST_FLAGS_trim_type ==
"needed_final") {
68 }
else if (FST_FLAGS_trim_type ==
"needed_nonfinal") {
72 <<
": Bad trim type: " << FST_FLAGS_trim_type;
78 FST_FLAGS_trim, trim_type))
81 if (!ofst.Write(out_name))
DEFINE_bool(trim, true,"Removes useless states and transitions")
bool Intersect(const fst::Fst< Arc > &ifst1, const fst::Fst< Arc > &ifst2, fst::MutableFst< Arc > *ofst, typename Arc::Label phi_label=fst::kNoLabel, bool trim=true, TrimType trim_type=TRIM_NEEDED_FINAL)
DEFINE_string(trim_type,"needed_final","Trim type, one of: ""\"needed_trim\", \"needed_final\", ""\"needed_nonfinal")
int main(int argc, char **argv)
DEFINE_int64(phi_label, fst::kNoLabel,"Specifies failure label (default: none)")