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:
authorhieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230>2008-02-27 15:43:04 +0300
committerhieuhoang1972 <hieuhoang1972@1f5c12ca-751b-0410-a591-d2e778427230>2008-02-27 15:43:04 +0300
commit4964c45489359dd5ad4894bdadf7996b400e556d (patch)
tree6459ab92a4584df4003f0e80fd5308c818e6ae73 /moses/src/Manager.cpp
parentf056bdbfde3bdb4e30074ff323c81f8a700c0249 (diff)
output wordgraph for german
git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/trunk@1573 1f5c12ca-751b-0410-a591-d2e778427230
Diffstat (limited to 'moses/src/Manager.cpp')
-rwxr-xr-xmoses/src/Manager.cpp53
1 files changed, 53 insertions, 0 deletions
diff --git a/moses/src/Manager.cpp b/moses/src/Manager.cpp
index acf5bbe20..692b6ba3f 100755
--- a/moses/src/Manager.cpp
+++ b/moses/src/Manager.cpp
@@ -479,3 +479,56 @@ void Manager::CalcDecoderStatistics() const
}
}
}
+
+void Manager::GetWordGraph() const
+{
+ const StaticData &staticData = StaticData::Instance();
+ string fileName = staticData.GetParam("output-word-graph")[0];
+ bool outputNBest = Scan<bool>(staticData.GetParam("output-word-graph")[1]);
+
+ std::ofstream wordGraphFile;
+ wordGraphFile.open(fileName.c_str());
+
+ size_t stackNo = 1;
+ std::vector < HypothesisStack >::const_iterator iterStack;
+ for (iterStack = ++m_hypoStackColl.begin() ; iterStack != m_hypoStackColl.end() ; ++iterStack)
+ {
+ cerr << endl << stackNo++ << endl;
+ const HypothesisStack &stack = *iterStack;
+ HypothesisStack::const_iterator iterHypo;
+ for (iterHypo = stack.begin() ; iterHypo != stack.end() ; ++iterHypo)
+ {
+ const Hypothesis *hypo = *iterHypo;
+ const Hypothesis *prevHypo = hypo->GetPrevHypo();
+ const Phrase *sourcePhrase = hypo->GetSourcePhrase();
+ const Phrase &targetPhrase = hypo->GetCurrTargetPhrase();
+
+
+ wordGraphFile << prevHypo->GetId() << " -> " << hypo->GetId() << ": "
+ << *sourcePhrase << " "
+ << targetPhrase << " "
+ << hypo->GetTranslationOption().GetScoreBreakdown() << endl;
+
+ if (outputNBest)
+ {
+ const ArcList *arcList = hypo->GetArcList();
+ if (arcList != NULL)
+ {
+ ArcList::const_iterator iterArcList;
+ for (iterArcList = arcList->begin() ; iterArcList != arcList->end() ; ++iterArcList)
+ {
+ const Hypothesis *loserHypo = *iterArcList;
+ const Hypothesis *prevHypo = loserHypo->GetPrevHypo();
+
+ wordGraphFile << prevHypo->GetId() << " -> " << loserHypo->GetId() << ": "
+ << *sourcePhrase << " "
+ << targetPhrase << " "
+ << loserHypo->GetTranslationOption().GetScoreBreakdown() << endl;
+ }
+ }
+ } //if (outputNBest)
+ } //for (iterHypo
+ } // for (iterStack
+
+ wordGraphFile.close();
+} \ No newline at end of file