diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2014-11-08 20:36:32 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2014-11-08 20:36:32 +0300 |
commit | 8d15287eee023b5a9ebb4e6f9a67ce034af2955f (patch) | |
tree | d38e3dbfbc1561d7174ee5f9eb6ec781a64ea657 /moses/TranslationTask.h | |
parent | 4687c1cc2bcbe53e061d372b352129db2a380a83 (diff) |
added phil's functions
Diffstat (limited to 'moses/TranslationTask.h')
-rw-r--r-- | moses/TranslationTask.h | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/moses/TranslationTask.h b/moses/TranslationTask.h index 698c7009c..3b5fe26d1 100644 --- a/moses/TranslationTask.h +++ b/moses/TranslationTask.h @@ -4,15 +4,17 @@ #include "moses/ThreadPool.h" #include "moses/Manager.h" #include "moses/HypergraphOutput.h" +#include "moses/IOWrapper.h" #include "moses/Manager.h" #include "moses/ChartManager.h" +#include "moses/Syntax/S2T/Manager.h" + namespace Moses { class InputType; class OutputCollector; -class IOWrapper; /** Translates a sentence. * - calls the search (Manager) @@ -50,6 +52,33 @@ private: void RunPb(); void RunChart(); + + template<typename Parser> + void DecodeS2T() { + const StaticData &staticData = StaticData::Instance(); + const std::size_t translationId = m_source->GetTranslationId(); + Syntax::S2T::Manager<Parser> manager(*m_source); + manager.Decode(); + // 1-best + const Syntax::SHyperedge *best = manager.GetBestSHyperedge(); + m_ioWrapper.OutputBestHypo(best, translationId); + // n-best + if (staticData.GetNBestSize() > 0) { + Syntax::KBestExtractor::KBestVec nBestList; + manager.ExtractKBest(staticData.GetNBestSize(), nBestList, + staticData.GetDistinctNBest()); + m_ioWrapper.OutputNBestList(nBestList, translationId); + } + // Write 1-best derivation (-translation-details / -T option). + if (staticData.IsDetailedTranslationReportingEnabled()) { + m_ioWrapper.OutputDetailedTranslationReport(best, translationId); + } + // Write unknown words file (-output-unknowns option) + if (!staticData.GetOutputUnknownsFile().empty()) { + m_ioWrapper.OutputUnknowns(manager.GetUnknownWords(), translationId); + } + } + }; |