Cambridge SMT System
main.applylm.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 namespace po = boost::program_options;
26 
40 inline void init_param_options ( int argc, const char* argv[]
41  , po::variables_map *vm ) {
42  using namespace HifstConstants;
43  using namespace std;
44  try {
45  po::options_description desc ( "Command-line/configuration file options" );
47  desc.add_options()
48  ( kRange.c_str(), po::value<string>(),
49  "Indices of lattices to rescore" )
50  ( kNThreads.c_str(), po::value<uint>(),
51  "Number of threads (trimmed to number of cpus in the machine) " )
52  ( kLatticeLoad.c_str(), po::value<string>(),
53  "Read original lattice from [file]" )
54  ( kLatticeLoadDeleteLmCost.c_str(),
55  "If working on LexStd, then delete lm cost in the lattices first,"
56  " by projecting Weight2 into Weight1." )
57  ( kLatticeStore.c_str(),
58  po::value<string>()->default_value ( "" ),
59  "Write lattice with lm scores to [file]" )
60  (kUseBilingualModel.c_str()
61  , po::value<string>()->default_value("no")
62  , "Use bilingual models. Only nplm model supported"
63  )
65  , po::value<unsigned>()->default_value(3)
66  , "Source size. Only 0 or positive odd values accepted. "
67  "NPLM model must be trained accordingly! If 0, it will assume NNLM. "
68  "Note that 0 is intended to use only for debugging purposes -- this should be equivalent to "
69  "(but slower than) --usebilm=no."
70  )
72  , po::value<string>()->default_value("")
73  , "Single file containing source sentences. Mandatory if "
74  "bilingual models are used!"
75  )
76  (kTune.c_str()
77  , po::value<string>()->default_value("no")
78  , "Dumps 1-best hypotheses for different word penalty corrections"
79  )
80  (kTuneWrite.c_str()
81  , po::value<string>()->default_value("")
82  , "Where to write 1-best output per word penalty correction (use %%wp%%)"
83  )
84  (kTuneWordPenaltyRange.c_str()
85  , po::value<string>()->default_value("")
86  , "Range of word penalties in usual range format (float values)."
87  )
88  ( kHifstSemiring.c_str()
89  , po::value<string>()->default_value
90  ( kHifstSemiringStdArc.c_str() )
91  , "Choose between lexstdarc or stdarc" )
92  ( kStatsWrite.c_str()
93  , po::value<string>()->default_value ( "" )
94  , "Write speed stats to [file]" )
95  ;
96  parseOptionsGeneric (desc, vm, argc, argv);
98  } catch ( exception& e ) {
99  cerr << "error: " << e.what() << "\n";
100  exit ( EXIT_FAILURE );
101  } catch ( ... ) {
102  cerr << "Exception of unknown type!\n";
103  exit ( EXIT_FAILURE );
104  }
105  LINFO ( "Configuration loaded" );
106 };
107 
108 }
109 } // end namespaces
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition: registrypo.hpp:58
std::string const kHifstSemiring
std::string const kUseBilingualModelSourceSentenceFile
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 kUseBilingualModel
#define LINFO(msg)
std::string const kLatticeStore
const std::string kRange
Definition: range.hpp:25
std::string const kLatticeLoadDeleteLmCost
std::string const kHifstSemiringStdArc
std::string const kTuneWrite
const std::string kNThreads
std::string const kTune
std::string const kLatticeLoad
To initialize boost parameter options.
void checkApplyLmOptions(po::variables_map *vm)
void initCommonApplylmOptions(po::options_description &desc)
std::string const kTuneWordPenaltyRange
std::string const kStatsWrite
std::string const kUseBilingualModelSourceSize
Definition: bleu.hpp:14