15 #ifndef MAIN_RUN_CREATESSGRAMMAR_HPP 16 #define MAIN_RUN_CREATESSGRAMMAR_HPP 28 using boost::asio::ip::tcp;
36 template <
class Data = HifstTaskData>
58 fastforwardread_ ( new
ucam::util::iszfstream ( rg.get<std::string>
67 bool run ( Data& d ) {
68 boost::scoped_ptr < LoadGrammar> grammartask (
new LoadGrammar ( rg_ ) );
69 grammartask->appendTask
71 (
new PrePro ( rg_ ) )
72 (
new PatternsToInstances ( rg_ ) )
73 (
new SentenceSpecificGrammar ( rg_ ) )
75 bool finished =
false;
80 finished = fastforwardread_ ( d.sidx ,
81 &d.originalsentence );
82 FORCELINFO (
"=====Translate sentence " << d.sidx <<
":" <<
84 grammartask->chainrun ( d );
85 if ( finished )
break;
105 template <
class Data = HifstTaskData>
119 unsigned threadcount_;
127 fastforwardread_ ( new
ucam::util::iszfstream ( rg.get<std::string>
137 bool run ( Data& original_data ) {
138 boost::scoped_ptr < LoadGrammar >grammartask (
new LoadGrammar ( rg_ ) );
139 grammartask->appendTask
143 grammartask->chainrun ( original_data );
144 std::vector < boost::shared_ptr<std::string> >translations;
147 bool finished =
false;
153 d->grammar = original_data.grammar;
155 d->wm = original_data.wm;
156 finished = fastforwardread_ ( d->sidx ,
157 & ( d->originalsentence ) );
158 FORCELINFO (
"=====Translate sentence " << d->sidx <<
":" <<
159 d->originalsentence );
160 PrePro *p =
new PrePro ( rg_ );
162 (
new PatternsToInstances ( rg_ ) )
163 (
new SentenceSpecificGrammar ( rg_ ) )
166 if ( finished )
break;
bool run(Data &d)
Reads an input sentence, tokenizes and integer-maps.
Reads text file, performs tokenization and integer-mapping.
Converts patterns to instanced patterns.
const std::string kPreproWordmapLoad
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
boost::shared_ptr< tcp::socket > socket_ptr
Trivial implementation of a threadpool based on boost::asio methods When initiated, creates a threadpool of n threads (n <= number of cpus). Jobs should be submitted with the templated operator(). When the object is deleted it will wait for all threads to finish.
MultiThreadedCreateSentenceSpecificGrammarTask(const ucam::util::RegistryPO &rg)
Constructor.
Task class that loads a grammar into memory.
Templated (hybrid) Interface for Task classes.
Simple functor that accepts an interface and pointer to the data object in which it will have to run ...
TaskInterface & appendTask(TaskInterface *t)
Appends a task class. If there is no task, append here, otherwise delegate in next task...
const std::string kNThreads
Full single-threaded Translation system.
This class uses instantiated patterns to analyze the grammar and deliver two hashes providing candida...
const std::string kSourceLoad
SingleThreadedCreateSentenceSpecificGrammarTask(const ucam::util::RegistryPO &rg)
Constructor.
const std::string kRangeOne
Full multi-threaded Translation system.
bool run(Data &original_data)
Reads an input sentence, tokenizes and integer-maps.