Move regularizaion type into StatisticsBasedScorer.

The type is used as internal purpose.
This commit is contained in:
Tetsuo Kiso 2012-02-01 20:58:49 +09:00
parent b19e7777ce
commit a351a74c18
2 changed files with 15 additions and 10 deletions

View File

@ -63,11 +63,11 @@ StatisticsBasedScorer::StatisticsBasedScorer(const string& name, const string& c
string type = getConfig(KEY_TYPE,TYPE_NONE);
if (type == TYPE_NONE) {
m_regularization_type = REG_NONE;
m_regularization_type = NONE;
} else if (type == TYPE_AVERAGE) {
m_regularization_type = REG_AVERAGE;
m_regularization_type = AVERAGE;
} else if (type == TYPE_MINIMUM) {
m_regularization_type = REG_MINIMUM;
m_regularization_type = MINIMUM;
} else {
throw runtime_error("Unknown scorer regularisation strategy: " + type);
}
@ -135,7 +135,7 @@ void StatisticsBasedScorer::score(const candidates_t& candidates, const diffs_t
// Regularisation. This can either be none, or the min or average as described in
// Cer, Jurafsky and Manning at WMT08.
if (m_regularization_type == REG_NONE || m_regularization_window <= 0) {
if (m_regularization_type == NONE || m_regularization_window <= 0) {
// no regularisation
return;
}
@ -148,7 +148,7 @@ void StatisticsBasedScorer::score(const candidates_t& candidates, const diffs_t
start = i - m_regularization_window;
}
const size_t end = min(scores.size(), i + m_regularization_window + 1);
if (m_regularization_type == REG_AVERAGE) {
if (m_regularization_type == AVERAGE) {
scores[i] = score_average(raw_scores,start,end);
} else {
scores[i] = score_min(raw_scores,start,end);

View File

@ -11,8 +11,6 @@
using namespace std;
enum ScorerRegularisationStrategy {REG_NONE, REG_AVERAGE, REG_MINIMUM};
class ScoreStats;
/**
@ -165,20 +163,27 @@ private:
*/
class StatisticsBasedScorer : public Scorer
{
public:
public:
StatisticsBasedScorer(const string& name, const string& config);
virtual ~StatisticsBasedScorer() {}
virtual void score(const candidates_t& candidates, const diffs_t& diffs,
statscores_t& scores) const;
protected:
protected:
enum RegularisationType {
NONE,
AVERAGE,
MINIMUM,
};
/**
* Calculate the actual score.
*/
virtual statscore_t calculateScore(const vector<int>& totals) const = 0;
// regularisation
ScorerRegularisationStrategy m_regularization_type;
RegularisationType m_regularization_type;
size_t m_regularization_window;
};