From 0393183eb489aa4a7334cbf0af37cfa60b4957db Mon Sep 17 00:00:00 2001 From: nicolabertoldi Date: Wed, 5 Aug 2009 15:38:35 +0000 Subject: mert software now works with different reference length policies: shortest, average, closest (default) and with case information (default is preserving case). Pay attention that both defaults are different from the previous version (which were shortest reflen and case-insensitive). git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@2459 1f5c12ca-751b-0410-a591-d2e778427230 --- mert/BleuScorer.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'mert/BleuScorer.h') diff --git a/mert/BleuScorer.h b/mert/BleuScorer.h index fc5d5f332..cd2471b55 100644 --- a/mert/BleuScorer.h +++ b/mert/BleuScorer.h @@ -25,7 +25,26 @@ enum BleuReferenceLengthStrategy { BLEU_AVERAGE, BLEU_SHORTEST, BLEU_CLOSEST }; **/ class BleuScorer: public StatisticsBasedScorer { public: - BleuScorer(const string& config = "") : StatisticsBasedScorer("BLEU",config),_refLengthStrategy(BLEU_SHORTEST) {} + BleuScorer(const string& config = "") : StatisticsBasedScorer("BLEU",config),_refLengthStrategy(BLEU_CLOSEST) { + //configure regularisation + static string KEY_REFLEN = "reflen"; + static string REFLEN_AVERAGE = "average"; + static string REFLEN_SHORTEST = "shortest"; + static string REFLEN_CLOSEST = "closest"; + + + string reflen = getConfig(KEY_REFLEN,REFLEN_CLOSEST); + if (reflen == REFLEN_AVERAGE) { + _refLengthStrategy = BLEU_AVERAGE; + } else if (reflen == REFLEN_SHORTEST) { + _refLengthStrategy = BLEU_SHORTEST; + } else if (reflen == REFLEN_CLOSEST) { + _refLengthStrategy = BLEU_CLOSEST; + } else { + throw runtime_error("Unknown reference length strategy: " + reflen); + } + cerr << "Using reference length strategy: " << reflen << endl; +} virtual void setReferenceFiles(const vector& referenceFiles); virtual void prepareStats(size_t sid, const string& text, ScoreStats& entry); static const int LENGTH; -- cgit v1.2.3