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>
26  ucam::util::PatternAddress<unsigned> output (rg.get<std::string>
28  WeightFunctorT mwcopy;
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) ==
54  > (rg);
55  } else if (rg.get<std::string> (HifstConstants::kAction) ==
58  , fst::StdArc
60  > (rg);
61  } else if (rg.get<std::string> (HifstConstants::kAction) ==
63  run<fst::StdArc
66  > (rg);
67  } else {
68  LERROR ("Action not recognized! Check program option.");
69  }
70  FORCELINFO ( argv[0] << " finished!" );
71 }
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
T get(const std::string &key) const
Returns parsed value associated to key.
Definition: registrypo.hpp:194
void initLogger(int argc, const char *argv[])
Inits logger, parses param options checking for –logger.verbose.
std::string const kInput
#define FORCELINFO(msg)
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
Definition: range.hpp:214
fst::TropicalWeightTpl< F > Map(double)
#define IntRangeFactory
Definition: range.hpp:213
std::string const kOutput
int main(int argc, const char *argv[])
Definition: lexmap.main.cpp:43
std::string const kActionStd2lex
Static variables for logger. Include only once from main file.
templated Mapper that modifies weights when copying from one FST to another, passing through the othe...
std::string const kAction
int run(ucam::util::RegistryPO const &rg)
Definition: lexmap.main.cpp:23
std::string const kActionLex2std
Templated functor that creates a weight given a float.
LexicographicArc< StdArc::Weight, StdArc::Weight > LexStdArc
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
std::string const kActionProjectweight2
#define LERROR(msg)
const std::string kRangeOne
Definition: range.hpp:26
Static variable for custom_assert. Include only once from main file.