46 "Two DFAs are equivalent iff the exit status is zero.\n\n" 49 usage +=
" in1.fst in2.fst\n";
51 SET_FLAGS(usage.c_str(), &argc, &argv,
true);
57 const std::string in1_name = strcmp(argv[1],
"-") == 0 ?
"" : argv[1];
58 const std::string in2_name = strcmp(argv[2],
"-") == 0 ?
"" : argv[2];
60 if (in1_name.empty() && in2_name.empty()) {
61 LOG(ERROR) << argv[0] <<
": Can't take both inputs from standard input";
65 std::unique_ptr<FstClass> ifst1(FstClass::Read(in1_name));
68 std::unique_ptr<FstClass> ifst2(FstClass::Read(in2_name));
72 if (FST_FLAGS_random) {
75 LOG(ERROR) << argv[0] <<
": Unknown or unsupported select type " 79 const RandGenOptions<s::RandArcSelection> opts(
80 ras, FST_FLAGS_max_length);
82 VLOG(1) << argv[0] <<
": Seed = " << seed;
84 FST_FLAGS_delta, seed);
89 if (!result)
VLOG(1) <<
"FSTs are not equivalent";
91 return result ? 0 : 2;
void ShowUsage(bool long_usage=true)
bool RandEquivalent(const Fst< Arc > &fst1, const Fst< Arc > &fst2, int32_t npath, const RandGenOptions< ArcSelector > &opts, float delta=kDelta, uint64_t seed=std::random_device()(), bool *error=nullptr)
bool GetRandArcSelection(std::string_view str, RandArcSelection *ras)
#define SET_FLAGS(usage, argc, argv, rmflags)
uint64_t GetSeed(uint64_t seed)
DECLARE_int32(max_length)
int fstequivalent_main(int argc, char **argv)
bool Equivalent(const Fst< Arc > &fst1, const Fst< Arc > &fst2, float delta=kDelta, bool *error=nullptr)