Cambridge SMT System
disambig.main.cpp
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 
22 #include <main.disambig.hpp>
23 #include <main.custom_assert.hpp>
24 #include <main.logger.hpp>
25 
26 template<class ArcT >
27 void run (ucam::util::RegistryPO const& rg) {
34  DisambigData data;
35  //Our pipeline is defined by the following tasks:
36  //Load Recasing language model
37  boost::scoped_ptr< LoadLanguageModelTask<DisambigData > > mytask (
38  new LoadLanguageModelTask<DisambigData> ( rg ,
40  mytask->appendTask
41  //Load unigram transduction model
42  ( new LoadUnimapTask< DisambigData, ArcT > ( rg ,
44  //Read input lattice
45  ( new ReadFstTask<DisambigData, ArcT > ( rg ,
47  //Apply both models and prune
48  ( new DisambigTask<DisambigData, ArcT > ( rg ,
51  //Write output lattice
52  ( new WriteFstTask<DisambigData, ArcT > ( rg ,
54  ;
55  //For a given range of lattices, proceed to run the task
58  ; !ir->done()
59  ; ir->next() ) {
60  data.sidx = ir->get();
61  mytask->chainrun ( data );
62  }
63 }
64 
72 int main ( int argc, const char* argv[] ) {
73  ucam::util::initLogger ( argc, argv );
74  FORCELINFO ( argv[0] << " starts!" );
75  ucam::util::RegistryPO rg ( argc, argv );
76  FORCELINFO ( rg.dump ( "CONFIG parameters:\n=====================",
77  "=====================" ) ) ;
78  if (rg.get<std::string> (HifstConstants::kHifstSemiring) ==
79  HifstConstants::kHifstSemiringStdArc) run<fst::StdArc> (rg);
80  else if (rg.get<std::string> (HifstConstants::kHifstSemiring) ==
81  HifstConstants::kHifstSemiringLexStdArc) run<fst::LexStdArc>
82  (rg);
83  else {
84  LERROR ("Unknown semiring type!");
85  }
86  FORCELINFO ( argv[0] << " ends!" );
87 };
88 
std::string const kHifstSemiring
data structure for disambig tool. It needs at least a mixed case language model, mixed-case vocabular...
std::string const kRecaserUnimapLoad
std::string const kRecaserLmLoad
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.
#define FORCELINFO(msg)
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
Definition: range.hpp:214
#define IntRangeFactory
Definition: range.hpp:213
Language model loader task, loads a language model wrapping it in a class to provide.
Loads a unigram transduction model (aka unimap file) from a file with the format accepted by srilm di...
Convenience class that inherits Taskinterface behaviour and writes an fst to [file] using a key defin...
std::string const kRecaserOutput
std::string const kHifstSemiringLexStdArc
int main(int argc, const char *argv[])
Main function for disambig tool. Single-threaded implementation only. Applies a unigram transduction ...
std::string const kHifstSemiringStdArc
Static variables for logger. Include only once from main file.
void run(ucam::util::RegistryPO const &rg)
Disambig Task tool. Given a search space, applies a unigram transduction model (generating alternativ...
Convenience class that loads an fst using a key defined in the constructor and delivers it to the dat...
std::string const kRecaserLmFeatureweight
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
Included headers for the binary (disambig) should be defined here. This file should be included only ...
#define LERROR(msg)
const std::string kRangeOne
Definition: range.hpp:26
std::string const kRecaserInput
Static variable for custom_assert. Include only once from main file.