Cambridge SMT System
main.tunewp.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::kInputExtended.c_str(), po::value<std::string>(),
46  "Fst(s) to count strings (use ? for multiple instances) " )
47  ( HifstConstants::kOutputExtended.c_str(), po::value<std::string>(),
48  "Text file output containing counts, one line per fst (use ? for multiple instances )" )
49  ( HifstConstants::kWordPenaltyExtended.c_str(), po::value<std::string>(),
50  "Range of word penalty values (i.e. 3.0 or 3.0:0.1:4.0 etc). Use %%wp%% in output to generate instances with different word penalties")
52  po::value<uint>()->default_value (std::numeric_limits<uint>::max() ),
53  "Apply Shortest path to obtain nshortest best hyps ")
55  po::value<std::string>()->default_value ("0"),
56  "Labels to be treated as epsilons")
58  po::value<std::string>()->default_value (
60  "Choose between stdarc and lexstdarc");
61  ;
62  parseOptionsGeneric (desc, vm, argc, argv);
63  } catch ( std::exception& e ) {
64  cerr << "error: " << e.what() << "\n";
65  exit ( EXIT_FAILURE );
66  } catch ( ... ) {
67  cerr << "Exception of unknown type!\n";
68  exit ( EXIT_FAILURE );
69  }
70  LINFO ( "Configuration loaded" );
71 };
72 
73 }
74 } // end namespaces
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition: registrypo.hpp:58
std::string const kNbestExtended
std::string const kWordPenaltyExtended
std::string const kEpsilonLabels
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 kRangeExtended
List of constants to be used both across program options and class runners.
std::string const kHifstSemiringStdArc
std::string const kInputExtended
std::string const kHifstSemiringExtended
Definition: bleu.hpp:14