00001 #ifndef MERT_HWCM_SCORER_H_
00002 #define MERT_HWCM_SCORER_H_
00003
00004 #include <string>
00005 #include <vector>
00006
00007 #include "StatisticsBasedScorer.h"
00008 #include "InternalTree.h"
00009
00010 namespace MosesTuning
00011 {
00012
00013
00014 class ScoreStats;
00015 const size_t kHwcmOrder = 4;
00016
00020 class HwcmScorer: public StatisticsBasedScorer
00021 {
00022 public:
00023 explicit HwcmScorer(const std::string& config = "");
00024 ~HwcmScorer();
00025
00026 virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles);
00027 virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry);
00028
00029 virtual std::size_t NumberOfScores() const {
00030 return kHwcmOrder*3;
00031 }
00032
00033 virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const;
00034
00035 virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const {
00036 return totals[2];
00037 }
00038
00039
00040 bool useAlignment() const {
00041 return true;
00042 }
00043
00044 private:
00045
00046
00047 std::vector<TreePointer> m_ref_trees;
00048 std::vector<std::vector<std::map<std::string, int> > > m_ref_hwc;
00049 std::vector<std::vector<int> > m_ref_lengths;
00050
00051 void extractHeadWordChain(TreePointer tree, std::vector<std::string> & history, std::vector<std::map<std::string, int> > & hwc);
00052 std::string getHead(TreePointer tree);
00053
00054
00055 HwcmScorer(const HwcmScorer&);
00056 HwcmScorer& operator=(const HwcmScorer&);
00057 };
00058
00059 }
00060
00061 #endif // MERT_HWCM_SCORER_H_