From faea049a3c2adc9cb373414e084976e032886dfb Mon Sep 17 00:00:00 2001 From: graehl Date: Mon, 26 Jul 2010 17:25:57 +0000 Subject: comment cleanup git-svn-id: https://ws10smt.googlecode.com/svn/trunk@421 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/ff.h | 4 ++++ decoder/ff_from_fsa.h | 40 +++++++++++++++++----------------------- decoder/ff_fsa.h | 8 ++++++-- decoder/ff_lm.cc | 3 +-- decoder/hg.h | 3 --- 5 files changed, 28 insertions(+), 30 deletions(-) diff --git a/decoder/ff.h b/decoder/ff.h index 5c1f214f..08715766 100644 --- a/decoder/ff.h +++ b/decoder/ff.h @@ -2,6 +2,7 @@ #define _FF_H_ #include +#include #include "fdict.h" #include "hg.h" @@ -29,6 +30,7 @@ class FeatureFunction { static std::string usage_helper(std::string const& name,std::string const& params,std::string const& details,bool show_params,bool show_details); static Features single_feature(int feat); public: + // stateless feature that doesn't depend on source span: override and return true. then your feature can be precomputed over rules. virtual bool rule_feature() const { return false; } @@ -81,6 +83,8 @@ public: // of the particular FeatureFunction class. There is one exception: // equality of the contents (i.e., memcmp) is required to determine whether // two states can be combined. + + // by Log, I mean that the edge is non-const only so you can log to it with INFO_EDGE(edge,msg<<"etc."). most features don't use this so implement the below. it has a different name to allow a default implementation without name hiding when inheriting + overriding just 1. virtual void TraversalFeaturesLog(const SentenceMetadata& smeta, Hypergraph::Edge& edge, // this is writable only so you can use log() const std::vector& ant_contexts, diff --git a/decoder/ff_from_fsa.h b/decoder/ff_from_fsa.h index 237e5d0d..f50e0fdc 100755 --- a/decoder/ff_from_fsa.h +++ b/decoder/ff_from_fsa.h @@ -40,8 +40,7 @@ public: Features features() const { return ff.features(); } - //TODO: add source span to Fsa FF interface, pass along - //TODO: read/debug VERY CAREFULLY + // Log because it void TraversalFeaturesLog(const SentenceMetadata& smeta, Hypergraph::Edge& edge, const std::vector& ant_contexts, @@ -64,25 +63,27 @@ public: FSAFFDBGnl(edge); return; } - +//why do we compute heuristic in so many places? well, because that's how we know what state we should score words in once we're full on our left context (because of markov order bound, we know the score will be the same no matter what came before that left context) SP h_start=ff.heuristic_start_state(); + // these left_* refer to our output (out_state): W left_begin=(W)out_state; W left_out=left_begin; // [left,fsa_state) = left ctx words. if left words aren't full, then null wordid WP left_full=left_end_full(out_state); - FsaScanner fsa(ff,smeta,edge); + FsaScanner fsa(ff,smeta,edge); // this holds our current state and eventuallybecomes our right state if we saw enough words 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]]; + SP a = ant_contexts[-e[j]]; // variables a* are referring to this child derivation state. FSAFFDBG(edge,' '< our left words -> any number of interior words which are scored then hidden + if (left_out+anwWordProb(w,ctx); // states are sri contexts so are in reverse order (most recent word is first, then 1-back comes next, etc.). diff --git a/decoder/hg.h b/decoder/hg.h index ea0e8aa1..b0785d33 100644 --- a/decoder/hg.h +++ b/decoder/hg.h @@ -1,9 +1,6 @@ #ifndef _HG_H_ #define _HG_H_ - -//FIXME: is the edge given to ffs the coarse (previous forest) edge? if so, then INFO_EDGE is effectively not working. supposed to have logging associated with each edge and see how it fits together in kbest afterwards. - // define USE_INFO_EDGE 1 if you want lots of debug info shown with --show_derivations - otherwise it adds quite a bit of overhead if ffs have their logging enabled (e.g. ff_from_fsa) #define USE_INFO_EDGE 0 #if USE_INFO_EDGE -- cgit v1.2.3