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:
authorNicola Bertoldi <bertoldi@fbk.eu>2014-12-15 19:42:41 +0300
committerNicola Bertoldi <bertoldi@fbk.eu>2014-12-15 19:42:41 +0300
commit4e77665d30224653e4fa1a818e8100a6188fac2d (patch)
tree2412ccb40527226e03ff9503826a2c99f5189406 /moses/Incremental.cpp
parente4eb201c52be74fee74399a6f35fcbe8eb85d834 (diff)
parentdfd6cd2dd7fb2451b899c0ee84172d2e4e291f77 (diff)
better handling of cache-based models with inconsistent parametersdynamic-models
Diffstat (limited to 'moses/Incremental.cpp')
-rw-r--r--moses/Incremental.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/moses/Incremental.cpp b/moses/Incremental.cpp
index d5de7b4d7..ba1d89eb9 100644
--- a/moses/Incremental.cpp
+++ b/moses/Incremental.cpp
@@ -283,6 +283,20 @@ const std::vector<search::Applied> &Manager::GetNBest() const
return *completed_nbest_;
}
+void Manager::OutputBest(OutputCollector *collector) const
+{
+ const long translationId = m_source.GetTranslationId();
+ const std::vector<search::Applied> &nbest = GetNBest();
+ if (!nbest.empty()) {
+ OutputBestHypo(collector, nbest[0], translationId);
+ }
+ else {
+ OutputBestNone(collector, translationId);
+ }
+
+}
+
+
void Manager::OutputNBest(OutputCollector *collector) const
{
if (collector == NULL) {
@@ -465,6 +479,38 @@ void Manager::OutputTreeFragmentsTranslationOptions(std::ostream &out,
}
}
+void Manager::OutputBestHypo(OutputCollector *collector, search::Applied applied, long translationId) const
+{
+ if (collector == NULL) return;
+ std::ostringstream out;
+ FixPrecision(out);
+ if (StaticData::Instance().GetOutputHypoScore()) {
+ out << applied.GetScore() << ' ';
+ }
+ Phrase outPhrase;
+ Incremental::ToPhrase(applied, outPhrase);
+ // delete 1st & last
+ UTIL_THROW_IF2(outPhrase.GetSize() < 2,
+ "Output phrase should have contained at least 2 words (beginning and end-of-sentence)");
+ outPhrase.RemoveWord(0);
+ outPhrase.RemoveWord(outPhrase.GetSize() - 1);
+ out << outPhrase.GetStringRep(StaticData::Instance().GetOutputFactorOrder());
+ out << '\n';
+ collector->Write(translationId, out.str());
+
+ VERBOSE(1,"BEST TRANSLATION: " << outPhrase << "[total=" << applied.GetScore() << "]" << std::endl);
+}
+
+void Manager::OutputBestNone(OutputCollector *collector, long translationId) const
+{
+ if (collector == NULL) return;
+ if (StaticData::Instance().GetOutputHypoScore()) {
+ collector->Write(translationId, "0 \n");
+ } else {
+ collector->Write(translationId, "\n");
+ }
+}
+
namespace
{