42 std::string usage =
"Intersects two FSAs.\n\n Usage: ";
44 usage +=
" in1.fst in2.fst [out.fst]\n";
45 usage +=
" Flags: connect\n";
47 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
48 if (argc < 3 || argc > 4) {
53 const std::string in1_name = strcmp(argv[1],
"-") == 0 ?
"" : argv[1];
54 const std::string in2_name = strcmp(argv[2],
"-") == 0 ?
"" : argv[2];
55 const std::string out_name =
56 argc > 3 && strcmp(argv[3],
"-") != 0 ? argv[3] :
"";
58 if (in1_name.empty() && in2_name.empty()) {
59 LOG(ERROR) << argv[0] <<
": Can't take both inputs from standard input";
63 std::unique_ptr<FstClass> ifst1(FstClass::Read(in1_name));
65 std::unique_ptr<FstClass> ifst2(FstClass::Read(in2_name));
68 VectorFstClass ofst(ifst1->ArcType());
73 LOG(ERROR) << argv[0] <<
": Unknown or unsupported compose filter type: " 74 << FST_FLAGS_compose_filter;
82 return !ofst.Write(out_name);
void ShowUsage(bool long_usage=true)
int fstintersect_main(int argc, char **argv)
void Intersect(const Fst< Arc > &ifst1, const Fst< Arc > &ifst2, MutableFst< Arc > *ofst, const IntersectOptions &opts=IntersectOptions())
#define SET_FLAGS(usage, argc, argv, rmflags)
bool GetComposeFilter(std::string_view str, ComposeFilter *compose_filter)
DECLARE_string(compose_filter)
ComposeOptions IntersectOptions