diff options
author | graehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-02 08:27:44 +0000 |
---|---|---|
committer | graehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-02 08:27:44 +0000 |
commit | 506cdc7562956b8bd2460f7dd55a307775eb68cb (patch) | |
tree | faeeeebdec6c0e12b9d4a6c26d8d02284e27fe84 | |
parent | c683b53f3553ed66c0261f653115a691d1bdb714 (diff) |
inside_outside
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@468 ec762483-ff6d-05da-a07a-a48fb63a330f
-rw-r--r-- | decoder/inside_outside.h | 12 |
1 files changed, 4 insertions, 8 deletions
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<V> &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]; |