summaryrefslogtreecommitdiff
path: root/mteval
diff options
context:
space:
mode:
authorChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-03-19 20:51:58 -0400
committerChris Dyer <cdyer@allegro.clab.cs.cmu.edu>2014-03-19 20:51:58 -0400
commitaeae0ee8ec2369b7b2ce5972fca74749ded7b229 (patch)
tree1b4ac347b0a2d22b203c727693997139a763efb7 /mteval
parent0bcf79ae9cc8e1d549ff36dc4f9ece7383687d27 (diff)
fix meteor bugs with mira
Diffstat (limited to 'mteval')
-rw-r--r--mteval/external_scorer.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/mteval/external_scorer.cc b/mteval/external_scorer.cc
index 1c09c2a1..f1b3ed6e 100644
--- a/mteval/external_scorer.cc
+++ b/mteval/external_scorer.cc
@@ -9,22 +9,34 @@
#include <cassert>
#include "stringlib.h"
+#include "filelib.h"
#include "tdict.h"
using namespace std;
+extern const char* meteor_jar_path;
+
map<string, boost::shared_ptr<ScoreServer> > ScoreServerManager::servers_;
class METEORServer : public ScoreServer {
public:
- METEORServer() : ScoreServer("java -Xmx1024m -jar /usr0/cdyer/meteor/meteor-1.3.jar - - -mira -lower -t tune -l en") {}
+ METEORServer(const string& cmd) : ScoreServer(cmd) {}
};
ScoreServer* ScoreServerManager::Instance(const string& score_type) {
boost::shared_ptr<ScoreServer>& s = servers_[score_type];
if (!s) {
if (score_type == "meteor") {
- s.reset(new METEORServer);
+#if HAVE_METEOR
+ if (!FileExists(meteor_jar_path)) {
+ cerr << meteor_jar_path << " not found!\n";
+ abort();
+ }
+ s.reset(new METEORServer(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 {
cerr << "Don't know how to create score server for type '" << score_type << "'\n";
abort();
@@ -138,7 +150,11 @@ struct ExternalScore : public ScoreBase<ExternalScore> {
assert(!"not implemented"); // no idea
}
void PlusEquals(const Score& delta, const float scale) {
- assert(!"not implemented"); // don't even know what this is
+ if (static_cast<const ExternalScore&>(delta).score_server) score_server = static_cast<const ExternalScore&>(delta).score_server;
+ if (fields.size() != static_cast<const ExternalScore&>(delta).fields.size())
+ fields.resize(max(fields.size(), static_cast<const ExternalScore&>(delta).fields.size()));
+ for (unsigned i = 0; i < static_cast<const ExternalScore&>(delta).fields.size(); ++i)
+ fields[i] += static_cast<const ExternalScore&>(delta).fields[i] * scale;
}
void PlusEquals(const Score& delta) {
if (static_cast<const ExternalScore&>(delta).score_server) score_server = static_cast<const ExternalScore&>(delta).score_server;