summaryrefslogtreecommitdiff
path: root/mteval/external_scorer.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2011-06-08 22:35:06 -0400
committerPatrick Simianer <p@simianer.de>2011-09-23 19:13:57 +0200
commitd820201b631c41db7376fc6abe0007a2e1e4acf0 (patch)
tree8595878b5fbaa47fcbaad73a4441a38b1da1e292 /mteval/external_scorer.h
parentd7f15837102e6f46cab0ce72ba019e125d779761 (diff)
rudimentary support for meteor via an external process. still needs configuration of path, but it should work
Diffstat (limited to 'mteval/external_scorer.h')
-rw-r--r--mteval/external_scorer.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/mteval/external_scorer.h b/mteval/external_scorer.h
index a2c91960..59ece269 100644
--- a/mteval/external_scorer.h
+++ b/mteval/external_scorer.h
@@ -3,15 +3,20 @@
#include <vector>
#include <cstdio>
+#include <string>
+#include <map>
+#include <boost/shared_ptr.hpp>
#include "scorer.h"
class ScoreServer {
- public:
+ friend class ScoreServerManager;
+ protected:
explicit ScoreServer(const std::string& cmd);
virtual ~ScoreServer();
- double ComputeScore(const std::vector<float>& fields);
+ public:
+ float ComputeScore(const std::vector<float>& fields);
void Evaluate(const std::vector<std::vector<WordID> >& refs, const std::vector<WordID>& hyp, std::vector<float>* fields);
private:
@@ -19,17 +24,22 @@ class ScoreServer {
FILE* pipe_;
};
+struct ScoreServerManager {
+ static ScoreServer* Instance(const std::string& score_type);
+ private:
+ static std::map<std::string, boost::shared_ptr<ScoreServer> > servers_;
+};
+
class ExternalSentenceScorer : public SentenceScorer {
public:
- virtual ScoreP ScoreCandidate(const Sentence& hyp) const = 0;
- virtual ScoreP ScoreCCandidate(const Sentence& hyp) const =0;
+ ExternalSentenceScorer(ScoreServer* server, const std::vector<std::vector<WordID> >& r) :
+ SentenceScorer("External", r), eval_server(server) {}
+ virtual ScoreP ScoreCandidate(const Sentence& hyp) const;
+ virtual ScoreP ScoreCCandidate(const Sentence& hyp) const;
+ static ScoreP ScoreFromString(ScoreServer* s, const std::string& data);
+
protected:
ScoreServer* eval_server;
};
-class METEORServer : public ScoreServer {
- public:
- METEORServer() : ScoreServer("java -Xmx1024m -jar meteor-1.3.jar - - -mira -lower") {}
-};
-
#endif