mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-19 07:07:24 +03:00
48533d1021
add method get ref length git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1669 1f5c12ca-751b-0410-a591-d2e778427230
74 lines
1.5 KiB
C++
74 lines
1.5 KiB
C++
#ifndef __SCORER_H__
|
|
#define __SCORER_H__
|
|
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "ScoreData.h"
|
|
|
|
class ScoreStats;
|
|
|
|
class Scorer {
|
|
|
|
public:
|
|
|
|
Scorer(const std::string& name): _name(name), _scoreData(0) {}
|
|
|
|
const std::string& getName() const {return _name;}
|
|
|
|
/**
|
|
* set the reference files. This must be called before prepareStats.
|
|
**/
|
|
void setReferenceFiles(const std::vector<std::string>& referenceFiles) {
|
|
//do nothing
|
|
}
|
|
|
|
|
|
size_t getReferenceSize() {
|
|
if (_scoreData) {
|
|
return _scoreData->size();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* Process the given guessed text, corresponding to the given reference sindex
|
|
* and add the appropriate statistics to the entry.
|
|
**/
|
|
virtual void prepareStats(int sindex, const std::string& text, ScoreStats& entry) {
|
|
//std::cerr << text << std::endl;
|
|
}
|
|
|
|
/**
|
|
* Set the score data, prior to scoring.
|
|
**/
|
|
void setScoreData(ScoreData* scoreData) {
|
|
_scoreData = scoreData;
|
|
}
|
|
|
|
/**
|
|
* Calculate the score of the sentences corresponding to the list of candidate
|
|
* indices. Each index indicates the 1-best choice from the n-best list.
|
|
**/
|
|
virtual float score(const std::vector<unsigned int>& candidates) {
|
|
if (!_scoreData) {
|
|
throw std::runtime_error("score data not loaded");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
|
|
protected:
|
|
ScoreData* _scoreData;
|
|
|
|
private:
|
|
std::string _name;
|
|
|
|
};
|
|
|
|
|
|
#endif //__SCORER_H
|