From 41fa62485ce194e176ef0a7ff1fc8ebc42d5ffe7 Mon Sep 17 00:00:00 2001 From: graehl Date: Sun, 25 Jul 2010 21:03:23 +0000 Subject: USE_INFO_EDGE works for exh, cube git-svn-id: https://ws10smt.googlecode.com/svn/trunk@411 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/apply_models.cc | 17 +++++------------ decoder/hg.h | 45 ++++++++++++++++++++++++++++++--------------- 2 files changed, 35 insertions(+), 27 deletions(-) (limited to 'decoder') diff --git a/decoder/apply_models.cc b/decoder/apply_models.cc index 77d35c92..700296da 100644 --- a/decoder/apply_models.cc +++ b/decoder/apply_models.cc @@ -204,13 +204,8 @@ public: } void IncorporateIntoPlusLMForest(Candidate* item, State2Node* s2n, CandidateList* freelist) { - Hypergraph::Edge* new_edge = out.AddEdge(item->out_edge_.rule_, item->out_edge_.tail_nodes_); - new_edge->feature_values_ = item->out_edge_.feature_values_; + Hypergraph::Edge* new_edge = out.AddEdge(item->out_edge_); new_edge->edge_prob_ = item->out_edge_.edge_prob_; - new_edge->i_ = item->out_edge_.i_; - new_edge->j_ = item->out_edge_.j_; - new_edge->prev_i_ = item->out_edge_.prev_i_; - new_edge->prev_j_ = item->out_edge_.prev_j_; Candidate*& o_item = (*s2n)[item->state_]; if (!o_item) o_item = item; @@ -220,9 +215,12 @@ public: node_states_.push_back(item->state_); node_id = new_node->id_; } +#if 0 Hypergraph::Node* node = &out.nodes_[node_id]; out.ConnectEdgeToHeadNode(new_edge, node); - +#else + out.ConnectEdgeToHeadNode(new_edge, node_id); +#endif // update candidate if we have a better derivation // note: the difference between the vit score and the estimated // score is the same for all items with a common residual DP @@ -337,11 +335,6 @@ struct NoPruningRescorer { 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, tail); - new_edge->feature_values_ = in_edge.feature_values_; - new_edge->i_ = in_edge.i_; - new_edge->j_ = in_edge.j_; - new_edge->prev_i_ = in_edge.prev_i_; - new_edge->prev_j_ = in_edge.prev_j_; string head_state; if (is_goal) { assert(tail.size() == 1); diff --git a/decoder/hg.h b/decoder/hg.h index 95a6525a..c4159999 100644 --- a/decoder/hg.h +++ b/decoder/hg.h @@ -3,7 +3,9 @@ //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 + +// 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 # include # define INFO_EDGE(e,msg) do { std::ostringstream &o=(e.info_);o<AsString(mask&RULE_LHS); if (USE_INFO_EDGE) { - if (mask) o << ' '; - o<copy_features(in_edge); 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: + // oldest method in use - should use in parsing (no models) only, in rescoring requires much manual assignment from source edge; favor the previous instead Edge* AddEdge(const TRulePtr& rule, const TailNodeVector& tail) { int eid=edges_.size(); edges_.push_back(Edge()); @@ -274,17 +284,22 @@ public: return &nodes_.back(); } + //TODO: use indices everywhere? bottom two are a bit redundant. void ConnectEdgeToHeadNode(const int edge_id, const int head_id) { edges_[edge_id].head_node_ = head_id; nodes_[head_id].in_edges_.push_back(edge_id); } - // TODO remove this - use the version that takes indices void ConnectEdgeToHeadNode(Edge* edge, Node* head) { edge->head_node_ = head->id_; head->in_edges_.push_back(edge->id_); } + void ConnectEdgeToHeadNode(Edge* edge, int head_id) { + edge->head_node_ = head_id; + nodes_[head_id].in_edges_.push_back(edge->id_); + } + // merge the goal node from other with this goal node void Union(const Hypergraph& other); -- cgit v1.2.3