summaryrefslogtreecommitdiff
path: root/decoder/viterbi.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-05-16 17:01:21 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-05-16 17:01:21 -0400
commit75d0f86f8f949e37c600096accf85d5521940f40 (patch)
tree0b7ab569d4642984a2fc90f5fd7eded1b36a21df /decoder/viterbi.h
parenta448faf30fa46c006b1d38c6aee64a7aad29ac5e (diff)
bjam cleanup
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_;
}