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/Syntax | |
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/Syntax')
-rw-r--r-- | moses/Syntax/F2S/Manager-inl.h | 4 | ||||
-rw-r--r-- | moses/Syntax/Manager.cpp | 18 | ||||
-rw-r--r-- | moses/Syntax/T2S/Manager-inl.h | 6 |
3 files changed, 14 insertions, 14 deletions
diff --git a/moses/Syntax/F2S/Manager-inl.h b/moses/Syntax/F2S/Manager-inl.h index 4ee691263..77d4e0d58 100644 --- a/moses/Syntax/F2S/Manager-inl.h +++ b/moses/Syntax/F2S/Manager-inl.h @@ -42,7 +42,7 @@ Manager<RuleMatcher>::Manager(ttasksptr const& ttask) m_rootVertex = p->GetRootVertex(); m_sentenceLength = p->GetSize(); } else if (const TreeInput *p = dynamic_cast<const TreeInput*>(&m_source)) { - T2S::InputTreeBuilder builder(options().output.factor_order); + T2S::InputTreeBuilder builder(options()->output.factor_order); T2S::InputTree tmpTree; builder.Build(*p, "Q", tmpTree); boost::shared_ptr<Forest> forest = boost::make_shared<Forest>(); @@ -75,7 +75,7 @@ void Manager<RuleMatcher>::Decode() // Create a glue rule synthesizer. GlueRuleSynthesizer glueRuleSynthesizer(*m_glueRuleTrie, - options().input.factor_order); + options()->input.factor_order); // Sort the input forest's vertices into bottom-up topological order. std::vector<const Forest::Vertex *> sortedVertices; diff --git a/moses/Syntax/Manager.cpp b/moses/Syntax/Manager.cpp index d9477fb9b..27c5beda8 100644 --- a/moses/Syntax/Manager.cpp +++ b/moses/Syntax/Manager.cpp @@ -23,12 +23,12 @@ void Manager::OutputBest(OutputCollector *collector) const const SHyperedge *best = GetBestSHyperedge(); if (best == NULL) { VERBOSE(1, "NO BEST TRANSLATION" << std::endl); - if (options().output.ReportHypoScore) { + if (options()->output.ReportHypoScore) { out << "0 "; } out << '\n'; } else { - if (options().output.ReportHypoScore) { + if (options()->output.ReportHypoScore) { out << best->label.futureScore << " "; } Phrase yield = GetOneBestTargetYield(*best); @@ -37,7 +37,7 @@ void Manager::OutputBest(OutputCollector *collector) const "Output phrase should have contained at least 2 words (beginning and end-of-sentence)"); yield.RemoveWord(0); yield.RemoveWord(yield.GetSize()-1); - out << yield.GetStringRep(options().output.factor_order); + out << yield.GetStringRep(options()->output.factor_order); out << '\n'; } collector->Write(m_source.GetTranslationId(), out.str()); @@ -48,8 +48,8 @@ void Manager::OutputNBest(OutputCollector *collector) const if (collector) { long translationId = m_source.GetTranslationId(); KBestExtractor::KBestVec nBestList; - ExtractKBest(options().nbest.nbest_size, nBestList, - options().nbest.only_distinct); + ExtractKBest(options()->nbest.nbest_size, nBestList, + options()->nbest.only_distinct); OutputNBestList(collector, nBestList, translationId); } } @@ -73,7 +73,7 @@ void Manager::OutputNBestList(OutputCollector *collector, const KBestExtractor::KBestVec &nBestList, long translationId) const { - const std::vector<FactorType> &outputFactorOrder = options().output.factor_order; + const std::vector<FactorType> &outputFactorOrder = options()->output.factor_order; std::ostringstream out; @@ -83,8 +83,8 @@ void Manager::OutputNBestList(OutputCollector *collector, FixPrecision(out); } - bool includeWordAlignment = options().nbest.include_alignment_info; - bool PrintNBestTrees = options().nbest.print_trees; // PrintNBestTrees(); + bool includeWordAlignment = options()->nbest.include_alignment_info; + bool PrintNBestTrees = options()->nbest.print_trees; // PrintNBestTrees(); for (KBestExtractor::KBestVec::const_iterator p = nBestList.begin(); p != nBestList.end(); ++p) { @@ -103,7 +103,7 @@ void Manager::OutputNBestList(OutputCollector *collector, out << translationId << " ||| "; OutputSurface(out, outputPhrase); // , outputFactorOrder, false); out << " ||| "; - bool with_labels = options().nbest.include_feature_labels; + bool with_labels = options()->nbest.include_feature_labels; derivation.scoreBreakdown.OutputAllFeatureScores(out, with_labels); out << " ||| " << derivation.score; diff --git a/moses/Syntax/T2S/Manager-inl.h b/moses/Syntax/T2S/Manager-inl.h index e98c3f4ad..76aae54a8 100644 --- a/moses/Syntax/T2S/Manager-inl.h +++ b/moses/Syntax/T2S/Manager-inl.h @@ -33,7 +33,7 @@ Manager<RuleMatcher>::Manager(ttasksptr const& ttask) { if (const TreeInput *p = dynamic_cast<const TreeInput*>(&m_source)) { // Construct the InputTree. - InputTreeBuilder builder(options().output.factor_order); + InputTreeBuilder builder(options()->output.factor_order); builder.Build(*p, "Q", m_inputTree); } else { UTIL_THROW2("ERROR: T2S::Manager requires input to be a tree"); @@ -97,9 +97,9 @@ void Manager<RuleMatcher>::Decode() const StaticData &staticData = StaticData::Instance(); // Get various pruning-related constants. - const std::size_t popLimit = this->options().cube.pop_limit; + const std::size_t popLimit = this->options()->cube.pop_limit; const std::size_t ruleLimit = staticData.GetRuleLimit(); - const std::size_t stackLimit = this->options().search.stack_size; + const std::size_t stackLimit = this->options()->search.stack_size; // Initialize the stacks. InitializeStacks(); |