Cambridge SMT System
main.lmert.init_param_options.hpp
Go to the documentation of this file.
1 #ifndef MAIN_LMERT_INITPARAMOPTIONS_HPP
2 #define MAIN_LMERT_INITPARAMOPTIONS_HPP
3 
4 #include <constants-lmert.hpp>
5 namespace ucam {
6 namespace util {
7 namespace po = boost::program_options;
8 
9 // \todo convert all parameter names into const strings
10 // and reuse these const parameters instead of literals
11 // in other places of code.
12 inline void init_param_options ( int argc, const char* argv[],
13  po::variables_map *vm ) {
14  using namespace HifstConstants;
15  try {
16  po::options_description desc ( "Command-line/configuration file options" );
17  desc.add_options()
18  ( kRangeExtended.c_str(), po::value<std::string>(),
19  "Indices of tuning set sentences" )
20  ( kInputExtended.c_str(), po::value<std::string>(),
21  "Fst(s) to count strings (use ? for multiple instances) " )
22  ( kLmertInitialParams.c_str(), po::value<std::string>(),
23  "Initial parameter value (lambda)" )
24  ( kLmertWordRefs.c_str(), po::value<std::string>(), "MERT reference translations words" )
25  ( kLmertIntRefs.c_str(), po::value<std::string>(), "MERT reference translations ints" )
26  ( kLmertMinGamma.c_str(), po::value<float>()->default_value ( 0.000005f ),
27  "minimum gamma value for a line segment" )
28  ( kLmertMinBleuGain.c_str(), po::value<float>()->default_value ( 0.000001f ),
29  "minimum accepted bleu gain (stopping criterion)" )
30  ( kLmertRandomSeed.c_str(), po::value<int>()->default_value ( time ( 0 ) ),
31  "seed for randomline search" )
32  ( kNThreads.c_str() , po::value<int>()->default_value ( 1 ), "number of threads" )
33  ( kLmertNumRandomDirections.c_str(), po::value<int>()->default_value ( 10 ),
34  "number of random directions; default is 2xfeature_dim" )
35  ( kLmertWriteParams.c_str(), po::value<std::string>(), "output parameter file" )
36  ( kLmertExternalTokenizer.c_str(), po::value<std::string>(), "external tokenization command" )
37  ( kLmertWMap.c_str(), po::value<std::string>(), "Maps idx to word; for use with word references" )
38  ( kLmertBleuCacheSize.c_str(), po::value<int>()->default_value(10000), "number of hyps per sentence for which to LRU cache Bleu stats");
39 
40  // \todo is this option supported?
41  // ( kHifstSemiring.c_str(),
42  // po::value<std::string>()->default_value ( "stdarc" ),
43  // "Choose between stdarc, lexstdarc, "
44  // "and tuplearc (for the tropical sparse tuple arc semiring)" )
45 
46  parseOptionsGeneric ( desc, vm, argc, argv );
47  } catch ( std::exception& e ) {
48  cerr << "error: " << e.what() << "\n";
49  exit ( EXIT_FAILURE );
50  } catch ( ... ) {
51  cerr << "Exception of unknown type!\n";
52  exit ( EXIT_FAILURE );
53  }
54 
55  LINFO ( "Configuration loaded" );
56 };
57 
58 }
59 } // end namespaces
60 
61 #endif
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition: registrypo.hpp:58
std::string const kLmertWordRefs
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 kRangeExtended
List of constants to be used both across program options and class runners.
std::string const kLmertRandomSeed
std::string const kLmertWMap
const std::string kNThreads
std::string const kLmertMinBleuGain
std::string const kLmertNumRandomDirections
std::string const kInputExtended
std::string const kLmertIntRefs
std::string const kLmertMinGamma
std::string const kLmertInitialParams
std::string const kLmertWriteParams
std::string const kLmertBleuCacheSize
std::string const kLmertExternalTokenizer
Definition: bleu.hpp:14