2012-06-22 21:19:16 +04:00
|
|
|
#ifndef __PERMUTATIONSCORER_H__
|
|
|
|
#define __PERMUTATIONSCORER_H__
|
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
#include <cmath>
|
|
|
|
#include <iostream>
|
|
|
|
#include <iterator>
|
|
|
|
#include <set>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdexcept>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2015-03-28 16:20:58 +03:00
|
|
|
#include <climits>
|
2012-06-22 21:19:16 +04:00
|
|
|
#include "Types.h"
|
|
|
|
#include "ScoreData.h"
|
|
|
|
#include "Scorer.h"
|
|
|
|
#include "Permutation.h"
|
2012-06-24 06:51:48 +04:00
|
|
|
#include "StatisticsBasedScorer.h"
|
2012-06-22 21:19:16 +04:00
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
namespace MosesTuning
|
|
|
|
{
|
2013-05-29 21:16:15 +04:00
|
|
|
|
2012-06-22 21:19:16 +04:00
|
|
|
/**
|
|
|
|
* Permutation
|
|
|
|
**/
|
2012-06-24 06:51:48 +04:00
|
|
|
class PermutationScorer: public StatisticsBasedScorer
|
2012-06-22 21:19:16 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
PermutationScorer(const std::string &distanceMetric = "HAMMING",
|
|
|
|
const std::string &config = std::string());
|
|
|
|
void setReferenceFiles(const std::vector<std::string>& referenceFiles);
|
|
|
|
void prepareStats(size_t sid, const std::string& text, ScoreStats& entry);
|
|
|
|
static const int SCORE_PRECISION;
|
2012-09-24 17:40:18 +04:00
|
|
|
static const int SCORE_MULTFACT;
|
2012-06-22 21:19:16 +04:00
|
|
|
|
|
|
|
size_t NumberOfScores() const {
|
|
|
|
//cerr << "PermutationScorer number of scores: 1" << endl;
|
2012-09-24 17:40:18 +04:00
|
|
|
//return 1;
|
|
|
|
|
|
|
|
//cerr << "PermutationScorer number of scores: 2" << endl;
|
|
|
|
//the second it is just a counter for the normalization of the amount of test sentences
|
|
|
|
return 2;
|
2012-06-22 21:19:16 +04:00
|
|
|
};
|
|
|
|
bool useAlignment() const {
|
|
|
|
//cout << "PermutationScorer::useAlignment returning true" << endl;
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
2012-06-23 05:07:05 +04:00
|
|
|
|
2012-06-22 21:19:16 +04:00
|
|
|
protected:
|
2014-09-16 19:36:45 +04:00
|
|
|
statscore_t calculateScore(const std::vector<ScoreStatsType>& scores) const;
|
2012-06-22 21:19:16 +04:00
|
|
|
PermutationScorer(const PermutationScorer&);
|
|
|
|
~PermutationScorer() {};
|
|
|
|
PermutationScorer& operator=(const PermutationScorer&);
|
|
|
|
int getNumberWords (const std::string & line) const;
|
|
|
|
|
|
|
|
distanceMetricReferenceChoice_t m_refChoiceStrategy;
|
|
|
|
distanceMetric_t m_distanceMetric;
|
|
|
|
|
|
|
|
// data extracted from reference files
|
|
|
|
// A vector of permutations for each reference file
|
|
|
|
std::vector< std::vector<Permutation> > m_referencePerms;
|
|
|
|
std::vector<size_t> m_sourceLengths;
|
|
|
|
std::vector<std::string> m_referenceAlignments;
|
|
|
|
|
|
|
|
private:
|
|
|
|
};
|
|
|
|
//TODO need to read in floats for scores - necessary for selecting mean reference strategy and for BLEU?
|
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
}
|
2012-06-22 21:19:16 +04:00
|
|
|
|
|
|
|
#endif //__PERMUTATIONSCORER_H
|
|
|
|
|
2012-06-30 23:23:45 +04:00
|
|
|
|