Cambridge SMT System
ucam::hifst::GrammarTask< Data > Class Template Reference

Task class that loads a grammar into memory. More...

#include <task.grammar.hpp>

Inheritance diagram for ucam::hifst::GrammarTask< Data >:
Collaboration diagram for ucam::hifst::GrammarTask< Data >:

Public Member Functions

 GrammarTask (ucam::util::RegistryPO const &rg, std::string const &featureweightskey=HifstConstants::kGrammarFeatureweights, unsigned featureoffset=0)
 Constructor. More...
 
 GrammarTask (const std::string &grammarfilekey=HifstConstants::kGrammarLoad, const std::string &patternfilekey=HifstConstants::kGrammarStorepatterns)
 Constructor used for unit testing. More...
 
GrammarDatagetGrammarData ()
 Returns GrammarData. More...
 
bool run (Data &d)
 ucam::util::TaskInterface mandatory method implementation. This method loads the hierarchical grammar, stores patterns, finds non-terminal hierarchy and delivers pointer to data object, for other tasks to use the grammar More...
 
void load (const std::string &file)
 Loads rules from a grammar file. More...
 
void load (std::stringstream &s)
 Loads rules from a stringstream. More...
 
virtual ~GrammarTask ()
 
- Public Member Functions inherited from ucam::util::TaskInterface< Data >
 TaskInterface ()
 Constructor. More...
 
virtual ~TaskInterface ()
 
bool chainrun (Data &d)
 Implements chain of responsability. Calls run method and, if there is another task, call its run method too. More...
 
bool operator() (Data &d)
 
TaskInterfaceappendTask (TaskInterface *t)
 Appends a task class. If there is no task, append here, otherwise delegate in next task. More...
 
TaskInterfaceoperator() (TaskInterface *t)
 
TaskInterfacegetTask ()
 Return appended task. More...
 
TaskInterfacenext ()
 

Friends

template<typename FM >
void ucam::util::readtextfile (const std::string &filename, FM &fm)
 Friendship with readtextfile function. More...
 

Detailed Description

template<class Data>
class ucam::hifst::GrammarTask< Data >

Task class that loads a grammar into memory.

It provides methods to take as input a [file], and read the contents, sort and populate GrammarData. Optionally it can also store grammar-specific patterns.

Remarks
Inherits properties from TaskInterface and is templated over a data class, in which relevant data is stored.

Definition at line 38 of file task.grammar.hpp.

Constructor & Destructor Documentation

template<class Data>
ucam::hifst::GrammarTask< Data >::GrammarTask ( ucam::util::RegistryPO const &  rg,
std::string const &  featureweightskey = HifstConstants::kGrammarFeatureweights,
unsigned  featureoffset = 0 
)
inline

Constructor.

Parameters
rgPointer to a Registry object initialized with boost::program_options parsed variables.

Definition at line 67 of file task.grammar.hpp.

template<class Data>
ucam::hifst::GrammarTask< Data >::GrammarTask ( const std::string &  grammarfilekey = HifstConstants::kGrammarLoad,
const std::string &  patternfilekey = HifstConstants::kGrammarStorepatterns 
)
inline

Constructor used for unit testing.

Parameters
grammarfilekeyRegistry key accessing file name to load the grammar from.
patternfilekeyRegistry key accessing file name to dump the patterns.

Definition at line 94 of file task.grammar.hpp.

template<class Data>
virtual ucam::hifst::GrammarTask< Data >::~GrammarTask ( )
inlinevirtual

Definition at line 175 of file task.grammar.hpp.

Member Function Documentation

template<class Data>
GrammarData* ucam::hifst::GrammarTask< Data >::getGrammarData ( )
inline

Returns GrammarData.

Returns
Pointer to GrammarData class.

Definition at line 106 of file task.grammar.hpp.

Here is the caller graph for this function:

template<class Data>
void ucam::hifst::GrammarTask< Data >::load ( const std::string &  file)
inline

Loads rules from a grammar file.

Parameters
fileFull pathname to the grammar file.
Returns
void

Definition at line 148 of file task.grammar.hpp.

Here is the caller graph for this function:

template<class Data>
void ucam::hifst::GrammarTask< Data >::load ( std::stringstream &  s)
inline

Loads rules from a stringstream.

Parameters
sstream with rules.
Returns
void

Definition at line 164 of file task.grammar.hpp.

template<class Data>
bool ucam::hifst::GrammarTask< Data >::run ( Data &  d)
inlinevirtual

ucam::util::TaskInterface mandatory method implementation. This method loads the hierarchical grammar, stores patterns, finds non-terminal hierarchy and delivers pointer to data object, for other tasks to use the grammar

Parameters
dData Object

Implements ucam::util::TaskInterface< Data >.

Definition at line 117 of file task.grammar.hpp.

Friends And Related Function Documentation

template<class Data>
template<typename FM >
void ucam::util::readtextfile ( const std::string &  filename,
FM &  fm 
)
friend

Friendship with readtextfile function.


The documentation for this class was generated from the following file: