From b95ef85087cda78386ded6a886d050f34879b75c Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Wed, 16 May 2012 17:01:21 -0400 Subject: bjam cleanup --- Jamroot | 4 ++++ decoder/Jamfile | 7 ++++++- decoder/decoder.cc | 12 ++++++------ decoder/hg.h | 6 +++--- decoder/viterbi.h | 18 +++++++++--------- klm/util/Jamfile | 2 +- mteval/Jamfile | 2 +- 7 files changed, 30 insertions(+), 21 deletions(-) diff --git a/Jamroot b/Jamroot index f873db68..6daf7a9e 100644 --- a/Jamroot +++ b/Jamroot @@ -18,6 +18,10 @@ if [ test_header google/dense_hash_map ] || $(with-google-hash) { requirements += HAVE_SPARSEHASH $(with-google-hash) ; } +if [ test_header cmph.h ] || $(with-cmph) { + requirements += HAVE_CMPH $(with-cmph) ; +} + if [ test_header boost/serialization/map.hpp ] && [ test_library boost_serialization ] { requirements += HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP ; } 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 : . + : : + ..//utils + ..//mteval + ../klm/lm//kenlm + ..//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 : $(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;irule_ = 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 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& 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 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 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_; } diff --git a/klm/util/Jamfile b/klm/util/Jamfile index 00eefc22..b8c14347 100644 --- a/klm/util/Jamfile +++ b/klm/util/Jamfile @@ -1,4 +1,4 @@ -lib kenutil : bit_packing.cc ersatz_progress.cc exception.cc file.cc file_piece.cc mmap.cc murmur_hash.cc ../..///z : .. : : .. ; +lib kenutil : bit_packing.cc ersatz_progress.cc exception.cc file.cc file_piece.cc mmap.cc murmur_hash.cc ../..//z : .. : : .. ; import testing ; diff --git a/mteval/Jamfile b/mteval/Jamfile index 24a95e8f..6260caea 100644 --- a/mteval/Jamfile +++ b/mteval/Jamfile @@ -1,6 +1,6 @@ import testing ; -lib mteval : ter.cc comb_scorer.cc aer_scorer.cc scorer.cc external_scorer.cc ns.cc ns_ter.cc ns_ext.cc ns_comb.cc ns_docscorer.cc ..//utils : . : : . ; +lib mteval : ter.cc comb_scorer.cc aer_scorer.cc scorer.cc external_scorer.cc ns.cc ns_ter.cc ns_ext.cc ns_comb.cc ns_docscorer.cc ..//utils : . : : . ..//z ; exe fast_score : fast_score.cc mteval ..//utils ..//boost_program_options ; exe mbr_kbest : mbr_kbest.cc mteval ..//utils ..//boost_program_options ; alias programs : fast_score mbr_kbest ; -- cgit v1.2.3