Cambridge SMT System
main.lmbr.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 
24 namespace po = boost::program_options;
25 
39 inline void init_param_options ( int argc, const char* argv[],
40  po::variables_map *vm ) {
41  try {
42  po::options_description desc ( "Command-line/configuration file options" );
43  desc.add_options()
45  po::value<std::string>()->default_value ( "1" ),
46  "Indices of sentences to translate" )
47  ( HifstConstants::kNThreads.c_str(), po::value<unsigned>(),
48  "Number of threads (trimmed to number of cpus in the machine) " )
50  "If set, the tool expects input FSAs to be templated over lexicographic<tropical,tropical> semiring (and so maps them to tropical)" )
51  ( HifstConstants::kLmbrLoadEvidencespace.c_str(), po::value<std::string>(),
52  "Load an FSA containing the evidence space" )
54  po::value<std::string>()->default_value ( "" ),
55  "Load an FSA containing the hypotheses space" )
57  po::value<std::string>()->default_value ( "" ),
58  "Write the lmbr FSA output with posteriors applied" )
60  po::value<std::string>()->default_value ( "" ),
61  "Write file text with one-best for tunings. Use %%alpha%% and %%wip%% outputs for different alphas and word penalties" )
63  po::value<unsigned>()->default_value ( 1 ), "Minimum posterior order to apply" )
65  po::value<unsigned>()->default_value ( 4 ), "Maximum posterior order to apply" )
67  po::value<std::string>()->default_value ( "1" ),
68  "Scaling factor of normalized evidence space (range of float values)" )
69  ( HifstConstants::kLmbrWps.c_str(),
70  po::value<std::string>()->default_value ( "0.0" ),
71  "Word penalty (range of float values)" )
72  ( HifstConstants::kLmbrP.c_str(), po::value<float>(), "Unigram precision" )
73  ( HifstConstants::kLmbrR.c_str(), po::value<float>(), "Precision ratio" )
74  ( HifstConstants::kLmbrT.c_str(), po::value<float>()->default_value ( 10.0f ),
75  "" )
77  po::value<float>()->default_value ( std::numeric_limits<float>::max() ),
78  "Preprune evidence space" )
79  ;
80  ucam::util::parseOptionsGeneric (desc, vm, argc, argv);
81  } catch ( std::exception& e ) {
82  cerr << "error: " << e.what() << "\n";
83  exit ( EXIT_FAILURE );
84  } catch ( ... ) {
85  cerr << "Exception of unknown type!\n";
86  exit ( EXIT_FAILURE );
87  }
88  LINFO ( "Configuration loaded" );
89 };
90 
91 }
92 } // end namespaces
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition: registrypo.hpp:58
const std::string kLmbrAlpha
const std::string kLmbrLoadHypothesesspace
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)
const std::string kLmbrLexstdarc
const std::string kLmbrWritedecoder
const std::string kLmbrPreprune
std::string const kRangeExtended
List of constants to be used both across program options and class runners.
const std::string kLmbrLoadEvidencespace
const std::string kLmbrMaxorder
const std::string kLmbrT
const std::string kNThreads
const std::string kLmbrMinorder
const std::string kLmbrR
const std::string kLmbrP
Definition: bleu.hpp:14
const std::string kLmbrWriteonebest
const std::string kLmbrWps