Cambridge SMT System
main.alilats2splats.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 
16 
23 namespace ucam {
24 namespace util {
25 
26 namespace po = boost::program_options;
27 
41 inline void init_param_options ( int argc, const char* argv[],
42  po::variables_map *vm ) {
43  try {
44  po::options_description desc ( "Command-line/configuration file options" );
45  desc.add_options()
47  po::value<std::string>()->default_value ("1"),
48  "Indices of sentences to translate" )
49  ( HifstConstants::kNThreads.c_str(), po::value<unsigned>(),
50  "Number of threads (trimmed to number of cpus in the machine) " )
52  , po::value<std::string>()->default_value ( "" )
53  , "Feature weights applied in hifst. This is a comma-separated sequence "
54  "of language model(s) and grammar feature weights.\n"
55  "IMPORTANT: If this option is not empty string, then it will override "
56  "any values in lm.featureweights and ruleflowerlattice.featureweights"
57  )
59  "Filter the flower lattice with the vocabulary of the alignment lattices" )
60  ( HifstConstants::kRuleflowerlatticeLoad.c_str(), po::value<std::string>(),
61  "Load a synchronous context-free grammar file" )
63  po::value<std::string>()->default_value ( "" ), "Store the fst (SparseWeight)" )
65  po::value<std::string>()->default_value ( "1" ),
66  "One or more feature weights. Must match the number of features in the grammar" )
68  po::value<std::string>(), "Load an alignment lattice" )
70  po::value<std::string>()->default_value ( "" ),
71  "Store the fst (SparseWeight) containing a vector of weights " )
73  po::value<std::string>()->default_value ( "no" ),
74  "Strip any special Hifst epsilon labels (e.g. oov, deletion rule, ...)" )
76  po::value<std::string>()->default_value ( "yes" ),
77  "Determinizes (and minimizes) the vector feature lattice. yes|no" )
79  po::value<std::string>()->default_value ( "" ),
80  "Store the fst (SparseWeight) containing a vector of weights " )
82  po::value<std::string>()->default_value ( "" ),
83  "Use wordmap when dumping nbest list (to use with storenbestfile option )" )
85  po::value<std::string>()->default_value ( "" ),
86  "Store the fst (SparseWeight) containing a vector of weights " )
88  po::value<unsigned>()->default_value ( 50 ),
89  "Number for which the feature output will printed in sparse format (weight_1@position_1 ... weight_n@position_n" )
90  ;
91  initCommonApplylmOptions (desc); // Add generic language model options
92  parseOptionsGeneric (desc, vm, argc, argv);
93  if ( vm->count ( HifstConstants::kRuleflowerlatticeLoad.c_str() ) ) {
94  LDEBUG ( "ruleflowerlattice.load=" <<
95  ( *vm ) [HifstConstants::kRuleflowerlatticeLoad.c_str()].as<std::string>() );
96  } else {
97  LERROR ( "parameter ruleflowerlattice.load not defined" );
98  exit ( EXIT_FAILURE );
99  }
100  } catch ( std::exception& e ) {
101  cerr << "error: " << e.what() << "\n";
102  exit ( EXIT_FAILURE );
103  } catch ( ... ) {
104  cerr << "Exception of unknown type!\n";
105  exit ( EXIT_FAILURE );
106  }
107  LINFO ( "Configuration loaded" );
108 };
109 
110 }
111 } // 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...
const std::string kRuleflowerlatticeLoad
#define LINFO(msg)
const std::string kSparseweightvectorlatticeDeterminize
const std::string kSparseweightvectorlatticeLoadalilats
#define LDEBUG(msg)
std::string const kRangeExtended
List of constants to be used both across program options and class runners.
const std::string kSparseweightvectorlatticeStripSpecialEpsilonLabels
const std::string kSparseweightvectorlatticeStorenbestfile
const std::string kRuleflowerlatticeFilterbyalilats
const std::string kRuleflowerlatticeFeatureweights
const std::string kNThreads
const std::string kSparseweightvectorlatticeWordmap
const std::string kSparseweightvectorlatticeStorefeaturefile
const std::string kRuleflowerlatticeStore
const std::string kSparseweightvectorlatticeStore
const std::string kSparseweightvectorlatticeFirstsparsefeatureatindex
To initialize boost parameter options.
#define LERROR(msg)
void initCommonApplylmOptions(po::options_description &desc)
const std::string kFeatureweights
Definition: bleu.hpp:14