15 #ifndef TASK_LOADUNIMAP_HPP 16 #define TASK_LOADUNIMAP_HPP 33 template<
class Data,
class Arc = fst::StdArc >
36 typedef typename Arc::Weight Weight;
37 typedef typename Arc::Label Label;
42 std::string unimapfile_;
44 fst::VectorFst<Arc> *unimap_;
48 unordered_set<std::string> vcblm_;
54 const std::string unimapkey_;
74 unimapkey_ ( unimapkey ),
75 unimapfile_ ( rg.get<std::string> ( unimapkey ) ),
76 uscale_ ( rg.get<float> (
"recaser.unimap.scale" ) ),
79 if ( rg.
get<std::string> ( lmkey ) ==
"" 80 && rg.
get<std::string> ( unimapkey ) ==
"" )
return;
82 && rg.
get<std::string> ( unimapkey ) !=
"" 83 ,
"recaser.lm.load and recaser.unimap.load must either be both defined or both left to empty string " ) )
91 bool run ( Data& d ) {
93 LINFO (
"Unimap model available at key=" << unimapkey_ );
94 d.fsts[unimapkey_] = unimap_;
95 d.recasingvcblm = &vcblm_;
108 if ( loaded_ )
return;
109 if ( unimapfile_ ==
"" )
return;
110 LINFO (
"Read Unigram Model" );
112 unimap_ =
new fst::VectorFst<Arc>;
113 loadflowerfst<Arc> ( umf, *unimap_ );
115 LINFO (
"Applying uscale=" << uscale_ );
116 SetGsf<Arc> ( unimap_, uscale_ );
117 fst::extractTargetVocabulary<Arc> ( *unimap_, &vcblm_ );
127 #endif // TASK_LOADUNIMAP_HPP
std::string const kRecaserUnimapLoad
std::string const kRecaserLmLoad
#define LDBG_EXECUTE(order)
T get(const std::string &key) const
Returns parsed value associated to key.
Templated (hybrid) Interface for Task classes.
Templated functor that creates a weight given a float.
#define USER_CHECK(exp, comment)
Tests whether exp is true. If not, comment is printed and program ends.
Utilities for DisambigTask and related tasks.
Wrapper stream class that reads pipes, text files or gzipped files.