From 2d3948b98bb9e8c7bad60f1acd99ff0b42b3ae30 Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 10 Nov 2013 00:58:44 -0500 Subject: guard against direct includes of tr1 --- mteval/scorer.cc | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'mteval/scorer.cc') diff --git a/mteval/scorer.cc b/mteval/scorer.cc index de84e076..9eb9a76e 100644 --- a/mteval/scorer.cc +++ b/mteval/scorer.cc @@ -594,26 +594,29 @@ void DocScorer::Init( const ScoreType type, const vector& ref_files, const string& src_file, bool verbose) { + cerr << "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" + "!!! This code is using the deprecated DocScorer interface, please fix !!!\n" + "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n"; scorers_.clear(); - // TODO stop using valarray, start using ReadFile + static const WordID kDIV = TD::Convert("|||"); cerr << "Loading references (" << ref_files.size() << " files)\n"; ReadFile srcrf; if (type == AER && src_file.size() > 0) { cerr << " (source=" << src_file << ")\n"; srcrf.Init(src_file); } + std::vector tmp; std::vector ifs(ref_files.begin(),ref_files.end()); for (int i=0; i < ref_files.size(); ++i) ifs[i].Init(ref_files[i]); char buf[64000]; bool expect_eof = false; int line=0; while (ifs[0].get()) { - vector > refs(ref_files.size()); + vector > refs; for (int i=0; i < ref_files.size(); ++i) { istream &in=ifs[i].get(); if (in.eof()) break; in.getline(buf, 64000); - refs[i].clear(); if (strlen(buf) == 0) { if (in.eof()) { if (!expect_eof) { @@ -622,9 +625,17 @@ void DocScorer::Init( } break; } - } else { - TD::ConvertSentence(buf, &refs[i]); - assert(!refs[i].empty()); + } else { // process reference + tmp.clear(); + TD::ConvertSentence(buf, &tmp); + unsigned last = 0; + for (unsigned j = 0; j < tmp.size(); ++j) { + if (tmp[j] == kDIV) { + refs.push_back(vector(tmp.begin() + last, tmp.begin() + j)); + last = j + 1; + } + } + refs.push_back(vector(tmp.begin() + last, tmp.end())); } assert(!expect_eof); } -- cgit v1.2.3 From 73a5e89074c7a531caee6faa72cfd9c22dafa43e Mon Sep 17 00:00:00 2001 From: Chris Dyer Date: Sun, 10 Nov 2013 13:22:23 -0500 Subject: fix for mavericks --- Makefile.am | 7 ++++--- configure.ac | 6 +++--- decoder/ff_context.cc | 2 +- decoder/phrasebased_translator.cc | 9 ++++++--- mteval/ns.cc | 2 +- mteval/scorer.cc | 2 +- 6 files changed, 16 insertions(+), 12 deletions(-) (limited to 'mteval/scorer.cc') diff --git a/Makefile.am b/Makefile.am index 1c30a6ff..3438c0a4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,12 +14,13 @@ SUBDIRS = \ training \ training/liblbfgs \ word-aligner \ - example_extff \ - extractor + example_extff + +# extractor #gi/pyp-topics/src gi/clda/src gi/posterior-regularisation/prjava -EXTRA_DIST = corpus tests python/pkg python/src python/tests python/examples compound-split environment +EXTRA_DIST = corpus tests python/tests python/examples compound-split environment AUTOMAKE_OPTIONS = foreign ACLOCAL_AMFLAGS = -I m4 AM_CPPFLAGS = -D_GLIBCXX_PARALLEL -march=native -mtune=native -O2 -pipe -fomit-frame-pointer -Wall diff --git a/configure.ac b/configure.ac index e4183c15..9c3e692b 100644 --- a/configure.ac +++ b/configure.ac @@ -185,13 +185,13 @@ AC_CHECK_HEADER(google/dense_hash_map, AC_PROG_INSTALL -CPPFLAGS="-DPIC -fPIC $CXX11_SWITCH $CPPFLAGS -DHAVE_CONFIG_H -DKENLM_MAX_ORDER=6" +CPPFLAGS="-DPIC -fPIC $CPPFLAGS -DHAVE_CONFIG_H -DKENLM_MAX_ORDER=6" +CXXFLAGS="$CXX11_SWITCH $CXXFLAGS" if test "x$HAVE_CXX11" = "x0"; then CPPFLAGS="$CPPFLAGS -DHAVE_OLD_CPP" fi - # core cdec stuff AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([utils/Makefile]) @@ -199,7 +199,7 @@ AC_CONFIG_FILES([mteval/Makefile]) AC_CONFIG_FILES([mteval/meteor_jar.cc]) AC_CONFIG_FILES([decoder/Makefile]) AC_CONFIG_FILES([python/setup.py]) -AC_CONFIG_FILES([extractor/Makefile]) +# AC_CONFIG_FILES([extractor/Makefile]) AC_CONFIG_FILES([word-aligner/Makefile]) # KenLM stuff diff --git a/decoder/ff_context.cc b/decoder/ff_context.cc index f2b0e67c..e56f6f1f 100644 --- a/decoder/ff_context.cc +++ b/decoder/ff_context.cc @@ -46,7 +46,7 @@ void RuleContextFeatures::ReplaceMacroWithString( macro << relative_location << "]"; int macro_index = feature_instance.find(macro.str()); if (macro_index == string::npos) { - cerr << "Can't find macro " << macro << " in feature template " + cerr << "Can't find macro " << macro.str() << " in feature template " << feature_instance; abort(); } diff --git a/decoder/phrasebased_translator.cc b/decoder/phrasebased_translator.cc index 04b3e5d2..8048248e 100644 --- a/decoder/phrasebased_translator.cc +++ b/decoder/phrasebased_translator.cc @@ -54,10 +54,13 @@ struct Coverage : public vector { }; struct CoverageHash { size_t operator()(const Coverage& cov) const { - return hasher_(static_cast&>(cov)); + int seed = 131; + size_t res = 0; + for (vector::const_iterator it = cov.begin(); it != cov.end(); ++it) { + res = (res * seed) + (*it + 1); + } + return res; } - private: - boost::hash > hasher_; }; ostream& operator<<(ostream& os, const Coverage& cov) { os << '['; diff --git a/mteval/ns.cc b/mteval/ns.cc index b64d4798..c1ea238b 100644 --- a/mteval/ns.cc +++ b/mteval/ns.cc @@ -106,7 +106,7 @@ struct BleuSegmentEvaluator : public SegmentEvaluator { } struct NGramCompare { - int operator() (const vector& a, const vector& b) { + int operator() (const vector& a, const vector& b) const { const size_t as = a.size(); const size_t bs = b.size(); const size_t s = (as < bs ? as : bs); diff --git a/mteval/scorer.cc b/mteval/scorer.cc index 9eb9a76e..fedbca91 100644 --- a/mteval/scorer.cc +++ b/mteval/scorer.cc @@ -198,7 +198,7 @@ class BLEUScorerBase : public SentenceScorer { virtual float ComputeRefLength(const vector& hyp) const = 0; private: struct NGramCompare { - int operator() (const vector& a, const vector& b) { + int operator() (const vector& a, const vector& b) const { size_t as = a.size(); size_t bs = b.size(); const size_t s = (as < bs ? as : bs); -- cgit v1.2.3