diff options
author | Michael Denkowski <michael.j.denkowski@gmail.com> | 2014-03-07 01:07:01 +0400 |
---|---|---|
committer | Michael Denkowski <michael.j.denkowski@gmail.com> | 2014-03-07 01:07:01 +0400 |
commit | bb201bbde8c674607285dce4d323e95456ca7ff0 (patch) | |
tree | 4df2df43b6517636872d9c011b515e2d86b00019 /mert/MeteorScorer.h | |
parent | 23556697c4e6831bfd0574351717f5a7b79dff77 (diff) |
Meteor scoring for Moses MERT
Diffstat (limited to 'mert/MeteorScorer.h')
-rw-r--r-- | mert/MeteorScorer.h | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/mert/MeteorScorer.h b/mert/MeteorScorer.h new file mode 100644 index 000000000..8e55c49a3 --- /dev/null +++ b/mert/MeteorScorer.h @@ -0,0 +1,81 @@ +#ifndef MERT_METEOR_SCORER_H_ +#define MERT_METEOR_SCORER_H_ + +#include <set> +#include <string> +#include <vector> + +#include <boost/thread/mutex.hpp> + +#include "Types.h" +#include "StatisticsBasedScorer.h" + +namespace MosesTuning +{ + +class ofdstream; +class ifdstream; +class ScoreStats; + +/** + * Meteor scoring + * + * https://github.com/mjdenkowski/meteor + * http://statmt.org/wmt11/pdf/WMT07.pdf + * + * Config: + * jar - location of meteor-*.jar (meteor-1.4.jar at time of writing) + * lang - optional language code (default: en) + * task - optional task (default: tune) + * m - optional quoted, space delimited module string "exact stem synonym paraphrase" (default varies by language) + * p - optional quoted, space delimited parameter string "alpha beta gamma delta" (default for tune: "0.5 1.0 0.5 0.5") + * w - optional quoted, space delimited weight string "w_exact w_stem w_synonym w_paraphrase" (default for tune: "1.0 0.5 0.5 0.5") + * + * Usage with mert-moses.pl: + * --mertargs="--sctype METEOR --scconfig jar:/path/to/meteor-1.4.jar" + */ +class MeteorScorer: public StatisticsBasedScorer +{ +public: + explicit MeteorScorer(const std::string& config = ""); + ~MeteorScorer(); + + virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles); + virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry); + + virtual std::size_t NumberOfScores() const { + // From edu.cmu.meteor.scorer.MeteorStats + // tstLen refLen tstFuncWords refFuncWords stage1tstMatchesContent + // stage1refMatchesContent stage1tstMatchesFunction stage1refMatchesFunction + // s2tc s2rc s2tf s2rf s3tc s3rc s3tf s3rf s4tc s4rc s4tf s4rf chunks + // tstwordMatches refWordMatches + return 23; + } + + virtual float calculateScore(const std::vector<int>& comps) const; + +private: + // Meteor and process IO + std::string meteor_jar; + std::string meteor_lang; + std::string meteor_task; + std::string meteor_m; + std::string meteor_p; + std::string meteor_w; + ofdstream* m_to_meteor; + ifdstream* m_from_meteor; + boost::mutex* mtx; + + // data extracted from reference files + std::vector<std::string> m_references; + std::vector<std::vector<std::string> > m_multi_references; + + // no copying allowed + MeteorScorer(const MeteorScorer&); + MeteorScorer& operator=(const MeteorScorer&); + +}; + +} + +#endif // MERT_METEOR_SCORER_H_ |