FST  openfst-1.7.9
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 #include <memory>
9 #include <string>
10 
11 #include <fst/flags.h>
12 #include <fst/script/info.h>
13 
14 DECLARE_string(arc_filter);
15 DECLARE_string(info_type);
16 DECLARE_bool(test_properties);
17 DECLARE_bool(fst_verify);
18 
19 int fstinfo_main(int argc, char **argv) {
20  namespace s = fst::script;
22 
23  std::string usage = "Prints out information about an FST.\n\n Usage: ";
24  usage += argv[0];
25  usage += " [in.fst]\n";
26 
27  std::set_new_handler(FailedNewHandler);
28  SET_FLAGS(usage.c_str(), &argc, &argv, true);
29  if (argc > 2) {
30  ShowUsage();
31  return 1;
32  }
33 
34  const std::string in_name =
35  (argc > 1 && (strcmp(argv[1], "-") != 0)) ? argv[1] : "";
36 
37  std::unique_ptr<FstClass> ifst(FstClass::Read(in_name));
38  if (!ifst) return 1;
39 
40  s::Info(*ifst, FLAGS_test_properties, FLAGS_arc_filter, FLAGS_info_type,
41  FLAGS_fst_verify);
42 
43  return 0;
44 }
void ShowUsage(bool long_usage=true)
Definition: flags.cc:123
int fstinfo_main(int argc, char **argv)
Definition: fstinfo-main.cc:19
void FailedNewHandler()
Definition: compat.cc:22
#define SET_FLAGS(usage, argc, argv, rmflags)
Definition: flags.h:216
DECLARE_bool(test_properties)
void Info(InfoArgs *args)
Definition: info.h:21
DECLARE_string(arc_filter)