diff options
author | machacekmatous <machacekmatous@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-08-16 20:21:31 +0400 |
---|---|---|
committer | machacekmatous <machacekmatous@1f5c12ca-751b-0410-a591-d2e778427230> | 2011-08-16 20:21:31 +0400 |
commit | 3ef02eb7e644cbde201750a1cc7efa438e0b0293 (patch) | |
tree | 52ff232c6586298206119ffdf7ae7a790d6b7280 /mert/TerScorer.h | |
parent | 6dae77c3eb7568f095bbe712b7d121172b12e1bd (diff) |
merged in TER Scorer from mert-other_metrics (at r4140)
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@4146 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'mert/TerScorer.h')
-rw-r--r-- | mert/TerScorer.h | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/mert/TerScorer.h b/mert/TerScorer.h new file mode 100644 index 000000000..aaba29fed --- /dev/null +++ b/mert/TerScorer.h @@ -0,0 +1,67 @@ +#ifndef __TERSCORER_H__ +#define __TERSCORER_H__ + +// #include <stdio.h> +#include <algorithm> +#include <cmath> +#include <iostream> +#include <iterator> +#include <set> +#include <sstream> +#include <stdexcept> +#include <string> +#include <vector> +#include <limits.h> +#include "Types.h" +#include "ScoreData.h" +#include "Scorer.h" +#include "TERsrc/tercalc.h" +#include "TERsrc/terAlignment.h" + +using namespace std; +using namespace TERCpp; + +// enum TerReferenceLengthStrategy { TER_AVERAGE, TER_SHORTEST, TER_CLOSEST }; + + +/** + * Bleu scoring + **/ +class TerScorer: public StatisticsBasedScorer +{ +public: + TerScorer(const string& config = "") : StatisticsBasedScorer("TER",config) {} + virtual void setReferenceFiles(const vector<string>& referenceFiles); + virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry); + static const int LENGTH; + virtual void whoami() { + cerr << "I AM TerScorer" << std::endl; + } + size_t NumberOfScores() { + cerr << "TerScorer: " << (LENGTH + 1) << endl; + return (LENGTH + 1); + }; + + +// protected: + float calculateScore(const vector<int>& comps); + float calculateScore(const vector<float>& comps); + +private: + string javaEnv; + string tercomEnv; + //no copy + TerScorer(const TerScorer&); + ~TerScorer() {}; + TerScorer& operator=(const TerScorer&); + // data extracted from reference files + vector<size_t> _reflengths; + vector<multiset<int> > _reftokens; + vector<vector<int> > m_references; + vector<vector<vector<int> > > m_multi_references; + string m_pid; + +}; + + +#endif //__TERSCORER_H |