diff options
author | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-10-31 15:50:52 +0300 |
---|---|---|
committer | Ulrich Germann <Ulrich.Germann@gmail.com> | 2015-10-31 15:50:52 +0300 |
commit | 324c378f7fc54f02a8ea264915d3eade867ff23d (patch) | |
tree | 2bb934fee448845b0524427d437c871e7118ac2c /moses/ChartCell.cpp | |
parent | dc8ad899454bd82408c6a371d5f50e497ede0caa (diff) |
Options refactoring. Moses crashed in server mode when asked to provide n-best translations with scores.
Diffstat (limited to 'moses/ChartCell.cpp')
-rw-r--r-- | moses/ChartCell.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/moses/ChartCell.cpp b/moses/ChartCell.cpp index f0a25986a..89108ebf9 100644 --- a/moses/ChartCell.cpp +++ b/moses/ChartCell.cpp @@ -27,7 +27,6 @@ #include "RuleCube.h" #include "Range.h" #include "Util.h" -#include "StaticData.h" #include "ChartTranslationOptions.h" #include "ChartTranslationOptionList.h" #include "ChartManager.h" @@ -52,8 +51,7 @@ ChartCellBase::~ChartCellBase() {} ChartCell::ChartCell(size_t startPos, size_t endPos, ChartManager &manager) : ChartCellBase(startPos, endPos), m_manager(manager) { - const StaticData &staticData = StaticData::Instance(); - m_nBestIsEnabled = staticData.options().nbest.enabled; + m_nBestIsEnabled = manager.options().nbest.enabled; } ChartCell::~ChartCell() {} @@ -66,7 +64,14 @@ ChartCell::~ChartCell() {} bool ChartCell::AddHypothesis(ChartHypothesis *hypo) { const Word &targetLHS = hypo->GetTargetLHS(); - return m_hypoColl[targetLHS].AddHypothesis(hypo, m_manager); + MapType::iterator m = m_hypoColl.find(targetLHS); + if (m == m_hypoColl.end()) + { + std::pair<Word, ChartHypothesisCollection> + e(targetLHS, ChartHypothesisCollection(m_manager.options())); + m = m_hypoColl.insert(e).first; + } + return m->second.AddHypothesis(hypo, m_manager); } /** Prune each collection in this cell to a particular size */ @@ -87,8 +92,6 @@ void ChartCell::PruneToSize() void ChartCell::Decode(const ChartTranslationOptionList &transOptList , const ChartCellCollection &allChartCells) { - const StaticData &staticData = StaticData::Instance(); - // priority queue for applicable rules with selected hypotheses RuleCubeQueue queue(m_manager); @@ -100,7 +103,7 @@ void ChartCell::Decode(const ChartTranslationOptionList &transOptList } // pluck things out of queue and add to hypo collection - const size_t popLimit = staticData.options().cube.pop_limit; + const size_t popLimit = m_manager.options().cube.pop_limit; for (size_t numPops = 0; numPops < popLimit && !queue.IsEmpty(); ++numPops) { ChartHypothesis *hypo = queue.Pop(); AddHypothesis(hypo); |