diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-12-10 02:05:00 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-12-10 02:05:00 +0300 |
commit | 240b88c6834c9c94e8a6448a34dc4ad33bdf3fbd (patch) | |
tree | e9f43dba3717e8a430557c16a1d6543a13628ddf /moses/ChartManager.cpp | |
parent | ad5e27ae56298564dfd73637c160a682b5f5f028 (diff) |
Passing around AllOptions or references thereto everywhere,
strong them locally where appropriate, so that compontents can
become independent of StaticData once instantiated.
Diffstat (limited to 'moses/ChartManager.cpp')
-rw-r--r-- | moses/ChartManager.cpp | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/moses/ChartManager.cpp b/moses/ChartManager.cpp index 0976c329f..1e07910a9 100644 --- a/moses/ChartManager.cpp +++ b/moses/ChartManager.cpp @@ -205,7 +205,7 @@ void ChartManager::CalcNBest( // than n. The n-best factor determines how much bigger the limit should be, // with 0 being 'unlimited.' This actually sets a large-ish limit in case // too many translations are identical. - const std::size_t nBestFactor = options().nbest.factor; + const std::size_t nBestFactor = options()->nbest.factor; std::size_t numDerivations = (nBestFactor == 0) ? n*1000 : n*nBestFactor; // Extract the derivations. @@ -315,14 +315,14 @@ void ChartManager::OutputBest(OutputCollector *collector) const void ChartManager::OutputNBest(OutputCollector *collector) const { - size_t nBestSize = options().nbest.nbest_size; + size_t nBestSize = options()->nbest.nbest_size; if (nBestSize > 0) { const size_t translationId = m_source.GetTranslationId(); VERBOSE(2,"WRITING " << nBestSize << " TRANSLATION ALTERNATIVES TO " - << options().nbest.output_file_path << endl); + << options()->nbest.output_file_path << endl); std::vector<boost::shared_ptr<ChartKBestExtractor::Derivation> > nBestList; - CalcNBest(nBestSize, nBestList, options().nbest.only_distinct); + CalcNBest(nBestSize, nBestList, options()->nbest.only_distinct); OutputNBestList(collector, nBestList, translationId); IFVERBOSE(2) { PrintUserTime("N-Best Hypotheses Generation Time:"); @@ -343,7 +343,7 @@ void ChartManager::OutputNBestList(OutputCollector *collector, FixPrecision(out); } - NBestOptions const& nbo = options().nbest; + NBestOptions const& nbo = options()->nbest; bool includeWordAlignment = nbo.include_alignment_info; bool PrintNBestTrees = nbo.print_trees; @@ -365,7 +365,7 @@ void ChartManager::OutputNBestList(OutputCollector *collector, OutputSurface(out, outputPhrase); // , outputFactorOrder, false); out << " ||| "; boost::shared_ptr<ScoreComponentCollection> scoreBreakdown = ChartKBestExtractor::GetOutputScoreBreakdown(derivation); - bool with_labels = options().nbest.include_feature_labels; + bool with_labels = options()->nbest.include_feature_labels; scoreBreakdown->OutputAllFeatureScores(out, with_labels); out << " ||| " << derivation.score; @@ -611,11 +611,11 @@ void ChartManager::OutputDetailedTranslationReport( collector->Write(translationId, out.str()); //DIMw - if (options().output.detailed_all_transrep_filepath.size()) { + if (options()->output.detailed_all_transrep_filepath.size()) { const Sentence &sentence = static_cast<const Sentence &>(m_source); - size_t nBestSize = options().nbest.nbest_size; + size_t nBestSize = options()->nbest.nbest_size; std::vector<boost::shared_ptr<ChartKBestExtractor::Derivation> > nBestList; - CalcNBest(nBestSize, nBestList, options().nbest.only_distinct); + CalcNBest(nBestSize, nBestList, options()->nbest.only_distinct); OutputDetailedAllTranslationReport(collector, nBestList, sentence, translationId); } @@ -820,11 +820,11 @@ void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothe Backtrack(hypo); VERBOSE(3,"0" << std::endl); - if (options().output.ReportHypoScore) { + if (options()->output.ReportHypoScore) { out << hypo->GetFutureScore() << " "; } - if (options().output.RecoverPath) { + if (options()->output.RecoverPath) { out << "||| "; } Phrase outPhrase(ARRAY_SIZE_INCR); @@ -837,12 +837,12 @@ void ChartManager::OutputBestHypo(OutputCollector *collector, const ChartHypothe outPhrase.RemoveWord(0); outPhrase.RemoveWord(outPhrase.GetSize() - 1); - string output = outPhrase.GetStringRep(options().output.factor_order); + string output = outPhrase.GetStringRep(options()->output.factor_order); out << output << endl; } else { VERBOSE(1, "NO BEST TRANSLATION" << endl); - if (options().output.ReportHypoScore) { + if (options()->output.ReportHypoScore) { out << "0 "; } |