diff --git a/contrib/other-builds/moses2/Search/CubePruningCardinalStack/Stack.cpp b/contrib/other-builds/moses2/Search/CubePruningCardinalStack/Stack.cpp index 1f0c93c4f..1e86f8b31 100644 --- a/contrib/other-builds/moses2/Search/CubePruningCardinalStack/Stack.cpp +++ b/contrib/other-builds/moses2/Search/CubePruningCardinalStack/Stack.cpp @@ -92,8 +92,16 @@ Stack::SortedHypos Stack::GetSortedAndPruneHypos(const Manager &mgr) const MemPool &pool = mgr.GetPool(); - // divide hypos by [bitmap, last end pos] + // prune and sort + Hypotheses *allHypos = new (pool.Allocate()) Hypotheses(pool, GetHypoSize()); + size_t i = 0; BOOST_FOREACH(const Hypothesis *hypo, m_coll) { + (*allHypos)[i++] = hypo; + } + SortAndPruneHypos(mgr, *allHypos); + + // divide hypos by [bitmap, last end pos] + BOOST_FOREACH(const Hypothesis *hypo, *allHypos) { HypoCoverage key(&hypo->GetBitmap(), hypo->GetInputPath().range.GetEndPos()); Hypotheses *hypos; @@ -109,15 +117,42 @@ Stack::SortedHypos Stack::GetSortedAndPruneHypos(const Manager &mgr) const hypos->push_back(hypo); } - // put into real return variable and sort - BOOST_FOREACH(SortedHypos::value_type &val, ret) { - Hypotheses &hypos = *val.second; - SortAndPruneHypos(mgr, hypos); - } - return ret; } + +//Stack::SortedHypos Stack::GetSortedAndPruneHypos(const Manager &mgr) const +//{ +// SortedHypos ret; +// +// MemPool &pool = mgr.GetPool(); +// +// // divide hypos by [bitmap, last end pos] +// BOOST_FOREACH(const Hypothesis *hypo, m_coll) { +// HypoCoverage key(&hypo->GetBitmap(), hypo->GetInputPath().range.GetEndPos()); +// +// Hypotheses *hypos; +// SortedHypos::iterator iter; +// iter = ret.find(key); +// if (iter == ret.end()) { +// hypos = new (pool.Allocate()) Hypotheses(pool); +// ret[key] = hypos; +// } +// else { +// hypos = iter->second; +// } +// hypos->push_back(hypo); +// } +// +// // put into real return variable and sort +// BOOST_FOREACH(SortedHypos::value_type &val, ret) { +// Hypotheses &hypos = *val.second; +// SortAndPruneHypos(mgr, hypos); +// } +// +// return ret; +//} + void Stack::SortAndPruneHypos(const Manager &mgr, Hypotheses &hypos) const { size_t stackSize = mgr.system.stackSize; diff --git a/contrib/other-builds/moses2/TypeDef.h b/contrib/other-builds/moses2/TypeDef.h index eee0dd247..65edfc3c8 100644 --- a/contrib/other-builds/moses2/TypeDef.h +++ b/contrib/other-builds/moses2/TypeDef.h @@ -49,6 +49,7 @@ enum SearchAlgorithm { CubePruningPerMiniStack = 10, CubePruningPerBitmap = 11, CubePruningCardinalStack = 12, + CubePruningBitmapStack = 13, DefaultSearchAlgorithm = 777 // means: use StaticData.m_searchAlgorithm };