00001 // 00002 // StatisticsBasedScorer.h 00003 // mert_lib 00004 // 00005 // Created by Hieu Hoang on 23/06/2012. 00006 // Copyright 2012 __MyCompanyName__. All rights reserved. 00007 // 00008 00009 #ifndef mert_lib_StatisticsBasedScorer_h 00010 #define mert_lib_StatisticsBasedScorer_h 00011 00012 #include "Scorer.h" 00013 00014 #include "util/exception.hh" 00015 00016 namespace MosesTuning 00017 { 00018 00019 00024 class StatisticsBasedScorer : public Scorer 00025 { 00026 friend class HopeFearDecoder; 00027 00028 public: 00029 StatisticsBasedScorer(const std::string& name, const std::string& config); 00030 virtual ~StatisticsBasedScorer() {} 00031 virtual void score(const candidates_t& candidates, const diffs_t& diffs, 00032 statscores_t& scores) const; 00033 00034 protected: 00035 00036 enum RegularisationType { 00037 NONE, 00038 AVERAGE, 00039 MINIMUM 00040 }; 00041 00045 virtual statscore_t calculateScore(const std::vector<ScoreStatsType>& totals) const = 0; 00046 00047 virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const { 00048 UTIL_THROW(util::Exception, "getReferenceLength not implemented for this scorer type."); 00049 return 0; 00050 } 00051 00052 // regularisation 00053 RegularisationType m_regularization_type; 00054 std::size_t m_regularization_window; 00055 }; 00056 00057 } // namespace 00058 00059 #endif