Cambridge SMT System
lexmap.main.cpp
Go to the documentation of this file.
1
8
#include <
main.custom_assert.hpp
>
9
#include <
main.logger.hpp
>
10
#include <
main.lexmap.hpp
>
11
12
/*
13
* \brief Main function.
14
* \param argc: Number of command-line program options.
15
* \param argv: Actual program options.
16
* \remarks
17
*/
18
19
template
<
class
ArcT
20
,
class
Arc2T
21
,
class
MapperT
22
,
class
WeightFunctorT >
23
int
run
(
ucam::util::RegistryPO
const
& rg) {
24
ucam::util::PatternAddress<unsigned>
input (rg.
get
<std::string>
25
(
HifstConstants::kInput
) );
26
ucam::util::PatternAddress<unsigned>
output (rg.
get
<std::string>
27
(
HifstConstants::kOutput
) );
28
WeightFunctorT mwcopy;
29
for
(
ucam::util::IntRangePtr
ir (
ucam::util::IntRangeFactory
( rg,
30
HifstConstants::kRangeOne
) );
31
!ir->done();
32
ir->next() ) {
33
FORCELINFO
(
"Processing file "
<< input ( ir->get() ) );
34
boost::scoped_ptr< fst::VectorFst<ArcT> > ifst (fst::VectorFstRead<ArcT>
35
( input (
36
ir->get() ) ) );
37
boost::scoped_ptr< fst::VectorFst<Arc2T> > ofst (
new
fst::VectorFst<Arc2T>);
38
Map
( *ifst, &*ofst, MapperT ( mwcopy ) );
39
fst::FstWrite<Arc2T> ( *ofst, output (ir->get() ) );
40
}
41
};
42
43
int
main
(
int
argc,
const
char
* argv[] ) {
44
ucam::util::initLogger
( argc, argv );
45
FORCELINFO
( argv[0] <<
" starts!"
);
46
ucam::util::RegistryPO
rg ( argc, argv );
47
FORCELINFO
( rg.
dump
(
"CONFIG parameters:\n====================="
,
48
"====================="
) );
49
if
(rg.
get
<std::string> (
HifstConstants::kAction
) ==
50
HifstConstants::kActionProjectweight2
) {
51
run
<
fst::LexStdArc
52
,
fst::LexStdArc
53
,
fst::GenericWeightMapper<fst::LexStdArc, fst::LexStdArc, fst::MakeWeight2<fst::LexStdArc>
>,
fst::MakeWeight2<fst::LexStdArc>
54
> (rg);
55
}
else
if
(rg.
get
<std::string> (
HifstConstants::kAction
) ==
56
HifstConstants::kActionLex2std
) {
57
run
<
fst::LexStdArc
58
, fst::StdArc
59
,
fst::GenericWeightMapper<fst::LexStdArc, fst::StdArc, fst::LexToStd >
,
fst::LexToStd
60
> (rg);
61
}
else
if
(rg.
get
<std::string> (
HifstConstants::kAction
) ==
62
HifstConstants::kActionStd2lex
) {
63
run
<fst::StdArc
64
,
fst::LexStdArc
65
,
fst::GenericWeightMapper<fst::StdArc, fst::LexStdArc, fst::MakeWeight2<fst::LexStdArc>
>,
fst::MakeWeight2<fst::LexStdArc>
66
> (rg);
67
}
else
{
68
LERROR
(
"Action not recognized! Check program option."
);
69
}
70
FORCELINFO
( argv[0] <<
" finished!"
);
71
}
ucam::util::PatternAddress
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
Definition:
addresshandler.hpp:33
ucam::util::RegistryPO
Definition:
registrypo.hpp:95
ucam::util::RegistryPO::get
T get(const std::string &key) const
Returns parsed value associated to key.
Definition:
registrypo.hpp:194
ucam::util::initLogger
void initLogger(int argc, const char *argv[])
Inits logger, parses param options checking for –logger.verbose.
Definition:
logger.boost_log.hpp:55
HifstConstants::kInput
std::string const kInput
Definition:
constants-fsttools.hpp:10
FORCELINFO
#define FORCELINFO(msg)
Definition:
logger.boost_log.hpp:79
ucam::util::IntRangePtr
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
Definition:
range.hpp:214
Map
fst::TropicalWeightTpl< F > Map(double)
IntRangeFactory
#define IntRangeFactory
Definition:
range.hpp:213
HifstConstants::kOutput
std::string const kOutput
Definition:
constants-fsttools.hpp:12
fst::LexToStd
Definition:
lexicographic-tropical-tropical-funcs.h:149
main
int main(int argc, const char *argv[])
Definition:
lexmap.main.cpp:43
main.lexmap.hpp
HifstConstants::kActionStd2lex
std::string const kActionStd2lex
Definition:
constants-fsttools.hpp:92
main.logger.hpp
Static variables for logger. Include only once from main file.
fst::GenericWeightMapper
templated Mapper that modifies weights when copying from one FST to another, passing through the othe...
Definition:
fstutils.mapper.hpp:69
HifstConstants::kAction
std::string const kAction
Definition:
constants-fsttools.hpp:90
run
int run(ucam::util::RegistryPO const &rg)
Definition:
lexmap.main.cpp:23
HifstConstants::kActionLex2std
std::string const kActionLex2std
Definition:
constants-fsttools.hpp:91
fst::MakeWeight2
Templated functor that creates a weight given a float.
Definition:
lexicographic-tropical-tropical-funcs.h:80
fst::LexStdArc
LexicographicArc< StdArc::Weight, StdArc::Weight > LexStdArc
Definition:
lexicographic-tropical-tropical-incls.h:36
ucam::util::RegistryPO::dump
std::string dump(const std::string &decorator_start="", const std::string &decorator_end="")
Dumps all configuration parameters into a string with a reasonably pretty format. ...
Definition:
registrypo.hpp:108
HifstConstants::kActionProjectweight2
std::string const kActionProjectweight2
Definition:
constants-fsttools.hpp:93
LERROR
#define LERROR(msg)
Definition:
logger.boost_log.hpp:119
HifstConstants::kRangeOne
const std::string kRangeOne
Definition:
range.hpp:26
main.custom_assert.hpp
Static variable for custom_assert. Include only once from main file.
ucam-smt
cpp
fsttools
lexmap.main.cpp
Generated on Wed May 25 2016 10:26:01 for Cambridge SMT System by
1.8.11