00001 #ifndef MERT_INTERPOLATED_SCORER_H_ 00002 #define MERT_INTERPOLATED_SCORER_H_ 00003 00004 #include <string> 00005 #include <vector> 00006 #include "Types.h" 00007 #include "ScoreData.h" 00008 #include "Scorer.h" 00009 #include "ScopedVector.h" 00010 00011 namespace MosesTuning 00012 { 00013 00014 00018 class InterpolatedScorer : public Scorer 00019 { 00020 public: 00021 // name would be: "HAMMING,BLEU" or similar 00022 InterpolatedScorer(const std::string& name, const std::string& config); 00023 virtual ~InterpolatedScorer() {} 00024 00025 virtual void score(const candidates_t& candidates, const diffs_t& diffs, 00026 statscores_t& scores) const; 00027 00028 virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles); 00029 virtual void prepareStats(std::size_t sid, const std::string& text, ScoreStats& entry); 00030 00031 virtual std::size_t NumberOfScores() const { 00032 std::size_t sz = 0; 00033 for (ScopedVector<Scorer>::const_iterator itsc = m_scorers.begin(); 00034 itsc != m_scorers.end(); ++itsc) { 00035 sz += (*itsc)->NumberOfScores(); 00036 } 00037 return sz; 00038 } 00039 00040 virtual void setScoreData(ScoreData* data); 00041 00042 virtual float calculateScore(const std::vector<ScoreStatsType>& totals) const; 00043 00044 virtual float getReferenceLength(const std::vector<ScoreStatsType>& totals) const; 00045 00049 virtual void setFactors(const std::string& factors); 00050 00051 virtual void setFilter(const std::string& filterCommand); 00052 00053 bool useAlignment() const; 00054 00055 protected: 00056 ScopedVector<Scorer> m_scorers; 00057 00058 // Take the ownership of the heap-allocated the objects 00059 // by Scorer objects. 00060 ScopedVector<ScoreData> m_scorers_score_data; 00061 00062 std::vector<float> m_scorer_weights; 00063 }; 00064 00065 } 00066 00067 #endif // MERT_INTERPOLATED_SCORER_H_