|
#ifndef MERT_HWCM_SCORER_H_ |
|
#define MERT_HWCM_SCORER_H_ |
|
|
|
#include <string> |
|
#include <vector> |
|
|
|
#include "StatisticsBasedScorer.h" |
|
#include "InternalTree.h" |
|
|
|
namespace MosesTuning |
|
{ |
|
|
|
|
|
class ScoreStats; |
|
const size_t kHwcmOrder = 4; |
|
|
|
|
|
|
|
|
|
class HwcmScorer: public StatisticsBasedScorer |
|
{ |
|
public: |
|
explicit HwcmScorer(const std::string& config = ""); |
|
~HwcmScorer(); |
|
|
|
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 { |
|
return kHwcmOrder*3; |
|
} |
|
|
|
virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const; |
|
|
|
virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const { |
|
return totals[2]; |
|
} |
|
|
|
|
|
bool useAlignment() const { |
|
return true; |
|
} |
|
|
|
private: |
|
|
|
|
|
std::vector<TreePointer> m_ref_trees; |
|
std::vector<std::vector<std::map<std::string, int> > > m_ref_hwc; |
|
std::vector<std::vector<int> > m_ref_lengths; |
|
|
|
void extractHeadWordChain(TreePointer tree, std::vector<std::string> & history, std::vector<std::map<std::string, int> > & hwc); |
|
std::string getHead(TreePointer tree); |
|
|
|
|
|
HwcmScorer(const HwcmScorer&); |
|
HwcmScorer& operator=(const HwcmScorer&); |
|
}; |
|
|
|
} |
|
|
|
#endif |