fstinfo.cc revision f4c12fce1ee58e670f9c3fce46c40296ba9ee8a2
1// fstinfo.cc 2 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14// 15// Copyright 2005-2010 Google, Inc. 16// Author: riley@google.com (Michael Riley) 17// Modified: jpr@google.com (Jake Ratkiewicz) to use FstClass 18// 19// \file 20// Prints out various information about an FST such as number of states 21// and arcs and property values (see properties.h). 22// 23 24#include <fst/script/info.h> 25 26DEFINE_string(arc_filter, "any", "Arc filter: one of :" 27 " \"any\", \"epsilon\", \"iepsilon\", \"oepsilon\""); 28DEFINE_string(info_type, "auto", 29 "Info format: one of: \"auto\", \"long\", \"short\""); 30DEFINE_bool(pipe, false, "Send info to stderr, input to stdout"); 31DEFINE_bool(test_properties, true, 32 "Compute property values (if unknown to FST)"); 33DEFINE_bool(fst_verify, true, "Verify FST sanity"); 34 35int main(int argc, char **argv) { 36 namespace s = fst::script; 37 using fst::script::FstClass; 38 39 string usage = "Prints out information about an FST.\n\n Usage: "; 40 usage += argv[0]; 41 usage += " [in.fst]\n"; 42 43 std::set_new_handler(FailedNewHandler); 44 SetFlags(usage.c_str(), &argc, &argv, true); 45 if (argc > 2) { 46 ShowUsage(); 47 return 1; 48 } 49 50 string in_name = (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : ""; 51 52 FstClass *ifst = FstClass::Read(in_name); 53 if (!ifst) return 1; 54 55 s::PrintFstInfo(*ifst, FLAGS_test_properties, FLAGS_arc_filter, 56 FLAGS_info_type, FLAGS_fst_verify, FLAGS_pipe); 57 58 return 0; 59} 60