Home | History | Annotate | Download | only in far
      1 // farinfo.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: allauzen (at) google.com (Cyril Allauzen)
     17 // Modified: jpr (at) google.com (Jake Ratkiewicz) to use new arc dispatching
     18 //
     19 // \file
     20 // Prints some basic information about the FSTs in an FST archive.
     21 //
     22 
     23 #include <fst/extensions/far/main.h>
     24 #include <fst/extensions/far/farscript.h>
     25 
     26 DEFINE_string(begin_key, "",
     27               "First key to extract (def: first key in archive)");
     28 DEFINE_string(end_key, "",
     29               "Last key to extract (def: last key in archive)");
     30 
     31 DEFINE_bool(list_fsts, false, "Display FST information for each key");
     32 
     33 int main(int argc, char **argv) {
     34   namespace s = fst::script;
     35 
     36   string usage = "Prints some basic information about the FSTs in an FST ";
     37   usage += "archive.\n\n Usage:";
     38   usage += argv[0];
     39   usage += " [in1.far in2.far...]\n";
     40   usage += "  Flags: begin_key end_key list_fsts";
     41 
     42   std::set_new_handler(FailedNewHandler);
     43   SET_FLAGS(usage.c_str(), &argc, &argv, true);
     44 
     45   vector<string> filenames;
     46   for (int i = 1; i < argc; ++i)
     47     filenames.push_back(strcmp(argv[i], "") != 0 ? argv[i] : "");
     48   if (filenames.empty())
     49     filenames.push_back("");
     50 
     51   s::FarInfo(filenames, fst::LoadArcTypeFromFar(filenames[0]),
     52              FLAGS_begin_key, FLAGS_end_key, FLAGS_list_fsts);
     53 }
     54