15 #ifndef TASK_TUNEWPWRITEFST_HPP 16 #define TASK_TUNEWPWRITEFST_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_;
47 unordered_set<Label> epsilons_;
52 ,
const std::string& fstkey
53 ,
const std::string& readfstkey =
"" 56 , readfstkey_ (readfstkey !=
"" ? readfstkey : fstkey)
57 , fstfile_ ( rg.get<std::string> ( fstkey ) )
59 , doTune_(rg.getBool(
HC::
kTune) )
61 LDEBUG(
"Init TuneWpWriteFstTask: " << fstfile_() );
62 epsilons_.insert(
OOV);
68 ,
const std::string& fstkey
69 ,
const std::string& readfstkey =
"" 84 inline bool run ( Data& d ) {
85 if ( fstfile_ ( d.sidx ) ==
"" )
return false;
86 if ( d.fsts.find ( readfstkey_ ) == d.fsts.end() ) {
87 LERROR (
"fst with key=" << readfstkey_ <<
" does not exist!" );
88 exit ( EXIT_FAILURE );
93 LDEBUG(
"Word penalty application --");
95 VectorFst<Arc> mfst (*(
static_cast< Fst<Arc> *
> (d.fsts[readfstkey_]) ) );
97 Map<Arc, WordPenaltyMapper<Arc> >
100 ShortestPath<Arc> (mfst, &aux);
102 std::string auxs= fstfile_(d.sidx);
104 FstWrite<Arc> ( mfst, auxs);
#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 Mapper that inserts a word penalty over an FST, skipping user defined epsilon arcs...
NumberType get(void)
Returns range value at position k_.
void start(void)
Empty implementation.
void next(void)
Increment index.
Templated (hybrid) Interface for Task classes.
Templated functor that creates a weight given a float.
bool exists(const std::string &key) const
Determines whether a program option (key) has been defined by the user.
bool getBool(const std::string &key) const
To handle yes|no program option values.
bool done(void)
Checks if reached the last element.
std::string const kUserWpRange
void find_and_replace(std::string &haystack, const std::string &needle, const std::string &replace)
std::string const kTuneWordPenaltyRange