15 #ifndef TASK_WRITEFST_HPP 16 #define TASK_WRITEFST_HPP 35 template <
class Data,
class Arc = fst::StdArc >
37 typedef typename Arc::Label Label;
38 typedef typename Arc::Weight Weight;
39 typedef std::vector<pair<Label, Label> > VectorPair;
43 std::string readfstkey_;
50 ,
const std::string& fstkey
51 ,
const std::string& readfstkey =
"" 54 , readfstkey_ (readfstkey !=
"" ? readfstkey : fstkey)
55 , fstfile_ ( rg.get<std::string> ( fstkey ) ) {
59 ,
const std::string& fstkey
60 ,
const std::string& readfstkey =
"" 62 if ( rg.
exists ( fstkey ) )
75 inline bool run ( Data& d ) {
76 if ( fstfile_ ( d.sidx ) ==
"" )
return false;
77 if ( d.fsts.find ( readfstkey_ ) == d.fsts.end() ) {
78 LERROR (
"fst with key=" << readfstkey_ <<
" does not exist!" );
79 exit ( EXIT_FAILURE );
82 FORCELINFO (
"Writing lattice " << d.sidx <<
" to ... " 83 << fstfile_( d.sidx ) );
87 ( * (
static_cast< Fst<Arc> *
> 88 ( d.fsts[readfstkey_] ) ), fstfile_ ( d.sidx ) );
89 std::string parenskey = readfstkey_ +
".parens";
90 if ( d.fsts.find ( parenskey ) != d.fsts.end() ) {
91 WriteLabelPairs (fstfile_ ( d.sidx ) +
".parens",
92 * (static_cast< VectorPair * > ( d.fsts[parenskey] ) ) );
#define ZDISALLOW_COPY_AND_ASSIGN(TypeName)
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
Templated (hybrid) Interface for Task classes.
bool exists(const std::string &key) const
Determines whether a program option (key) has been defined by the user.