Cambridge SMT System
main.disambignffst.init_param_options.hpp
Go to the documentation of this file.
1 // Licensed under the Apache License, Version 2.0 (the "License");
2 // you may not use these files except in compliance with the License.
3 // You may obtain a copy of the License at
4 //
5 // http://www.apache.org/licenses/LICENSE-2.0
6 //
7 // Unless required by applicable law or agreed to in writing, software
8 // distributed under the License is distributed on an "AS IS" BASIS,
9 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 // See the License for the specific language governing permissions and
11 // limitations under the License.
12 
13 // Copyright 2012 - Gonzalo Iglesias, AdriĆ  de Gispert, William Byrne
14 
21 namespace ucam {
22 namespace util {
23 namespace po = boost::program_options;
24 
38 inline void init_param_options ( int argc, const char* argv[],
39  po::variables_map *vm ) {
40  using namespace HifstConstants;
41  try {
42  po::options_description desc ( "Command-line/configuration file options" );
43  desc.add_options()
44  ( kRangeExtended.c_str(), po::value<std::string>(),
45  "Indices of sentences handle" )
46  ( kDeterminizeOutput.c_str(), po::value<std::string>()->default_value("no"),
47  "Determinize on output (i.e. assuming tags are on input side)")
48  ( kMinimize.c_str(), po::value<std::string>()->default_value("no"),
49  "Determinize AND minimize (AND also push). This is an EXPERIMENTAL feature.")
50  ( kExitOnFirstPassFailure.c_str(), po::value<std::string>()->default_value("yes"),
51  "Exit immediately if first pass fails to position correctly the tags")
52  ( kUseOpenFst.c_str(), po::value<std::string>()->default_value("no"),
53  "Use OpenFst determinize for non-functional fsts (openfst 1.4.1/1.5.0)")
54  ( kInputExtended.c_str(), po::value<std::string>(),
55  "Fst(s) to determinize. Keeps best derivation. (use ? for multiple instances) " )
56  ( kOutputExtended.c_str(), po::value<std::string>(),
57  "Determinized Fsts (use ? for multiple instances )" )
58  ( kHifstSemiring.c_str(),
59  po::value<std::string>()->default_value ("stdarc"),
60  "Choose between stdarc, lexstdarc,... (only stdarc supported!")
61  ( kNThreads.c_str(), po::value<unsigned>(),
62  "Number of threads (trimmed to number of cpus in the machine) " )
63  ;
64  parseOptionsGeneric (desc, vm, argc, argv);
65  } catch ( std::exception& e ) {
66  cerr << "error: " << e.what() << "\n";
67  exit ( EXIT_FAILURE );
68  } catch ( ... ) {
69  cerr << "Exception of unknown type!\n";
70  exit ( EXIT_FAILURE );
71  }
72  LINFO ( "Configuration loaded" );
73 };
74 
75 }
76 } // end namespaces
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition: registrypo.hpp:58
std::string const kHifstSemiring
void init_param_options(int argc, const char *argv[], po::variables_map *vm)
Function to initialize boost program_options module with command-line and config file options...
#define LINFO(msg)
std::string const kOutputExtended
std::string const kExitOnFirstPassFailure
std::string const kRangeExtended
List of constants to be used both across program options and class runners.
std::string const kDeterminizeOutput
const std::string kNThreads
std::string const kInputExtended
std::string const kUseOpenFst
Definition: bleu.hpp:14
std::string const kMinimize