Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/moses-smt/mosesdecoder.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHieu Hoang <hieuhoang@gmail.com>2014-12-04 21:35:19 +0300
committerHieu Hoang <hieuhoang@gmail.com>2014-12-04 21:35:19 +0300
commitb23c00989b30a916d3a3fba98bf033dec5081699 (patch)
tree41cc1ea0903e93d24021ebfe5e2cf72063eaf0e5 /moses/ChartManager.cpp
parent3a2f58eb2c97d03b486508db1438fb8b877f85d7 (diff)
move OutputDetailedTreeFragmentsTranslationReport() to Manager
Diffstat (limited to 'moses/ChartManager.cpp')
-rw-r--r--moses/ChartManager.cpp64
1 files changed, 64 insertions, 0 deletions
diff --git a/moses/ChartManager.cpp b/moses/ChartManager.cpp
index a90ea717d..824b440c8 100644
--- a/moses/ChartManager.cpp
+++ b/moses/ChartManager.cpp
@@ -29,6 +29,7 @@
#include "StaticData.h"
#include "DecodeStep.h"
#include "TreeInput.h"
+#include "moses/FF/StatefulFeatureFunction.h"
#include "moses/FF/WordPenaltyProducer.h"
#include "moses/OutputCollector.h"
#include "moses/ChartKBestExtractor.h"
@@ -680,4 +681,67 @@ void ChartManager::OutputUnknowns(OutputCollector *collector) const
}
+void ChartManager::OutputDetailedTreeFragmentsTranslationReport(OutputCollector *collector) const
+{
+ const ChartHypothesis *hypo = GetBestHypothesis();
+ if (collector == NULL || hypo == NULL) {
+ return;
+ }
+
+ std::ostringstream out;
+ ApplicationContext applicationContext;
+
+ const Sentence &sentence = dynamic_cast<const Sentence &>(m_source);
+ const size_t translationId = m_source.GetTranslationId();
+
+ OutputTreeFragmentsTranslationOptions(out, applicationContext, hypo, sentence, translationId);
+
+ //Tree of full sentence
+ const StatefulFeatureFunction* treeStructure = StaticData::Instance().GetTreeStructure();
+ if (treeStructure != NULL) {
+ const vector<const StatefulFeatureFunction*>& sff = StatefulFeatureFunction::GetStatefulFeatureFunctions();
+ for( size_t i=0; i<sff.size(); i++ ) {
+ if (sff[i] == treeStructure) {
+ const TreeState* tree = dynamic_cast<const TreeState*>(hypo->GetFFState(i));
+ out << "Full Tree " << translationId << ": " << tree->GetTree()->GetString() << "\n";
+ break;
+ }
+ }
+ }
+
+ collector->Write(translationId, out.str());
+
+}
+
+void ChartManager::OutputTreeFragmentsTranslationOptions(std::ostream &out,
+ ApplicationContext &applicationContext,
+ const ChartHypothesis *hypo,
+ const Sentence &sentence,
+ long translationId) const
+{
+
+ if (hypo != NULL) {
+ OutputTranslationOption(out, applicationContext, hypo, sentence, translationId);
+
+ const TargetPhrase &currTarPhr = hypo->GetCurrTargetPhrase();
+
+ out << " ||| ";
+ if (const PhraseProperty *property = currTarPhr.GetProperty("Tree")) {
+ out << " " << *property->GetValueString();
+ } else {
+ out << " " << "noTreeInfo";
+ }
+ out << std::endl;
+ }
+
+ // recursive
+ const std::vector<const ChartHypothesis*> &prevHypos = hypo->GetPrevHypos();
+ std::vector<const ChartHypothesis*>::const_iterator iter;
+ for (iter = prevHypos.begin(); iter != prevHypos.end(); ++iter) {
+ const ChartHypothesis *prevHypo = *iter;
+ OutputTreeFragmentsTranslationOptions(out, applicationContext, prevHypo, sentence, translationId);
+ }
+}
+
+
} // namespace Moses