42 if ( arc.weight == FromArc::Weight::Zero() )
43 return ToArc ( arc.ilabel, arc.olabel, ToArc::Weight::Zero(), arc.nextstate );
46 std::map<int, float> wm;
47 for (fst::SparseTupleWeightIterator<FeatureWeight32, int> it ( arc.weight )
50 if (it.Value().first > (int) lmOffset_ ) {
53 if (it.Value().first < 0 ) {
54 WeightsTableIt itx = d_->
weights->find(-it.Value().first );
55 if (itx == d_->
weights->end()) {
56 std::cerr <<
"RULE NOT FOUND:" << -it.Value().first <<
"," << d_->
weights->size() << std::endl;
59 Weight aux = itx->second;
60 for (fst::SparseTupleWeightIterator<FeatureWeight32, int> auxit ( aux )
63 wm[auxit.Value().first] += auxit.Value().second.Value() * it.Value().second.Value();
67 wm[it.Value().first] += it.Value().second.Value();
70 Weight nw(arc.weight.DefaultValue());
71 for (std::map<int, float>::const_iterator itx = wm.begin()
74 nw.Push(itx->first, itx->second);
76 return ToArc ( arc.ilabel, arc.olabel, nw, arc.nextstate );
93 bool run ( Data& d ) {
108 LINFO(
"#LMs =" << offset);
121 std::string loadgrammar;
146 VectorFst<Arc> *mfst = VectorFstRead<Arc> (pi (ir->get() ) );
148 myMappingProcedure(mfst, d, offset);
149 std::string auxs = po (ir->get() );
151 FstWrite<Arc> (*mfst, auxs);
162 void myMappingProcedure(fst::VectorFst<TupleArc32> *mfst
164 ,
unsigned lmOffset) {
void run(ucam::util::RegistryPO const &rg)
const std::string kHifstLatticeStore
class that expands a wildcard into its actual value. This is useful e.g. for filenames ranging severa...
const std::string kRulesToWeightsNumberOfLanguageModels
std::vector< std::string > getVectorString(const std::string &key) const
Convenience method that returns a vector of strings taking "," as the separator character.
bool run(DataT &d)
Inherited method from ucam::util::TaskInterface. Loads the flower lattice into the data object...
SingleThreadededRulesToWeightsSparseLatsTask(const ucam::util::RegistryPO &rg)
ucam::hifst::RuleIdsToSparseWeightLatsData * d_
T get(const std::string &key) const
Returns parsed value associated to key.
WeightsTable::const_iterator WeightsTableIt
boost::scoped_ptr< NumberRangeInterface< unsigned > > IntRangePtr
fst::TropicalWeightTpl< F > Map(double)
const std::string kRangeInfinite
ucam::hifst::RuleIdsToSparseWeightLatsData::WeightsTableIt WeightsTableIt
RulesToWeightsMapperObject(ucam::hifst::RuleIdsToSparseWeightLatsData<> &d, unsigned lmOffset)
ToArc operator()(FromArc const &arc) const
Templated (hybrid) Interface for Task classes.
const std::string kRulesToWeightsLatticeFilterbyAlilats
std::string const kLmFeatureweights
const std::string kRulesToWeightsLoadalilats
bool exists(const std::string &key) const
Determines whether a program option (key) has been defined by the user.
Data class containing relevant variables. To be used as template for task classes using it...
const std::string kRulesToWeightsLoadGrammar
bool fileExists(const std::string &fileName)
Full single-threaded Alignment lattices to Sparse lattices.
const std::string kRulesToWeightsLatticeStore
const std::string kRangeOne
const std::string kGrammarLoad