diff --git a/contrib/other-builds/moses2/HypothesisColl.cpp b/contrib/other-builds/moses2/HypothesisColl.cpp index 8c769b2de..5a58e970a 100644 --- a/contrib/other-builds/moses2/HypothesisColl.cpp +++ b/contrib/other-builds/moses2/HypothesisColl.cpp @@ -72,7 +72,7 @@ Hypotheses &HypothesisColl::GetSortedAndPruneHypos(const ManagerBase &mgr, void HypothesisColl::SortAndPruneHypos(const ManagerBase &mgr, ArcLists &arcLists) const { - size_t stackSize = mgr.system.stackSize; + size_t stackSize = mgr.system.options.search.stack_size; Recycler &recycler = mgr.GetHypoRecycle(); /* diff --git a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp index 66d6dd98f..e36059f91 100644 --- a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp +++ b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Misc.cpp @@ -77,7 +77,7 @@ void QueueItem::CreateHypothesis(Manager &mgr) hypo->Init(mgr, *prevHypo, edge->path, tp, edge->newBitmap, edge->estimatedScore); - if (!mgr.system.cubePruningLazyScoring) { + if (!mgr.system.options.cube.lazy_scoring) { hypo->EvaluateWhenApplied(); } } diff --git a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp index b1ef2e3f6..ce4c46d7d 100644 --- a/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp +++ b/contrib/other-builds/moses2/PhraseBased/CubePruningMiniStack/Search.cpp @@ -118,7 +118,7 @@ void Search::Decode(size_t stackInd) */ size_t pops = 0; - while (!m_queue.empty() && pops < mgr.system.popLimit) { + while (!m_queue.empty() && pops < mgr.system.options.cube.pop_limit) { // get best hypo from queue, add to stack //cerr << "queue=" << queue.size() << endl; QueueItem *item = m_queue.top(); @@ -129,7 +129,7 @@ void Search::Decode(size_t stackInd) // add hypo to stack Hypothesis *hypo = item->hypo; - if (mgr.system.cubePruningLazyScoring) { + if (mgr.system.options.cube.lazy_scoring) { hypo->EvaluateWhenApplied(); } @@ -142,7 +142,7 @@ void Search::Decode(size_t stackInd) } // create hypo from every edge. Increase diversity - if (mgr.system.cubePruningDiversity) { + if (mgr.system.options.cube.diversity) { while (!m_queue.empty()) { QueueItem *item = m_queue.top(); m_queue.pop(); diff --git a/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp b/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp index ae3e01f8b..73cc1fc56 100644 --- a/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp +++ b/contrib/other-builds/moses2/PhraseBased/InputPaths.cpp @@ -21,7 +21,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr) MemPool &pool = mgr.GetPool(); size_t numPt = mgr.system.mappings.size(); size_t size = input.GetSize(); - size_t maxLength = min(size, mgr.system.maxPhraseLength); + size_t maxLength = min(size, mgr.system.options.search.max_phrase_length); m_matrix = new (pool.Allocate >()) Matrix(pool, size, maxLength); diff --git a/contrib/other-builds/moses2/PhraseBased/Manager.cpp b/contrib/other-builds/moses2/PhraseBased/Manager.cpp index 09134243a..af1ac2af4 100644 --- a/contrib/other-builds/moses2/PhraseBased/Manager.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Manager.cpp @@ -70,7 +70,7 @@ void Manager::Init() m_bitmaps->Init(m_input->GetSize(), vector(0)); - switch (system.searchAlgorithm) { + switch (system.options.search.algo) { case Normal: m_search = new SearchNormal(*this); break; diff --git a/contrib/other-builds/moses2/PhraseBased/Search.cpp b/contrib/other-builds/moses2/PhraseBased/Search.cpp index 1e95e90f2..6c35aa151 100644 --- a/contrib/other-builds/moses2/PhraseBased/Search.cpp +++ b/contrib/other-builds/moses2/PhraseBased/Search.cpp @@ -39,11 +39,11 @@ bool Search::CanExtend(const Bitmap &hypoBitmap, size_t hypoRangeEndPos, return false; } - if (mgr.system.maxDistortion >= 0) { + if (mgr.system.options.reordering.max_distortion >= 0) { // distortion limit int distortion = ComputeDistortionDistance(hypoRangeEndPos, pathRange.GetStartPos()); - if (distortion > mgr.system.maxDistortion) { + if (distortion > mgr.system.options.reordering.max_distortion) { //cerr << " NO" << endl; return false; } @@ -97,7 +97,7 @@ bool Search::CanExtend(const Bitmap &hypoBitmap, size_t hypoRangeEndPos, Range bestNextExtension(hypoFirstGapPos, hypoFirstGapPos); if (ComputeDistortionDistance(pathRange.GetEndPos(), - bestNextExtension.GetStartPos()) > mgr.system.maxDistortion) { + bestNextExtension.GetStartPos()) > mgr.system.options.reordering.max_distortion) { //cerr << " NO" << endl; return false; } diff --git a/contrib/other-builds/moses2/SCFG/InputPaths.cpp b/contrib/other-builds/moses2/SCFG/InputPaths.cpp index 1948f9393..6f8601f15 100644 --- a/contrib/other-builds/moses2/SCFG/InputPaths.cpp +++ b/contrib/other-builds/moses2/SCFG/InputPaths.cpp @@ -23,7 +23,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr) MemPool &pool = mgr.GetPool(); size_t numPt = mgr.system.mappings.size(); size_t size = input.GetSize(); - size_t maxLength = min(size, mgr.system.maxPhraseLength); + size_t maxLength = min(size, mgr.system.options.search.max_phrase_length); m_matrix = new (pool.Allocate >()) Matrix(pool, size, maxLength); diff --git a/contrib/other-builds/moses2/System.cpp b/contrib/other-builds/moses2/System.cpp index 209c6fa80..7a691e361 100644 --- a/contrib/other-builds/moses2/System.cpp +++ b/contrib/other-builds/moses2/System.cpp @@ -23,21 +23,11 @@ namespace Moses2 System::System(const Parameter ¶msArg) : params(paramsArg), featureFunctions(*this) { + options.init(paramsArg); + bestCollector.reset(new OutputCollector()); ini_performance_options(); - params.SetParameter(stackSize, "stack", DEFAULT_MAX_HYPOSTACK_SIZE); - params.SetParameter(maxDistortion, "distortion-limit", -1); - params.SetParameter(maxPhraseLength, "max-phrase-length", - DEFAULT_MAX_PHRASE_LENGTH); - params.SetParameter(searchAlgorithm, "search-algorithm", Normal); - params.SetParameter(popLimit, "cube-pruning-pop-limit", - DEFAULT_CUBE_PRUNING_POP_LIMIT); - params.SetParameter(cubePruningDiversity, "cube-pruning-diversity", - (size_t) 0); - params.SetParameter(cubePruningLazyScoring, "cube-pruning-lazy-scoring", - false); - params.SetParameter(cpuAffinityOffset, "cpu-affinity-offset", 0); params.SetParameter(cpuAffinityOffsetIncr, "cpu-affinity-increment", 1); diff --git a/contrib/other-builds/moses2/System.h b/contrib/other-builds/moses2/System.h index 0d6d97629..1d88d8bee 100644 --- a/contrib/other-builds/moses2/System.h +++ b/contrib/other-builds/moses2/System.h @@ -20,6 +20,7 @@ #include "TypeDef.h" #include "legacy/Bitmaps.h" #include "legacy/OutputCollector.h" +#include "parameters/AllOptions.h" namespace Moses2 { @@ -37,6 +38,7 @@ class System { public: const Parameter ¶ms; + AllOptions options; FeatureFunctions featureFunctions; Weights weights; std::vector mappings; @@ -44,16 +46,8 @@ public: mutable boost::shared_ptr bestCollector, nbestCollector; // moses.ini params - size_t stackSize; - int maxDistortion; - size_t maxPhraseLength; int numThreads; - SearchAlgorithm searchAlgorithm; - size_t popLimit; - size_t cubePruningDiversity; - bool cubePruningLazyScoring; - size_t nbestSize; bool distinctNBest; diff --git a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp index 3a0c24d1d..066483c3b 100644 --- a/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp +++ b/contrib/other-builds/moses2/TranslationModel/PhraseTableMemory.cpp @@ -140,7 +140,7 @@ void PhraseTableMemory::Load(System &system) Phrase *source; TargetPhrase *target; - switch (system.searchAlgorithm) { + switch (system.options.search.algo) { case Normal: case CubePruning: case CubePruningPerMiniStack: diff --git a/contrib/other-builds/moses2/TranslationTask.cpp b/contrib/other-builds/moses2/TranslationTask.cpp index f716bb013..7dd9ce29d 100644 --- a/contrib/other-builds/moses2/TranslationTask.cpp +++ b/contrib/other-builds/moses2/TranslationTask.cpp @@ -11,7 +11,7 @@ namespace Moses2 TranslationTask::TranslationTask(System &system, const std::string &line, long translationId) { - if (system.searchAlgorithm == CYKPlus) { + if (system.options.search.algo == CYKPlus) { m_mgr = new SCFG::Manager(system, *this, line, translationId); } else {