From 65a47d21082deb41aceb6516212568408bddaeac Mon Sep 17 00:00:00 2001 From: graehl Date: Sun, 25 Jul 2010 20:33:06 +0000 Subject: being ensuring edge debug info is copied when apply_models - new hg.AddEdge methods git-svn-id: https://ws10smt.googlecode.com/svn/trunk@409 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/apply_models.cc | 2 +- decoder/ff_from_fsa.h | 5 ++--- decoder/ff_fsa.h | 11 ++++++---- decoder/hg.h | 55 ++++++++++++++++++++++++++++++++++++++++++------- decoder/oracle_bleu.h | 2 +- 5 files changed, 59 insertions(+), 16 deletions(-) diff --git a/decoder/apply_models.cc b/decoder/apply_models.cc index 11d43e93..77d35c92 100644 --- a/decoder/apply_models.cc +++ b/decoder/apply_models.cc @@ -336,7 +336,7 @@ struct NoPruningRescorer { Hypergraph::TailNodeVector tail(arity); for (int i = 0; i < arity; ++i) tail[i] = nodemap[in_edge.tail_nodes_[i]][tail_iter[i]]; - Hypergraph::Edge* new_edge = out.AddEdge(in_edge.rule_, tail); + Hypergraph::Edge* new_edge = out.AddEdge(in_edge, tail); new_edge->feature_values_ = in_edge.feature_values_; new_edge->i_ = in_edge.i_; new_edge->j_ = in_edge.j_; diff --git a/decoder/ff_from_fsa.h b/decoder/ff_from_fsa.h index adb704de..d32e90df 100755 --- a/decoder/ff_from_fsa.h +++ b/decoder/ff_from_fsa.h @@ -5,9 +5,8 @@ #define FSA_FF_DEBUG #ifdef FSA_FF_DEBUG -# define FSAFFDBG(e,x) do { if (debug) { FSADBGae(e,x) } } while(0) -# define FSAFFDBGnl(e) do { if (debug) { std::cerr<R if we only scan 1 word at a time, that's fine //#define FSA_DEBUG - -# define FSADBGae(e,x) std::cerr << x; INFO_EDGE(e,x); +#define FSA_DEBUG_CERR 0 +#define FSA_DEBUG_DEBUG 0 +# define FSADBGif(i,e,x) do { if (i) { if (FSA_DEBUG_CERR){std::cerr< -# define FSADBG(e,x) do { if (d().debug()) { FSADBGae(e,x) } } while(0) -# define FSADBGnl(e) do { if (d().debug) { std::cerr<id_ = eid; + index_tails(*edge); + return edge; + } + + Edge* AddEdge(Edge const& in_edge, const TailNodeVector& tail) { + edges_.push_back(Edge(edges_.size(),in_edge)); + Edge* edge = &edges_.back(); + edge->tail_nodes_ = tail; // possibly faster than copying to Edge() constructed above then copying via push_back. perhaps optimized it's the same. + index_tails(*edge); + return edge; + } + + // oldest method in use - requires much manual assignment from source edge: Edge* AddEdge(const TRulePtr& rule, const TailNodeVector& tail) { + int eid=edges_.size(); edges_.push_back(Edge()); Edge* edge = &edges_.back(); edge->rule_ = rule; edge->tail_nodes_ = tail; - edge->id_ = edges_.size() - 1; + edge->id_ = eid; for (int i = 0; i < edge->tail_nodes_.size(); ++i) nodes_[edge->tail_nodes_[i]].out_edges_.push_back(edge->id_); return edge; diff --git a/decoder/oracle_bleu.h b/decoder/oracle_bleu.h index fbb681e0..56ff8b72 100755 --- a/decoder/oracle_bleu.h +++ b/decoder/oracle_bleu.h @@ -281,7 +281,7 @@ struct OracleBleu { void DumpKBest(const int sent_id, const Hypergraph& forest, const int k, const bool unique, std::string const &kbest_out_filename_) { WriteFile ko(kbest_out_filename_); - std::cerr << "Output kbest to " << kbest_out_filename_; + std::cerr << "Output kbest to " << kbest_out_filename_<(sent_id,forest,k,ko.get(),std::cerr); -- cgit v1.2.3