summaryrefslogtreecommitdiff
path: root/decoder
diff options
context:
space:
mode:
Diffstat (limited to 'decoder')
-rw-r--r--decoder/Jamfile7
-rw-r--r--decoder/decoder.cc12
-rw-r--r--decoder/hg.h6
-rw-r--r--decoder/viterbi.h18
4 files changed, 24 insertions, 19 deletions
diff --git a/decoder/Jamfile b/decoder/Jamfile
index f8112cae..871da4f6 100644
--- a/decoder/Jamfile
+++ b/decoder/Jamfile
@@ -61,9 +61,14 @@ lib cdec_lib :
../klm/lm//kenlm
..//boost_program_options
: <include>.
+ : :
+ <library>..//utils
+ <library>..//mteval
+ <library>../klm/lm//kenlm
+ <library>..//boost_program_options
;
-exe cdec : cdec.cc cdec_lib ;
+exe cdec : cdec.cc cdec_lib ..//utils ..//mteval ../klm/lm//kenlm ..//boost_program_options ;
all_tests [ glob *_test.cc : cfg_test.cc ] : cdec_lib : <testing.arg>$(TOP)/decoder/test_data ;
diff --git a/decoder/decoder.cc b/decoder/decoder.cc
index 4ce2ba86..487c7635 100644
--- a/decoder/decoder.cc
+++ b/decoder/decoder.cc
@@ -965,14 +965,14 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) {
{
ReadFile rf(writer.fname_);
bool succeeded = HypergraphIO::ReadFromJSON(rf.stream(), &new_hg);
- assert(succeeded);
+ if (!succeeded) abort();
}
new_hg.Union(forest);
bool succeeded = writer.Write(new_hg, false);
- assert(succeeded);
+ if (!succeeded) abort();
} else {
bool succeeded = writer.Write(forest, false);
- assert(succeeded);
+ if (!succeeded) abort();
}
}
@@ -1052,14 +1052,14 @@ bool DecoderImpl::Decode(const string& input, DecoderObserver* o) {
{
ReadFile rf(writer.fname_);
bool succeeded = HypergraphIO::ReadFromJSON(rf.stream(), &new_hg);
- assert(succeeded);
+ if (!succeeded) abort();
}
new_hg.Union(forest);
bool succeeded = writer.Write(new_hg, false);
- assert(succeeded);
+ if (!succeeded) abort();
} else {
bool succeeded = writer.Write(forest, false);
- assert(succeeded);
+ if (!succeeded) abort();
}
}
if (aligner_mode && !output_training_vector)
diff --git a/decoder/hg.h b/decoder/hg.h
index f0ddbb76..dfa4ac6d 100644
--- a/decoder/hg.h
+++ b/decoder/hg.h
@@ -189,7 +189,7 @@ public:
o<<'(';
show(o,show_mask);
if (indent) o<<'\n';
- for (int i=0;i<tail_nodes_.size();++i) {
+ for (unsigned i=0;i<tail_nodes_.size();++i) {
TEdgeHandle c=re(tail_nodes_[i],i,eh);
Edge const* cp=c;
if (cp) {
@@ -314,7 +314,7 @@ public:
private:
void index_tails(Edge const& edge) {
- for (int i = 0; i < edge.tail_nodes_.size(); ++i)
+ for (unsigned i = 0; i < edge.tail_nodes_.size(); ++i)
nodes_[edge.tail_nodes_[i]].out_edges_.push_back(edge.id_);
}
public:
@@ -348,7 +348,7 @@ public:
edge->rule_ = rule;
edge->tail_nodes_ = tail;
edge->id_ = eid;
- for (int i = 0; i < edge->tail_nodes_.size(); ++i)
+ for (unsigned i = 0; i < edge->tail_nodes_.size(); ++i)
nodes_[edge->tail_nodes_[i]].out_edges_.push_back(edge->id_);
return edge;
}
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_;
}