diff options
author | Eva <eva@deimos.(none)> | 2012-05-29 02:49:39 +0400 |
---|---|---|
committer | Eva <eva@deimos.(none)> | 2012-05-29 02:49:39 +0400 |
commit | 29b31f6cd9451b1a221574e93ddda39620e769a0 (patch) | |
tree | e6734291048570db5d5e4e2a205434a7ed890e5c /mira | |
parent | d81ebe2337c0de18aa6d510bf13c408b83a083ca (diff) |
remove <s> and </s> from chart bleu score computation
Diffstat (limited to 'mira')
-rwxr-xr-x | mira/Decoder.cpp | 17 | ||||
-rwxr-xr-x | mira/Decoder.h | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/mira/Decoder.cpp b/mira/Decoder.cpp index f6912e4b9..1edc85150 100755 --- a/mira/Decoder.cpp +++ b/mira/Decoder.cpp @@ -103,11 +103,12 @@ namespace Mira { string filename) { StaticData &staticData = StaticData::InstanceNonConst(); - initialize(staticData, source, sentenceid, bleuObjectiveWeight, bleuScoreWeight, avgRefLength); + bool chartDecoding = (staticData.GetSearchAlgorithm() == ChartDecoding); + initialize(staticData, source, sentenceid, bleuObjectiveWeight, bleuScoreWeight, avgRefLength, chartDecoding); const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT); // run the decoder - if (staticData.GetSearchAlgorithm() == ChartDecoding) { + if (chartDecoding) { return runChartDecoder(source, sentenceid, nBestSize, bleuObjectiveWeight, bleuScoreWeight, featureValues, bleuScores, modelScores, numReturnedTranslations, distinct, rank, epoch, system); @@ -274,10 +275,11 @@ namespace Mira { size_t nBestSize, float bleuObjectiveWeight, float bleuScoreWeight, bool distinctNbest, bool avgRefLength, string filename, ofstream& streamOut) { StaticData &staticData = StaticData::InstanceNonConst(); - initialize(staticData, source, sentenceid, bleuObjectiveWeight, bleuScoreWeight, avgRefLength); + bool chartDecoding = (staticData.GetSearchAlgorithm() == ChartDecoding); + initialize(staticData, source, sentenceid, bleuObjectiveWeight, bleuScoreWeight, avgRefLength, chartDecoding); const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT); - if (staticData.GetSearchAlgorithm() == ChartDecoding) { + if (chartDecoding) { m_chartManager = new ChartManager(*m_sentence, &system); m_chartManager->ProcessSentence(); ChartTrellisPathList nBestList; @@ -328,7 +330,7 @@ namespace Mira { } void MosesDecoder::initialize(StaticData& staticData, const std::string& source, size_t sentenceid, - float bleuObjectiveWeight, float bleuScoreWeight, bool avgRefLength) { + float bleuObjectiveWeight, float bleuScoreWeight, bool avgRefLength, bool chartDecoding) { m_sentence = new Sentence(); stringstream in(source + "\n"); const std::vector<FactorType> &inputFactorOrder = staticData.GetInputFactorOrder(); @@ -339,6 +341,11 @@ namespace Mira { staticData.ReLoadBleuScoreFeatureParameter(bleuObjectiveWeight*bleuScoreWeight); m_bleuScoreFeature->SetCurrSourceLength((*m_sentence).GetSize()); + if (chartDecoding) + m_bleuScoreFeature->SetCurrNormSourceLength((*m_sentence).GetSize()-2); + else + m_bleuScoreFeature->SetCurrNormSourceLength((*m_sentence).GetSize()); + if (avgRefLength) m_bleuScoreFeature->SetCurrAvgRefLength(sentenceid); else diff --git a/mira/Decoder.h b/mira/Decoder.h index be9ed2f9a..e9f9aafe3 100755 --- a/mira/Decoder.h +++ b/mira/Decoder.h @@ -102,7 +102,7 @@ class MosesDecoder { std::string filename, std::ofstream& streamOut); void initialize(Moses::StaticData& staticData, const std::string& source, size_t sentenceid, - float bleuObjectiveWeight, float bleuScoreWeight, bool avgRefLength); + float bleuObjectiveWeight, float bleuScoreWeight, bool avgRefLength, bool chartDecoding); void updateHistory(const std::vector<const Moses::Word*>& words); void updateHistory(const std::vector< std::vector< const Moses::Word*> >& words, std::vector<size_t>& sourceLengths, std::vector<size_t>& ref_ids, size_t rank, size_t epoch); void printBleuFeatureHistory(std::ostream& out); |