diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-12-07 19:07:11 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-12-07 19:07:11 +0300 |
commit | c4e45fb128e096f255a624b57b7826febdf06f2e (patch) | |
tree | 74455d64b0e45877c91dc2488838cfe01732b224 /moses/Syntax | |
parent | 2be2481feb2d68d6e4ba366d06fcfa51f7ff664e (diff) |
Code cleanup.
Diffstat (limited to 'moses/Syntax')
-rw-r--r-- | moses/Syntax/F2S/GlueRuleSynthesizer.cpp | 9 | ||||
-rw-r--r-- | moses/Syntax/F2S/GlueRuleSynthesizer.h | 2 | ||||
-rw-r--r-- | moses/Syntax/F2S/Manager-inl.h | 7 | ||||
-rw-r--r-- | moses/Syntax/Manager.cpp | 20 | ||||
-rw-r--r-- | moses/Syntax/S2T/OovHandler-inl.h | 5 | ||||
-rw-r--r-- | moses/Syntax/T2S/InputTreeBuilder.cpp | 4 | ||||
-rw-r--r-- | moses/Syntax/T2S/InputTreeBuilder.h | 2 | ||||
-rw-r--r-- | moses/Syntax/T2S/Manager-inl.h | 2 |
8 files changed, 24 insertions, 27 deletions
diff --git a/moses/Syntax/F2S/GlueRuleSynthesizer.cpp b/moses/Syntax/F2S/GlueRuleSynthesizer.cpp index 3ba5a26d3..c8d867650 100644 --- a/moses/Syntax/F2S/GlueRuleSynthesizer.cpp +++ b/moses/Syntax/F2S/GlueRuleSynthesizer.cpp @@ -13,13 +13,14 @@ namespace Syntax namespace F2S { -GlueRuleSynthesizer::GlueRuleSynthesizer(HyperTree &trie) +GlueRuleSynthesizer:: +GlueRuleSynthesizer(HyperTree &trie, const std::vector<FactorType> &iFactors) : m_hyperTree(trie) { - const std::vector<FactorType> &inputFactorOrder = - StaticData::Instance().GetInputFactorOrder(); + // const std::vector<FactorType> &inputFactorOrder = + // StaticData::Instance().GetInputFactorOrder(); Word *lhs = NULL; - m_dummySourcePhrase.CreateFromString(Input, inputFactorOrder, "hello", &lhs); + m_dummySourcePhrase.CreateFromString(Input, iFactors, "hello", &lhs); delete lhs; } diff --git a/moses/Syntax/F2S/GlueRuleSynthesizer.h b/moses/Syntax/F2S/GlueRuleSynthesizer.h index fa271796f..c66fb0ff8 100644 --- a/moses/Syntax/F2S/GlueRuleSynthesizer.h +++ b/moses/Syntax/F2S/GlueRuleSynthesizer.h @@ -17,7 +17,7 @@ namespace F2S class GlueRuleSynthesizer : public HyperTreeCreator { public: - GlueRuleSynthesizer(HyperTree &); + GlueRuleSynthesizer(HyperTree &, std::vector<FactorType> const& iFactors); // Synthesize the minimal, monotone rule that can be applied to the given // hyperedge and add it to the rule trie. diff --git a/moses/Syntax/F2S/Manager-inl.h b/moses/Syntax/F2S/Manager-inl.h index 9417b90f8..98a19d6d9 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; + T2S::InputTreeBuilder builder(options().output.factor_order); T2S::InputTree tmpTree; builder.Build(*p, "Q", tmpTree); boost::shared_ptr<Forest> forest = boost::make_shared<Forest>(); @@ -74,8 +74,9 @@ void Manager<RuleMatcher>::Decode() RuleMatcherCallback callback(m_stackMap, ruleLimit); // Create a glue rule synthesizer. - GlueRuleSynthesizer glueRuleSynthesizer(*m_glueRuleTrie); - + GlueRuleSynthesizer glueRuleSynthesizer(*m_glueRuleTrie, + options().input.factor_order); + // Sort the input forest's vertices into bottom-up topological order. std::vector<const Forest::Vertex *> sortedVertices; TopologicalSorter sorter; diff --git a/moses/Syntax/Manager.cpp b/moses/Syntax/Manager.cpp index e30e818cf..d9477fb9b 100644 --- a/moses/Syntax/Manager.cpp +++ b/moses/Syntax/Manager.cpp @@ -1,11 +1,8 @@ -#include "Manager.h" - #include <sstream> - -#include "moses/OutputCollector.h" -#include "moses/StaticData.h" - +#include "Manager.h" #include "PVertex.h" +#include "moses/OutputCollector.h" +#include "moses/Util.h" namespace Moses { @@ -40,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(StaticData::Instance().GetOutputFactorOrder()); + out << yield.GetStringRep(options().output.factor_order); out << '\n'; } collector->Write(m_source.GetTranslationId(), out.str()); @@ -76,10 +73,7 @@ void Manager::OutputNBestList(OutputCollector *collector, const KBestExtractor::KBestVec &nBestList, long translationId) const { - const StaticData &staticData = StaticData::Instance(); - - const std::vector<FactorType> &outputFactorOrder = - staticData.GetOutputFactorOrder(); + const std::vector<FactorType> &outputFactorOrder = options().output.factor_order; std::ostringstream out; @@ -89,8 +83,8 @@ void Manager::OutputNBestList(OutputCollector *collector, FixPrecision(out); } - bool includeWordAlignment = staticData.options().nbest.include_alignment_info; - bool PrintNBestTrees = staticData.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) { diff --git a/moses/Syntax/S2T/OovHandler-inl.h b/moses/Syntax/S2T/OovHandler-inl.h index ab9e3b07f..773cc7a91 100644 --- a/moses/Syntax/S2T/OovHandler-inl.h +++ b/moses/Syntax/S2T/OovHandler-inl.h @@ -52,11 +52,12 @@ Phrase *OovHandler<RuleTrie>::SynthesizeSourcePhrase(const Word &sourceWord) } template<typename RuleTrie> -Word *OovHandler<RuleTrie>::SynthesizeTargetLhs(const std::string &lhsStr) +Word * +OovHandler<RuleTrie>::SynthesizeTargetLhs(const std::string &lhsStr) { Word *targetLhs = new Word(true); targetLhs->CreateFromString(Output, - StaticData::Instance().GetOutputFactorOrder(), + StaticData::Instance().options().output.factor_order, lhsStr, true); UTIL_THROW_IF2(targetLhs->GetFactor(0) == NULL, "Null factor for target LHS"); return targetLhs; diff --git a/moses/Syntax/T2S/InputTreeBuilder.cpp b/moses/Syntax/T2S/InputTreeBuilder.cpp index 927c6b4e3..140b578d6 100644 --- a/moses/Syntax/T2S/InputTreeBuilder.cpp +++ b/moses/Syntax/T2S/InputTreeBuilder.cpp @@ -9,8 +9,8 @@ namespace Syntax namespace T2S { -InputTreeBuilder::InputTreeBuilder() - : m_outputFactorOrder(StaticData::Instance().GetOutputFactorOrder()) +InputTreeBuilder::InputTreeBuilder(std::vector<FactorType> const& oFactors) + : m_outputFactorOrder(oFactors) { } diff --git a/moses/Syntax/T2S/InputTreeBuilder.h b/moses/Syntax/T2S/InputTreeBuilder.h index d789d06a2..e14f20a6b 100644 --- a/moses/Syntax/T2S/InputTreeBuilder.h +++ b/moses/Syntax/T2S/InputTreeBuilder.h @@ -17,7 +17,7 @@ namespace T2S class InputTreeBuilder { public: - InputTreeBuilder(); + InputTreeBuilder(std::vector<FactorType> const& oFactors); // Constructs a Moses::T2S::InputTree given a Moses::TreeInput and a label // for the top-level node (which covers <s> and </s>). diff --git a/moses/Syntax/T2S/Manager-inl.h b/moses/Syntax/T2S/Manager-inl.h index 873d36d7c..e98c3f4ad 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; + InputTreeBuilder builder(options().output.factor_order); builder.Build(*p, "Q", m_inputTree); } else { UTIL_THROW2("ERROR: T2S::Manager requires input to be a tree"); |