00001 #ifndef MERT_M2_SCORER_H_
00002 #define MERT_M2_SCORER_H_
00003
00004 #include <string>
00005 #include <vector>
00006 #include <functional>
00007
00008 #include "Types.h"
00009 #include "Util.h"
00010 #include "StatisticsBasedScorer.h"
00011 #include "M2.h"
00012
00013 namespace MosesTuning
00014 {
00015
00019 class M2Scorer: public StatisticsBasedScorer
00020 {
00021 public:
00022 explicit M2Scorer(const std::string& config);
00023
00024 virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles);
00025 virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry);
00026
00027 virtual std::size_t NumberOfScores() const {
00028 return 4;
00029 }
00030
00031 virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const;
00032 virtual float getReferenceLength(const std::vector<ScoreStatsType>& comps) const;
00033
00034 private:
00035 float beta_;
00036 int max_unchanged_words_;
00037 bool truecase_;
00038 bool verbose_;
00039 M2::M2 m2_;
00040
00041 std::map<std::pair<size_t, std::string>, std::vector<ScoreStatsType> > seen_;
00042
00043
00044 M2Scorer(const M2Scorer&);
00045 M2Scorer& operator=(const M2Scorer&);
00046 };
00047
00048 float sentenceM2 (const std::vector<ScoreStatsType>& stats);
00049
00050 }
00051
00052 #endif // MERT_M2_SCORER_H_