mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-26 19:37:58 +03:00
add detailed logging of 1-best translation output
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@550 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
5d7a766aae
commit
f83c8abd66
@ -50,6 +50,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
|||||||
#include "IOFile.h"
|
#include "IOFile.h"
|
||||||
#include "Sentence.h"
|
#include "Sentence.h"
|
||||||
#include "ConfusionNet.h"
|
#include "ConfusionNet.h"
|
||||||
|
#include "TranslationAnalysis.h"
|
||||||
|
|
||||||
#if HAVE_CONFIG_H
|
#if HAVE_CONFIG_H
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -148,6 +149,9 @@ int main(int argc, char* argv[])
|
|||||||
RemoveAllInColl< LatticePathList::iterator > (nBestList);
|
RemoveAllInColl< LatticePathList::iterator > (nBestList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (staticData.IsDetailedTranslationReportingEnabled()) {
|
||||||
|
TranslationAnalysis::PrintTranslationAnalysis(std::cout, manager.GetBestHypothesis());
|
||||||
|
}
|
||||||
staticData.CleanUpAfterSentenceProcessing();
|
staticData.CleanUpAfterSentenceProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include "StaticData.h"
|
||||||
#include "Hypothesis.h"
|
#include "Hypothesis.h"
|
||||||
#include "TranslationAnalysis.h"
|
#include "TranslationAnalysis.h"
|
||||||
|
|
||||||
@ -10,6 +11,7 @@ namespace TranslationAnalysis {
|
|||||||
|
|
||||||
void PrintTranslationAnalysis(std::ostream &os, const Hypothesis* hypo)
|
void PrintTranslationAnalysis(std::ostream &os, const Hypothesis* hypo)
|
||||||
{
|
{
|
||||||
|
os << std::endl << "TRANSLATION HYPOTHESIS DETAILS:" << std::endl;
|
||||||
std::vector<const Hypothesis*> translationPath;
|
std::vector<const Hypothesis*> translationPath;
|
||||||
while (hypo) {
|
while (hypo) {
|
||||||
translationPath.push_back(hypo);
|
translationPath.push_back(hypo);
|
||||||
@ -35,8 +37,8 @@ void PrintTranslationAnalysis(std::ostream &os, const Hypothesis* hypo)
|
|||||||
epsilon = true;
|
epsilon = true;
|
||||||
droppedWords.push_back(source);
|
droppedWords.push_back(source);
|
||||||
}
|
}
|
||||||
os << " SOURCE: " << swr << " " << source << std::endl
|
os << " SOURCE: " << swr << " " << source << std::endl
|
||||||
<< "TRANSLATED AS: " << target << std::endl;
|
<< " TRANSLATED AS: " << target << std::endl;
|
||||||
size_t twr_i = twr.GetStartPos();
|
size_t twr_i = twr.GetStartPos();
|
||||||
size_t swr_i = swr.GetStartPos();
|
size_t swr_i = swr.GetStartPos();
|
||||||
if (!epsilon) { sms << twr_i; }
|
if (!epsilon) { sms << twr_i; }
|
||||||
@ -53,11 +55,12 @@ void PrintTranslationAnalysis(std::ostream &os, const Hypothesis* hypo)
|
|||||||
}
|
}
|
||||||
std::vector<std::string>::iterator si = sourceMap.begin();
|
std::vector<std::string>::iterator si = sourceMap.begin();
|
||||||
std::vector<std::string>::iterator ti = targetMap.begin();
|
std::vector<std::string>::iterator ti = targetMap.begin();
|
||||||
os << "SOURCE:";
|
os << std::endl << "SOURCE/TARGET SPANS:";
|
||||||
|
os << std::endl << " SOURCE:";
|
||||||
for (; si != sourceMap.end(); ++si) {
|
for (; si != sourceMap.end(); ++si) {
|
||||||
os << " " << *si;
|
os << " " << *si;
|
||||||
}
|
}
|
||||||
os << std::endl << "TARGET:";
|
os << std::endl << " TARGET:";
|
||||||
for (; ti != targetMap.end(); ++ti) {
|
for (; ti != targetMap.end(); ++ti) {
|
||||||
os << " " << *ti;
|
os << " " << *ti;
|
||||||
}
|
}
|
||||||
@ -65,11 +68,14 @@ void PrintTranslationAnalysis(std::ostream &os, const Hypothesis* hypo)
|
|||||||
|
|
||||||
if (droppedWords.size() > 0) {
|
if (droppedWords.size() > 0) {
|
||||||
std::vector<std::string>::iterator dwi = droppedWords.begin();
|
std::vector<std::string>::iterator dwi = droppedWords.begin();
|
||||||
os << "WORDS/PHRASES DROPPED:" << std::endl;
|
os << std::endl << "WORDS/PHRASES DROPPED:" << std::endl;
|
||||||
for (; dwi != droppedWords.end(); ++dwi) {
|
for (; dwi != droppedWords.end(); ++dwi) {
|
||||||
os << "\t" << *dwi << std::endl;
|
os << "\t" << *dwi << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
os << std::endl << "SCORES (UNWEIGHTED/WEIGHTED):" << std::endl;
|
||||||
|
StaticData::Instance()->GetScoreIndexManager().Debug_PrintLabeledWeightedScores(os, translationPath.back()->GetScoreBreakdown(), StaticData::Instance()->GetAllWeights());
|
||||||
|
os << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user