summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-11-17 17:21:30 -0500
committerChris Dyer <cdyer@cs.cmu.edu>2012-11-17 17:21:30 -0500
commit1a43362c3aa079688415ec89d67ee0f41210f9dd (patch)
tree7f28aa6caf209581130b2ae6d3886e82e2726e93
parentdb9897bcafe5f732cee5c1c0fe5c9d9eaecdef0e (diff)
make meteor jar configurable at build time
-rw-r--r--configure.ac23
-rw-r--r--mteval/Makefile.am14
-rw-r--r--mteval/ns.cc17
3 files changed, 42 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac
index cb132d66..233009ca 100644
--- a/configure.ac
+++ b/configure.ac
@@ -13,6 +13,7 @@ AC_LANG_CPLUSPLUS
BOOST_REQUIRE([1.44])
BOOST_PROGRAM_OPTIONS
BOOST_SYSTEM
+BOOST_SERIALIZATION
BOOST_TEST
AM_PATH_PYTHON
AC_CHECK_HEADER(dlfcn.h,AC_DEFINE(HAVE_DLFCN_H))
@@ -26,10 +27,24 @@ AM_CONDITIONAL([MPI], [test "x$mpi" = xyes])
if test "x$mpi" = xyes
then
- BOOST_SERIALIZATION
AC_DEFINE([HAVE_MPI], [1], [flag for MPI])
- # TODO BOOST_MPI needs to be implemented
- LIBS="$LIBS -lboost_mpi $BOOST_SERIALIZATION_LIBS"
+ LIBS="$LIBS -lboost_mpi"
+fi
+
+AM_CONDITIONAL([HAVE_METEOR], false)
+AC_ARG_WITH(meteor,
+ [AC_HELP_STRING([--with-meteor=PATH], [(optional) path to METEOR jar])],
+ [with_meteor=$withval],
+ [with_meteor=no]
+ )
+
+if test "x$with_meteor" != 'xno'
+then
+ AC_CHECK_FILE([$with_meteor],
+ [AC_DEFINE([HAVE_METEOR], [1], [flag for METEOR jar library])],
+ [AC_MSG_ERROR([Cannot find METEOR jar!])])
+ AC_SUBST(METEOR_JAR,"${with_meteor}")
+ AM_CONDITIONAL([HAVE_METEOR], true)
fi
AM_CONDITIONAL([HAVE_CMPH], false)
@@ -129,6 +144,8 @@ AC_CONFIG_FILES([mira/Makefile])
AC_CONFIG_FILES([dtrain/Makefile])
AC_CONFIG_FILES([example_extff/Makefile])
+AC_CONFIG_FILES([mteval/meteor_jar.cc])
+
AC_CONFIG_FILES([python/setup.py])
AC_OUTPUT
diff --git a/mteval/Makefile.am b/mteval/Makefile.am
index 22550c99..5e9bba91 100644
--- a/mteval/Makefile.am
+++ b/mteval/Makefile.am
@@ -8,7 +8,19 @@ TESTS = scorer_test
noinst_LIBRARIES = libmteval.a
-libmteval_a_SOURCES = 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 ns_cer.cc
+libmteval_a_SOURCES = \
+ aer_scorer.cc \
+ comb_scorer.cc \
+ external_scorer.cc \
+ meteor_jar.cc \
+ ns.cc \
+ ns_cer.cc \
+ ns_comb.cc \
+ ns_docscorer.cc \
+ ns_ext.cc \
+ ns_ter.cc \
+ scorer.cc \
+ ter.cc
fast_score_SOURCES = fast_score.cc
fast_score_LDADD = libmteval.a $(top_srcdir)/utils/libutils.a -lz
diff --git a/mteval/ns.cc b/mteval/ns.cc
index f3a82ce0..7d73061c 100644
--- a/mteval/ns.cc
+++ b/mteval/ns.cc
@@ -19,6 +19,8 @@ using namespace std;
map<string, EvaluationMetric*> EvaluationMetric::instances_;
+extern const char* meteor_jar_path;
+
SegmentEvaluator::~SegmentEvaluator() {}
EvaluationMetric::~EvaluationMetric() {}
@@ -235,13 +237,7 @@ struct BleuMetric : public EvaluationMetric {
EvaluationMetric* EvaluationMetric::Instance(const string& imetric_id) {
static bool is_first = true;
- static string meteor_jar_path = "/cab0/tools/meteor-1.3/meteor-1.3.jar";
if (is_first) {
- const char* ppath = getenv("METEOR_JAR");
- if (ppath) {
- cerr << "METEOR_JAR environment variable set to " << ppath << endl;
- meteor_jar_path = ppath;
- }
instances_["NULL"] = NULL;
is_first = false;
}
@@ -259,11 +255,16 @@ EvaluationMetric* EvaluationMetric::Instance(const string& imetric_id) {
} else if (metric_id == "TER") {
m = new TERMetric;
} else if (metric_id == "METEOR") {
+#if HAVE_METEOR
if (!FileExists(meteor_jar_path)) {
- cerr << meteor_jar_path << " not found. Set METEOR_JAR environment variable.\n";
+ cerr << meteor_jar_path << " not found!\n";
abort();
}
- m = new ExternalMetric("METEOR", "java -Xmx1536m -jar " + meteor_jar_path + " - - -mira -lower -t tune -l en");
+ m = new ExternalMetric("METEOR", string("java -Xmx1536m -jar ") + meteor_jar_path + " - - -mira -lower -t tune -l en");
+#else
+ cerr << "cdec was not built with the --with-meteor option." << endl;
+ abort();
+#endif
} else if (metric_id.find("COMB:") == 0) {
m = new CombinationMetric(metric_id);
} else if (metric_id == "CER") {