#ifndef FF_FROM_FSA_H #define FF_FROM_FSA_H #include "ff_fsa.h" #define FSA_FF_DEBUG #ifdef FSA_FF_DEBUG # define FSAFFDBG(x) do { if (debug) { std::cerr << x; } } while(0) #else # define FSAFFDBG(x) #endif /* regular bottom up scorer from Fsa feature uses guarantee about markov order=N to score ASAP encoding of state: if less than N-1 (ctxlen) words either: struct FF : public FsaImpl,FeatureFunctionFromFsa (more efficient) or: struct FF : public FsaFeatureFunctionDynamic,FeatureFunctionFromFsa (code sharing, but double dynamic dispatch) */ template class FeatureFunctionFromFsa : public FeatureFunction { typedef void const* SP; typedef WordID *W; typedef WordID const* WP; public: FeatureFunctionFromFsa(std::string const& param) : ff(param) { debug=true; // because factory won't set until after we construct. FSAFFDBG(ff.name()<<" params="<& ant_contexts, FeatureVector* features, FeatureVector* estimated_features, void* out_state) const { FSAFFDBG("(FromFsa) "< fsa(ff,smeta,edge); TRule const& rule=*edge.rule_; Sentence const& e = rule.e(); for (int j = 0; j < e.size(); ++j) { // items in target side of rule if (e[j] < 1) { // variable SP a = ant_contexts[-e[j]]; FSAFFDBG(' '<M) // child had full state already (had a "gap"); if nw==M then we already reached the same state via left word heuristic scan above fsa.reset(fsa_state(a)); } else { // single word WordID ew=e[j]; FSAFFDBG(' '< "<") FSAFFDBG(" right: "< "< markov order 0 FSAFFDBG("order="<