FST  openfst-1.8.3
OpenFst Library
farinfo-main.cc
Go to the documentation of this file.
1 // Copyright 2005-2024 Google LLC
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 // See www.openfst.org for extensive documentation on this weighted
16 // finite-state transducer library.
17 //
18 // Prints some basic information about the FSTs in an FST archive.
19 
20 #include <string>
21 #include <vector>
22 
26 
27 DECLARE_string(begin_key);
28 DECLARE_string(end_key);
29 DECLARE_bool(list_fsts);
30 
31 int farinfo_main(int argc, char **argv) {
32  namespace s = fst::script;
33 
34  std::string usage = "Prints information about an FST archive.\n\n Usage:";
35  usage += argv[0];
36  usage += " [in1.far in2.far...]\n";
37  usage += " Flags: begin_key end_key list_fsts";
38 
39  SET_FLAGS(usage.c_str(), &argc, &argv, true);
40  s::ExpandArgs(argc, argv, &argc, &argv);
41 
42  std::vector<std::string> sources;
43  for (int i = 1; i < argc; ++i) sources.push_back(argv[i]);
44  if (sources.empty()) sources.push_back("");
45 
46  const auto arc_type = s::LoadArcTypeFromFar(sources[0]);
47  if (arc_type.empty()) return 1;
48 
49  s::Info(sources, arc_type, FST_FLAGS_begin_key,
50  FST_FLAGS_end_key, FST_FLAGS_list_fsts);
51 
52  return 0;
53 }
int farinfo_main(int argc, char **argv)
Definition: farinfo-main.cc:31
void ExpandArgs(int argc, char **argv, int *argcp, char ***argvp)
Definition: getters.cc:60
#define SET_FLAGS(usage, argc, argv, rmflags)
Definition: flags.h:226
void Info(const std::vector< std::string > &sources, const std::string &arc_type, const std::string &begin_key, const std::string &end_key, bool list_fsts)
Definition: farscript.cc:145
std::string LoadArcTypeFromFar(const std::string &far_source)
Definition: script-impl.cc:34
DECLARE_bool(list_fsts)
DECLARE_string(begin_key)