00001 #ifndef MERT_SEMPOSSCORER_H_
00002 #define MERT_SEMPOSSCORER_H_
00003
00004 #include <map>
00005 #include <string>
00006 #include <utility>
00007 #include <vector>
00008 #include <boost/scoped_ptr.hpp>
00009
00010 #include "Scorer.h"
00011
00012
00013
00014
00015
00016
00017 #include "SemposOverlapping.h"
00018 #include "StatisticsBasedScorer.h"
00019
00020 namespace MosesTuning
00021 {
00022
00023
00027 class SemposScorer: public StatisticsBasedScorer
00028 {
00029 public:
00030 explicit SemposScorer(const std::string& config);
00031 ~SemposScorer();
00032
00033 virtual void setReferenceFiles(const std::vector<std::string>& referenceFiles);
00034 virtual void prepareStats(std::size_t sindex, const std::string& text, ScoreStats& entry);
00035 virtual std::size_t NumberOfScores() const {
00036 return m_ovr->NumberOfScores();
00037 }
00038 virtual float calculateScore(const std::vector<ScoreStatsType>& comps) const {
00039 return m_ovr->calculateScore(comps);
00040 }
00041
00042 bool EnableDebug() const {
00043 return m_enable_debug;
00044 }
00045
00046 float weight(int item) const;
00047
00048 private:
00049 boost::scoped_ptr<SemposOverlapping> m_ovr;
00050 std::vector<std::vector<sentence_t> > m_ref_sentences;
00051
00052 typedef std::map<std::string, int> encoding_t;
00053 typedef encoding_t::iterator encoding_it;
00054
00055 encoding_t m_semposMap;
00056 encoding_t m_stringMap;
00057 bool m_enable_debug;
00058
00059 void splitSentence(const std::string& sentence, str_sentence_t& splitSentence);
00060 void encodeSentence(const str_sentence_t& sentence, sentence_t& encodedSentence);
00061 int encodeString(const std::string& str);
00062 int encodeSempos(const std::string& sempos);
00063
00064 std::map<int, float> weightsMap;
00065
00066 void loadWeights(const std::string& weightsfile);
00067
00068
00069 SemposScorer(const SemposScorer&);
00070 SemposScorer& operator=(const SemposScorer&);
00071 };
00072
00073 }
00074
00075 #endif // MERT_SEMPOSSCORER_H_