From 05a43a89a5f52c4b473d99035e8777aadf1afea1 Mon Sep 17 00:00:00 2001 From: "graehl@gmail.com" Date: Mon, 2 Aug 2010 08:27:44 +0000 Subject: inside_outside git-svn-id: https://ws10smt.googlecode.com/svn/trunk@468 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/inside_outside.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'decoder') diff --git a/decoder/inside_outside.h b/decoder/inside_outside.h index 739b46fd..e3bd4592 100644 --- a/decoder/inside_outside.h +++ b/decoder/inside_outside.h @@ -38,9 +38,8 @@ WeightType Inside(const Hypergraph& hg, inside_score.resize(num_nodes); // std::fill(inside_score.begin(), inside_score.end(), WeightType()); // clear handles for (int i = 0; i < num_nodes; ++i) { - const Hypergraph::Node& cur_node = hg.nodes_[i]; WeightType* const cur_node_inside_score = &inside_score[i]; - Hypergraph::EdgesVector const& in=cur_node.in_edges_; + Hypergraph::EdgesVector const& in=hg.nodes_[i].in_edges_; const int num_in_edges = in.size(); if (num_in_edges == 0) { *cur_node_inside_score = WeightType(1); //FIXME: why not call weight(edge) instead? @@ -75,9 +74,8 @@ void Outside(const Hypergraph& hg, // std::fill(outside_score.begin(), outside_score.end(), WeightType()); // cleared outside_score.back() = scale_outside; for (int i = num_nodes - 1; i >= 0; --i) { - const Hypergraph::Node& cur_node = hg.nodes_[i]; const WeightType& head_node_outside_score = outside_score[i]; - Hypergraph::EdgesVector const& in=cur_node.in_edges_; + Hypergraph::EdgesVector const& in=hg.nodes_[i].in_edges_; const int num_in_edges = in.size(); for (int j = 0; j < num_in_edges; ++j) { const Hypergraph::Edge& edge = hg.edges_[in[j]]; @@ -141,8 +139,7 @@ struct InsideOutsides { typename XWeightFunction::Result expect(Hypergraph const& hg,XWeightFunction const& xwf=XWeightFunction()) { typename XWeightFunction::Result x; // default constructor is semiring 0 for (int i = 0,num_nodes=hg.nodes_.size(); i < num_nodes; ++i) { - const Hypergraph::Node& cur_node = hg.nodes_[i]; - Hypergraph::EdgesVector const& in=cur_node.in_edges_; + Hypergraph::EdgesVector const& in=hg.nodes_[i].in_edges_; const int num_in_edges = in.size(); for (int j = 0; j < num_in_edges; ++j) { const Hypergraph::Edge& edge = hg.edges_[in[j]]; @@ -159,8 +156,7 @@ struct InsideOutsides { void compute_edge_marginals(Hypergraph const& hg,std::vector &vs,VWeight const& weight) { vs.resize(hg.edges_.size()); for (int i = 0,num_nodes=hg.nodes_.size(); i < num_nodes; ++i) { - const Hypergraph::Node& cur_node = hg.nodes_[i]; - Hypergraph::EdgesVector const& in=cur_node.in_edges_; + Hypergraph::EdgesVector const& in=hg.nodes_[i].in_edges_; const int num_in_edges = in.size(); for (int j = 0; j < num_in_edges; ++j) { int edgei=in[j]; -- cgit v1.2.3