Cambridge SMT System
main.disambig.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  try {
41  po::options_description desc ( "Command-line/configuration file options" );
42  desc.add_options()
43  ( HifstConstants::kRangeExtended.c_str(), po::value<std::string>(),
44  "Indices of sentences to translate" )
45  ( HifstConstants::kRecaserLmLoad.c_str(), po::value<std::string>(),
46  "Scaling factors applied to the language models" )
48  po::value<std::string>()->default_value ( "1.0" ),
49  "Scaling factors applied to the language models" )
50  ( HifstConstants::kRecaserUnimapLoad.c_str(), po::value<std::string>(),
51  "Scaling factors applied to the language models (separated by commas) " )
53  po::value<float>()->default_value ( 1.0f ),
54  "Scaling factors applied to the language models " )
56  po::value<std::string>()->default_value ( "byshortestpath,1" ),
57  "Choose between byshortestpath,numpaths or byweight,weight" )
58  ( HifstConstants::kRecaserInputExtended.c_str(), po::value<std::string>(),
59  "Input lattice" )
60  ( HifstConstants::kRecaserOutputExtended.c_str(), po::value<std::string>(),
61  "Output lattice" )
63  po::value<std::string>()->default_value (
65  "Choose between lexstdarc or stdarc" )
66  ;
67  parseOptionsGeneric (desc, vm, argc, argv);
68  if ( !vm->count ( HifstConstants::kRecaserLmLoad.c_str() ) ) {
69  LERROR ( "Language model file not defined" );
70  exit ( EXIT_FAILURE );
71  }
72  if ( !vm->count ( HifstConstants::kRecaserUnimapLoad.c_str() ) ) {
73  LERROR ( "Unimap model not defined" );
74  exit ( EXIT_FAILURE );
75  }
76  } catch ( std::exception& e ) {
77  cerr << "error: " << e.what() << "\n";
78  exit ( EXIT_FAILURE );
79  } catch ( ... ) {
80  cerr << "Exception of unknown type!\n";
81  exit ( EXIT_FAILURE );
82  }
83  LINFO ( "Configuration loaded" );
84 };
85 
86 }
87 } // end namespaces
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition: registrypo.hpp:58
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...
std::string const kRecaserPrune
#define LINFO(msg)
std::string const kRecaserUnimapLoad
std::string const kRecaserLmLoad
std::string const kRecaserOutputExtended
std::string const kRangeExtended
List of constants to be used both across program options and class runners.
std::string const kHifstSemiringStdArc
std::string const kRecaserUnimapWeight
std::string const kRecaserLmFeatureweight
std::string const kRecaserInputExtended
#define LERROR(msg)
std::string const kHifstSemiringExtended
Definition: bleu.hpp:14