FST  openfst-1.7.2
OpenFst Library
fstinfo-main.cc
Go to the documentation of this file.
1 // See www.openfst.org for extensive documentation on this weighted
2 // finite-state transducer library.
3 //
4 // Prints out various information about an FST such as number of states
5 // and arcs and property values (see properties.h).
6 
7 #include <cstring>
8 
9 #include <memory>
10 #include <string>
11 
12 #include <fst/flags.h>
13 #include <fst/script/info.h>
14 
15 DECLARE_string(arc_filter);
16 DECLARE_string(info_type);
17 DECLARE_bool(pipe);
18 DECLARE_bool(test_properties);
19 DECLARE_bool(fst_verify);
20 
21 int fstinfo_main(int argc, char **argv) {
22  namespace s = fst::script;
24 
25  string usage = "Prints out information about an FST.\n\n Usage: ";
26  usage += argv[0];
27  usage += " [in.fst]\n";
28 
29  std::set_new_handler(FailedNewHandler);
30  SET_FLAGS(usage.c_str(), &argc, &argv, true);
31  if (argc > 2) {
32  ShowUsage();
33  return 1;
34  }
35 
36  const string in_name =
37  (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
38 
39  std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
40  if (!ifst) return 1;
41 
42  s::PrintFstInfo(*ifst, FLAGS_test_properties, FLAGS_arc_filter,
43  FLAGS_info_type, FLAGS_fst_verify, FLAGS_pipe);
44 
45  return 0;
46 }
void ShowUsage(bool long_usage=true)
Definition: flags.cc:124
int fstinfo_main(int argc, char **argv)
Definition: fstinfo-main.cc:21
DECLARE_bool(pipe)
void FailedNewHandler()
Definition: compat.cc:25
#define SET_FLAGS(usage, argc, argv, rmflags)
Definition: flags.h:214
void PrintFstInfo(InfoArgs *args)
Definition: info.h:21
DECLARE_string(arc_filter)