Cambridge SMT System
main.rules2weights.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
15
#include <
main.rules2weights.init_param_options_common.hpp
>
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
using namespace
HifstConstants
;
44
try
{
45
po::options_description desc (
"Command-line/configuration file options"
);
46
initRules2WeightsOptions
(desc);
47
parseOptionsGeneric
(desc, vm, argc, argv);
48
checkRules2Weightptions
(vm);
49
if
( vm->count (
kRulesToWeightsLoadGrammar
.c_str() ) ) {
50
LDEBUG
(
kRulesToWeightsLoadGrammar
<<
51
( *vm ) [
kRulesToWeightsLoadGrammar
.c_str()].as<std::string>() );
52
}
else
{
53
LERROR
(
"parameter "
<<
kRulesToWeightsLoadGrammar
<<
" not defined"
);
54
exit ( EXIT_FAILURE );
55
}
56
}
catch
( std::exception& e ) {
57
cerr <<
"error: "
<< e.what() <<
"\n"
;
58
exit ( EXIT_FAILURE );
59
}
catch
( ... ) {
60
cerr <<
"Exception of unknown type!\n"
;
61
exit ( EXIT_FAILURE );
62
}
63
LINFO
(
"Configuration loaded"
);
64
};
65
66
}
67
}
// end namespaces
ucam::util::parseOptionsGeneric
void parseOptionsGeneric(bpo::options_description &desc, bpo::variables_map *vm, int argc, const char *argv[])
Definition:
registrypo.hpp:58
ucam::util::init_param_options
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...
Definition:
main.applylm.init_param_options.hpp:40
ucam::util::initRules2WeightsOptions
void initRules2WeightsOptions(po::options_description &desc, bool addAllOptions=true)
Definition:
main.rules2weights.init_param_options_common.hpp:27
LINFO
#define LINFO(msg)
Definition:
logger.boost_log.hpp:78
main.rules2weights.init_param_options_common.hpp
To initialize boost parameter options.
LDEBUG
#define LDEBUG(msg)
Definition:
logger.boost_log.hpp:107
HifstConstants
Definition:
constants-fsttools.hpp:4
ucam::util::checkRules2Weightptions
void checkRules2Weightptions(po::variables_map *vm)
Definition:
main.rules2weights.init_param_options_common.hpp:59
HifstConstants::kRulesToWeightsLoadGrammar
const std::string kRulesToWeightsLoadGrammar
Definition:
constants-hifst.hpp:133
LERROR
#define LERROR(msg)
Definition:
logger.boost_log.hpp:119
ucam
Definition:
bleu.hpp:14
ucam-smt
cpp
hifst
include
main.rules2weights.init_param_options.hpp
Generated on Wed May 25 2016 10:26:01 for Cambridge SMT System by
1.8.11