FST  openfst-1.7.1
OpenFst Library
farinfo.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 some basic information about the FSTs in an FST archive.
5 
6 #include <string>
7 #include <vector>
8 
9 #include <fst/flags.h>
12 
13 DEFINE_string(begin_key, "",
14  "First key to extract (default: first key in archive)");
15 DEFINE_string(end_key, "",
16  "Last key to extract (default: last key in archive)");
17 
18 DEFINE_bool(list_fsts, false, "Display FST information for each key");
19 
20 int main(int argc, char **argv) {
21  namespace s = fst::script;
22 
23  string usage = "Prints some basic information about the FSTs in an FST ";
24  usage += "archive.\n\n Usage:";
25  usage += argv[0];
26  usage += " [in1.far in2.far...]\n";
27  usage += " Flags: begin_key end_key list_fsts";
28 
29  std::set_new_handler(FailedNewHandler);
30  SET_FLAGS(usage.c_str(), &argc, &argv, true);
31  s::ExpandArgs(argc, argv, &argc, &argv);
32 
33  std::vector<string> in_fnames;
34  for (int i = 1; i < argc; ++i) in_fnames.push_back(argv[i]);
35  if (in_fnames.empty()) in_fnames.push_back("");
36 
37  const auto arc_type = s::LoadArcTypeFromFar(in_fnames[0]);
38  if (arc_type.empty()) return 1;
39 
40  s::FarInfo(in_fnames, arc_type, FLAGS_begin_key, FLAGS_end_key,
41  FLAGS_list_fsts);
42 
43  return 0;
44 }
void FarInfo(const std::vector< string > &filenames, const string &arc_type, const string &begin_key, const string &end_key, const bool list_fsts)
Definition: farscript.cc:56
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
Definition: getters.cc:55
void FailedNewHandler()
Definition: compat.cc:25
#define SET_FLAGS(usage, argc, argv, rmflags)
Definition: flags.h:214
DEFINE_bool(list_fsts, false,"Display FST information for each key")
DEFINE_string(begin_key,"","First key to extract (default: first key in archive)")
int main(int argc, char **argv)
Definition: farinfo.cc:20
string LoadArcTypeFromFar(const string &far_fname)
Definition: script-impl.cc:17