diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2011-06-08 22:35:06 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2011-06-08 22:35:06 -0400 |
commit | 572f12ba11cee5ca55f292a89d4c5130f8b261eb (patch) | |
tree | 8595878b5fbaa47fcbaad73a4441a38b1da1e292 /mteval/external_scorer.h | |
parent | dc9cd6987abdfc703f50e924fa9e55dc702d5242 (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.h | 28 |
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 |