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-05 20:59:53 +0300
committerHieu Hoang <hieuhoang@gmail.com>2014-12-05 20:59:53 +0300
commit23ca29a2ea13bfa12210f4f278785aefdd45a672 (patch)
tree7a10fd28d59c5c22e9848bd44f6d1ad09e9d7a31 /moses/ChartManager.cpp
parent0d8e20980eed5f6fcefe89584dc5995e39b091a2 (diff)
add Decode to API framework
Diffstat (limited to 'moses/ChartManager.cpp')
-rw-r--r--moses/ChartManager.cpp46
1 files changed, 45 insertions, 1 deletions
diff --git a/moses/ChartManager.cpp b/moses/ChartManager.cpp
index d2269c3bf..f6f5f341c 100644
--- a/moses/ChartManager.cpp
+++ b/moses/ChartManager.cpp
@@ -64,7 +64,7 @@ ChartManager::~ChartManager()
}
//! decode the sentence. This contains the main laps. Basically, the CKY++ algorithm
-void ChartManager::ProcessSentence()
+void ChartManager::Decode()
{
VERBOSE(1,"Translating: " << m_source << endl);
@@ -597,6 +597,18 @@ void ChartManager::OutputDetailedTranslationReport(
OutputTranslationOptions(out, applicationContext, hypo, sentence, translationId);
collector->Write(translationId, out.str());
+
+ //DIMw
+ const StaticData &staticData = StaticData::Instance();
+
+ if (staticData.IsDetailedAllTranslationReportingEnabled()) {
+ const Sentence &sentence = dynamic_cast<const Sentence &>(m_source);
+ size_t nBestSize = staticData.GetNBestSize();
+ std::vector<boost::shared_ptr<ChartKBestExtractor::Derivation> > nBestList;
+ CalcNBest(nBestSize, nBestList, staticData.GetDistinctNBest());
+ OutputDetailedAllTranslationReport(collector, nBestList, sentence, translationId);
+ }
+
}
void ChartManager::OutputTranslationOptions(std::ostream &out,
@@ -753,4 +765,36 @@ void ChartManager::OutputSearchGraph(OutputCollector *collector) const
}
}
+//DIMw
+void ChartManager::OutputDetailedAllTranslationReport(
+ OutputCollector *collector,
+ const std::vector<boost::shared_ptr<Moses::ChartKBestExtractor::Derivation> > &nBestList,
+ const Sentence &sentence,
+ long translationId) const
+{
+ std::ostringstream out;
+ ApplicationContext applicationContext;
+
+ const ChartCellCollection& cells = GetChartCellCollection();
+ size_t size = GetSource().GetSize();
+ for (size_t width = 1; width <= size; ++width) {
+ for (size_t startPos = 0; startPos <= size-width; ++startPos) {
+ size_t endPos = startPos + width - 1;
+ WordsRange range(startPos, endPos);
+ const ChartCell& cell = cells.Get(range);
+ const HypoList* hyps = cell.GetAllSortedHypotheses();
+ out << "Chart Cell [" << startPos << ".." << endPos << "]" << endl;
+ HypoList::const_iterator iter;
+ size_t c = 1;
+ for (iter = hyps->begin(); iter != hyps->end(); ++iter) {
+ out << "----------------Item " << c++ << " ---------------------"
+ << endl;
+ OutputTranslationOptions(out, applicationContext, *iter,
+ sentence, translationId);
+ }
+ }
+ }
+ collector->Write(translationId, out.str());
+}
+
} // namespace Moses