summaryrefslogtreecommitdiff
path: root/decoder/viterbi.h
diff options
context:
space:
mode:
authorVictor Chahuneau <vchahune@cs.cmu.edu>2012-05-17 10:46:23 -0400
committerVictor Chahuneau <vchahune@cs.cmu.edu>2012-05-17 10:46:23 -0400
commit3d44c4e9c80472c4e3f39bfbf730c192328c839c (patch)
treeb5ab7097634b3d5d1071bd53844fe368ec1dd8dc /decoder/viterbi.h
parent141f566baf82129fd339fa28e1e98a17c6e37dcc (diff)
parent75d0f86f8f949e37c600096accf85d5521940f40 (diff)
Merge branch 'master' of https://github.com/redpony/cdec
Diffstat (limited to 'decoder/viterbi.h')
-rw-r--r--decoder/viterbi.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/decoder/viterbi.h b/decoder/viterbi.h
index daee3d7a..3092f6da 100644
--- a/decoder/viterbi.h
+++ b/decoder/viterbi.h
@@ -32,16 +32,16 @@ typename WeightFunction::Weight Viterbi(const Hypergraph& hg,
WeightType* const cur_node_best_weight = &vit_weight[i];
T* const cur_node_best_result = &vit_result[i];
- const int num_in_edges = cur_node.in_edges_.size();
+ const unsigned num_in_edges = cur_node.in_edges_.size();
if (num_in_edges == 0) {
*cur_node_best_weight = WeightType(1);
continue;
}
Hypergraph::Edge const* edge_best=0;
- for (int j = 0; j < num_in_edges; ++j) {
+ for (unsigned j = 0; j < num_in_edges; ++j) {
const Hypergraph::Edge& edge = hg.edges_[cur_node.in_edges_[j]];
WeightType score = weight(edge);
- for (int k = 0; k < edge.tail_nodes_.size(); ++k)
+ for (unsigned k = 0; k < edge.tail_nodes_.size(); ++k)
score *= vit_weight[edge.tail_nodes_[k]];
if (!edge_best || *cur_node_best_weight < score) {
*cur_node_best_weight = score;
@@ -51,7 +51,7 @@ typename WeightFunction::Weight Viterbi(const Hypergraph& hg,
assert(edge_best);
Hypergraph::Edge const& edgeb=*edge_best;
std::vector<const T*> antsb(edgeb.tail_nodes_.size());
- for (int k = 0; k < edgeb.tail_nodes_.size(); ++k)
+ for (unsigned k = 0; k < edgeb.tail_nodes_.size(); ++k)
antsb[k] = &vit_result[edgeb.tail_nodes_[k]];
traverse(edgeb, antsb, cur_node_best_result);
}
@@ -101,7 +101,7 @@ struct PathLengthTraversal {
int* result) const {
(void) edge;
*result = 1;
- for (int i = 0; i < ants.size(); ++i) *result += *ants[i];
+ for (unsigned i = 0; i < ants.size(); ++i) *result += *ants[i];
}
};
@@ -120,7 +120,7 @@ struct ELengthTraversal {
const std::vector<const int*>& ants,
int* result) const {
*result = edge.rule_->ELength() - edge.rule_->Arity();
- for (int i = 0; i < ants.size(); ++i) *result += *ants[i];
+ for (unsigned i = 0; i < ants.size(); ++i) *result += *ants[i];
}
};
@@ -179,8 +179,8 @@ struct ViterbiPathTraversal {
void operator()(const Hypergraph::Edge& edge,
std::vector<Result const*> const& ants,
Result* result) const {
- for (int i = 0; i < ants.size(); ++i)
- for (int j = 0; j < ants[i]->size(); ++j)
+ for (unsigned i = 0; i < ants.size(); ++i)
+ for (unsigned j = 0; j < ants[i]->size(); ++j)
result->push_back((*ants[i])[j]);
result->push_back(&edge);
}
@@ -191,7 +191,7 @@ struct FeatureVectorTraversal {
void operator()(Hypergraph::Edge const& edge,
std::vector<Result const*> const& ants,
Result* result) const {
- for (int i = 0; i < ants.size(); ++i)
+ for (unsigned i = 0; i < ants.size(); ++i)
*result+=*ants[i];
*result+=edge.feature_values_;
}