示例#1
0
 ///Constructor with registry object and several keys to access data object and registry
 HiFSTTask ( const ucam::util::RegistryPO& rg ,
             const std::string& outputkey = HifstConstants::kHifstLatticeStore,
             const std::string& locallmkey = HifstConstants::kHifstLocalpruneLmLoad,
             const std::string& fullreferencelatticekey =
               HifstConstants::kReferencefilterNosubstringStore ,
             const std::string& lmkey = HifstConstants::kLmLoad
           ) :
   optimize_ (rg.getBool (HifstConstants::kHifstOptimizecells) ),
   numlocallm_ (rg.getVectorString (locallmkey).size() ),
   warned_ (false),
   rtnfiles_ (rg.get<std::string> (HifstConstants::kHifstWritertn) ),
   fullreferencelatticekey_ ( fullreferencelatticekey ),
   lmkey_ ( lmkey ),
   locallmkey_ ( locallmkey ),
   outputkey_ ( outputkey ),
   piscount_ ( 0 ),
   aligner_ ( rg.getBool ( HifstConstants::kHifstAlilatsmode ) ),
   //    cellredm_ ( rg.getBool ( "hifst.cellredm" ) ),
   //    finalredm_ ( rg.getBool ( "hifst.finalredm" ) ),
   hipdtmode_ (rg.getBool (HifstConstants::kHifstUsepdt) ),
   rtnopt_ (rg.getBool (HifstConstants::kHifstRtnopt) ),
   replacefstbyarc_ ( rg.getSetString (
                        HifstConstants::kHifstReplacefstbyarcNonterminals ) ),
   replacefstbyarcexceptions_ ( rg.getSetString (
                                  HifstConstants::kHifstReplacefstbyarcExceptions ) ),
   replacefstbynumstates_ ( rg.get<unsigned>
                            ( HifstConstants::kHifstReplacefstbyarcNumstates ) ),
   localprune_ ( rg.getBool ( HifstConstants::kHifstLocalpruneEnable ) ),
   pruneweight_ ( rg.get<float> ( HifstConstants::kHifstPrune ) ),
   numstatesthreshold_ ( rg.get<unsigned>
                         ( HifstConstants::kHifstLocalpruneNumstates ) ),
   lpctuples_ ( rg.getVectorString (
                  HifstConstants::kHifstLocalpruneConditions ) ) {
   LINFO ("Number of local language models=" << numlocallm_);
   LINFO ("aligner mode=" << aligner_);
   LINFO ("localprune mode=" << localprune_);
   USER_CHECK ( ! ( lpc_.size() % 4 ),
                "local pruning conditions are defined by tuples of 4 elements: category,x,y,Number-of-states. Category is a string and x,y are int. Number of states is unsigned" );
   USER_CHECK ( (localprune_ && numlocallm_) || ( localprune_ && !numlocallm_
                && aligner_ ) || (!localprune_) ,
                "If you want to do cell pruning in translation, you should  use a language model for local pruning. Check --hifst.localprune.lm.load and --hifst.localprune.enable.\n");
   optimize.setAlignMode (aligner_);
   if (hipdtmode_) {
     LINFO ("Hipdt mode enabled!");
   }
   if (!rtnopt_) {
     LINFO ("RTN openfst optimizations will not be applied");
   }
   LDEBUG ( "Hifst constructor done!" );
 };
示例#2
0
 ///Constructor with RegistryPO object.
 HifstStatsTask ( const ucam::util::RegistryPO& rg ) :
   d_ ( NULL ),
   writeCYKStats_ ( rg.getBool ( HifstConstants::kStatsHifstCykgridEnable  ) ),
   width_ ( rg.get<unsigned> ( HifstConstants::kStatsHifstCykgridCellwidth ) ),
   statsoutput_ ( rg.get<std::string> ( HifstConstants::kStatsHifstWrite ) ) {
   this->appendTask ( new ucam::fsttools::SpeedStatsTask<Data> ( rg ) );
 };