#include "apply_fsa_models.h" #include "hg.h" #include "ff_fsa_dynamic.h" #include "feature_vector.h" #include "stringlib.h" #include "apply_models.h" #include #include using namespace std; struct ApplyFsa { ApplyFsa(const Hypergraph& ih, const SentenceMetadata& smeta, const FsaFeatureFunction& fsa, DenseWeightVector const& weights, ApplyFsaBy const& cfg, Hypergraph* oh) :ih(ih),smeta(smeta),fsa(fsa),weights(weights),cfg(cfg),oh(oh) { // sparse_to_dense(weight_vector,&weights); Init(); } void Init() { ApplyBottomUp(); //TODO: implement l->r } void ApplyBottomUp() { assert(cfg.IsBottomUp()); vector ffs; ModelSet models(weights, ffs); IntersectionConfiguration i(cfg.BottomUpAlgorithm(),cfg.pop_limit); ApplyModelSet(ih,smeta,models,i,oh); } private: const Hypergraph& ih; const SentenceMetadata& smeta; const FsaFeatureFunction& fsa; // WeightVector weight_vector; DenseWeightVector weights; ApplyFsaBy cfg; Hypergraph* oh; }; void ApplyFsaModels(const Hypergraph& ih, const SentenceMetadata& smeta, const FsaFeatureFunction& fsa, DenseWeightVector const& weight_vector, ApplyFsaBy const& cfg, Hypergraph* oh) { ApplyFsa a(ih,smeta,fsa,weight_vector,cfg,oh); } namespace { char const* anames[]={ "BU_CUBE", "BU_FULL", "EARLEY", 0 }; } //TODO: named enum type in boost? std::string ApplyFsaBy::name() const { return anames[algorithm]; } std::string ApplyFsaBy::all_names() { std::ostringstream o; for (int i=0;i=0); assert (i