// See www.openfst.org for extensive documentation on this weighted // finite-state transducer library. // // Regression test for various FST algorithms. #include "./algo_test.h" #include #include #include // DEFINEs determine which semirings are tested; these are controlled by // the `defines` attributes of the associated build rules. DEFINE_int32(seed, -1, "random seed"); DEFINE_int32(repeat, 25, "number of test repetitions"); using fst::AlgoTester; using fst::ArcTpl; using fst::GallicArc; using fst::GallicWeight; using fst::LexicographicArc; using fst::LexicographicWeight; using fst::LogArc; using fst::LogWeight; using fst::MinMaxArc; using fst::MinMaxWeight; using fst::PowerWeight; using fst::STRING_LEFT; using fst::STRING_RIGHT; using fst::StdArc; using fst::StringArc; using fst::StringWeight; using fst::TropicalWeight; using fst::WeightGenerate; int main(int argc, char **argv) { FLAGS_fst_verify_properties = true; std::set_new_handler(FailedNewHandler); SET_FLAGS(argv[0], &argc, &argv, true); static const int kCacheGcLimit = 20; srand(FLAGS_seed); LOG(INFO) << "Seed = " << FLAGS_seed; FLAGS_fst_default_cache_gc = rand() % 2; FLAGS_fst_default_cache_gc_limit = rand() % kCacheGcLimit; VLOG(1) << "default_cache_gc:" << FLAGS_fst_default_cache_gc; VLOG(1) << "default_cache_gc_limit:" << FLAGS_fst_default_cache_gc_limit; #ifdef TEST_TROPICAL using TropicalWeightGenerate = WeightGenerate; TropicalWeightGenerate tropical_generator(false); AlgoTester tropical_tester( tropical_generator, FLAGS_seed); tropical_tester.Test(); #endif // TEST_TROPICAL #ifdef TEST_LOG using LogWeightGenerate = WeightGenerate; LogWeightGenerate log_generator(false); AlgoTester log_tester(log_generator, FLAGS_seed); log_tester.Test(); #endif // TEST_LOG #ifdef TEST_MINMAX using MinMaxWeightGenerate = WeightGenerate; MinMaxWeightGenerate minmax_generator(false); AlgoTester minmax_tester(minmax_generator, FLAGS_seed); minmax_tester.Test(); #endif #ifdef TEST_LEFT_STRING using StringWeightGenerate = WeightGenerate>; StringWeightGenerate left_string_generator(false); AlgoTester, StringWeightGenerate> left_string_tester( left_string_generator, FLAGS_seed); left_string_tester.Test(); #endif // TEST_LEFT_STRING #ifdef TEST_RIGHT_STRING using StringWeightGenerate = WeightGenerate>; StringWeightGenerate right_string_generator(false); AlgoTester, StringWeightGenerate> right_string_tester(right_string_generator, FLAGS_seed); right_string_tester.Test(); #endif // TEST_RIGHT_STRING #ifdef TEST_GALLIC using StdGallicArc = GallicArc; using TropicalGallicWeightGenerate = WeightGenerate>; TropicalGallicWeightGenerate tropical_gallic_generator(false); AlgoTester gallic_tester( tropical_gallic_generator, FLAGS_seed); gallic_tester.Test(); #endif // TEST_GALLIC #ifdef TEST_LEXICOGRAPHIC using TropicalLexicographicArc = LexicographicArc; using TropicalLexicographicWeightGenerate = WeightGenerate>; TropicalLexicographicWeightGenerate lexicographic_generator(false); AlgoTester lexicographic_tester(lexicographic_generator, FLAGS_seed); lexicographic_tester.Test(); #endif // TEST_LEXICOGRAPHIC #ifdef TEST_POWER using TropicalCubeWeight = PowerWeight; using TropicalCubeArc = ArcTpl; using TropicalCubeWeightGenerate = WeightGenerate; TropicalCubeWeightGenerate tropical_cube_generator(false); AlgoTester tropical_cube_tester( tropical_cube_generator, FLAGS_seed); tropical_cube_tester.Test(); #endif // TEST_POWER std::cout << "PASS" << std::endl; return 0; }