#include <HypothesisStackCubePruning.h>
Public Member Functions | |
HypothesisStackCubePruning (Manager &manager) | |
~HypothesisStackCubePruning () | |
bool | AddPrune (Hypothesis *hypothesis) |
void | AddInitial (Hypothesis *hypo) |
void | SetMaxHypoStackSize (size_t maxHypoStackSize) |
size_t | GetMaxHypoStackSize () const |
void | SetBeamWidth (float beamWidth) |
float | GetBestScore () const |
float | GetWorstScore () const |
void | AddHypothesesToBitmapContainers () |
const _BMType & | GetBitmapAccessor () const |
void | SetBitmapAccessor (const Bitmap &newBitmap, HypothesisStackCubePruning &stack, const Range &range, BitmapContainer &bitmapContainer, const SquareMatrix &estimatedScores, const TranslationOptionList &transOptList) |
void | PruneToSize (size_t newSize) |
const Hypothesis * | GetBestHypothesis () const |
return the hypothesis with best score. Used to get the translated at end of decoding | |
std::vector< const Hypothesis * > | GetSortedList () const |
return all hypothesis, sorted by descending score. Used in creation of N best list | |
void | CleanupArcList () |
TO_STRING () | |
Protected Member Functions | |
std::pair < HypothesisStackCubePruning::iterator, bool > | Add (Hypothesis *hypothesis) |
void | RemoveAll () |
BitmapContainer * | AddBitmapContainer (const Bitmap &bitmap, HypothesisStackCubePruning &stack) |
Protected Attributes | |
_BMType | m_bitmapAccessor |
float | m_bestScore |
float | m_worstScore |
float | m_beamWidth |
size_t | m_maxHypoStackSize |
bool | m_nBestIsEnabled |
bool | m_deterministic |
Friends | |
std::ostream & | operator<< (std::ostream &, const HypothesisStackCubePruning &) |
Definition at line 45 of file HypothesisStackCubePruning.h.
Moses::HypothesisStackCubePruning::HypothesisStackCubePruning | ( | Manager & | manager | ) |
Definition at line 36 of file HypothesisStackCubePruning.cpp.
References m_bestScore, m_deterministic, m_nBestIsEnabled, m_worstScore, and Moses::BaseManager::options().
Moses::HypothesisStackCubePruning::~HypothesisStackCubePruning | ( | ) | [inline] |
Definition at line 72 of file HypothesisStackCubePruning.h.
References m_bitmapAccessor, and RemoveAll().
pair< HypothesisStackCubePruning::iterator, bool > Moses::HypothesisStackCubePruning::Add | ( | Hypothesis * | hypothesis | ) | [protected] |
add hypothesis to stack. Prune if necessary. Returns false if equiv hypo exists in collection, otherwise returns true
Definition at line 55 of file HypothesisStackCubePruning.cpp.
References Moses::Hypothesis::GetFutureScore(), m_beamWidth, m_bestScore, Moses::HypothesisStack::m_hypos, m_maxHypoStackSize, m_worstScore, PruneToSize(), and VERBOSE.
Referenced by AddInitial(), and AddPrune().
BitmapContainer * Moses::HypothesisStackCubePruning::AddBitmapContainer | ( | const Bitmap & | bitmap, | |
HypothesisStackCubePruning & | stack | |||
) | [protected] |
Definition at line 297 of file HypothesisStackCubePruning.cpp.
References m_bitmapAccessor, and m_deterministic.
Referenced by AddInitial(), and SetBitmapAccessor().
void Moses::HypothesisStackCubePruning::AddHypothesesToBitmapContainers | ( | ) |
Definition at line 286 of file HypothesisStackCubePruning.cpp.
References Moses::BitmapContainer::AddHypothesis(), Moses::Hypothesis::GetWordsBitmap(), m_bitmapAccessor, and Moses::HypothesisStack::m_hypos.
Referenced by Moses::SearchCubePruning::CreateForwardTodos().
void Moses::HypothesisStackCubePruning::AddInitial | ( | Hypothesis * | hypo | ) |
Definition at line 145 of file HypothesisStackCubePruning.cpp.
References Add(), AddBitmapContainer(), Moses::Hypothesis::GetWordsBitmap(), and UTIL_THROW_IF2.
bool Moses::HypothesisStackCubePruning::AddPrune | ( | Hypothesis * | hypothesis | ) | [virtual] |
adds the hypo, but only if within thresholds (beamThr, stackSize). This function will recombine hypotheses silently! There is no record (could affect n-best list generation...TODO) Call stack for adding hypothesis is AddPrune() Add() AddNoPrune()
Implements Moses::HypothesisStack.
Definition at line 84 of file HypothesisStackCubePruning.cpp.
References Add(), Moses::Hypothesis::AddArc(), Moses::SentenceStats::AddDiscarded(), Moses::SentenceStats::AddRecombination(), Moses::HypothesisStack::Detach(), Moses::Hypothesis::GetFutureScore(), Moses::Manager::GetSentenceStats(), Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_nBestIsEnabled, m_worstScore, Moses::HypothesisStack::Remove(), UTIL_THROW, and VERBOSE.
Referenced by Moses::BitmapContainer::ProcessBestHypothesis().
void Moses::HypothesisStackCubePruning::CleanupArcList | ( | ) |
make all arcs in point to the equiv hypothesis that contains them. Ie update doubly linked list be hypo & arcs
Definition at line 239 of file HypothesisStackCubePruning.cpp.
References Moses::Hypothesis::CleanupArcList(), Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_nBestIsEnabled, and Moses::BaseManager::options().
Referenced by Moses::SearchCubePruning::Decode().
const Hypothesis * Moses::HypothesisStackCubePruning::GetBestHypothesis | ( | ) | const [virtual] |
return the hypothesis with best score. Used to get the translated at end of decoding
Implements Moses::HypothesisStack.
Definition at line 213 of file HypothesisStackCubePruning.cpp.
References Moses::Hypothesis::GetFutureScore(), Moses::HypothesisStack::m_hypos, and NULL.
float Moses::HypothesisStackCubePruning::GetBestScore | ( | ) | const [inline] |
return score of the best hypothesis in the stack
Definition at line 109 of file HypothesisStackCubePruning.h.
References m_bestScore.
const _BMType& Moses::HypothesisStackCubePruning::GetBitmapAccessor | ( | ) | const [inline] |
Definition at line 120 of file HypothesisStackCubePruning.h.
References m_bitmapAccessor.
Referenced by Moses::SearchCubePruning::CreateForwardTodos(), Moses::SearchCubePruning::Decode(), and Moses::SearchCubePruning::PrintBitmapContainerGraph().
size_t Moses::HypothesisStackCubePruning::GetMaxHypoStackSize | ( | ) | const [inline] |
vector< const Hypothesis * > Moses::HypothesisStackCubePruning::GetSortedList | ( | ) | const [virtual] |
return all hypothesis, sorted by descending score. Used in creation of N best list
Implements Moses::HypothesisStack.
Definition at line 228 of file HypothesisStackCubePruning.cpp.
References Moses::HypothesisStack::m_hypos, and sort().
float Moses::HypothesisStackCubePruning::GetWorstScore | ( | ) | const [inline, virtual] |
return worst score allowed for the stack
Reimplemented from Moses::HypothesisStack.
Definition at line 114 of file HypothesisStackCubePruning.h.
References m_worstScore.
void Moses::HypothesisStackCubePruning::PruneToSize | ( | size_t | newSize | ) |
pruning, if too large. Pruning algorithm: find a threshold and delete all hypothesis below it. The threshold is chosen so that exactly newSize top items remain on the stack in fact, in situations where some of the hypothesis fell below m_beamWidth, the stack will contain less items.
newSize | maximum size |
Definition at line 155 of file HypothesisStackCubePruning.cpp.
References Moses::SentenceStats::AddPruning(), Moses::Hypothesis::GetFutureScore(), Moses::Hypothesis::GetId(), Moses::Manager::GetSentenceStats(), IFVERBOSE, m_beamWidth, m_bestScore, Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_worstScore, Moses::HypothesisStack::Remove(), Moses::HypothesisStack::size(), TRACE_ERR, and VERBOSE.
Referenced by Add(), and Moses::SearchCubePruning::Decode().
void Moses::HypothesisStackCubePruning::RemoveAll | ( | ) | [protected] |
destroy all instances of Hypothesis in this collection
remove all hypotheses from the collection
Definition at line 46 of file HypothesisStackCubePruning.cpp.
References m_bitmapAccessor.
Referenced by ~HypothesisStackCubePruning().
void Moses::HypothesisStackCubePruning::SetBeamWidth | ( | float | beamWidth | ) | [inline] |
set beam threshold, hypotheses in the stack must not be worse than this factor times the best score to be allowed in the stack
beamThreshold | minimum factor (typical number: 0.03) |
Definition at line 104 of file HypothesisStackCubePruning.h.
References m_beamWidth.
Referenced by Moses::SearchCubePruning::SearchCubePruning().
void Moses::HypothesisStackCubePruning::SetBitmapAccessor | ( | const Bitmap & | newBitmap, | |
HypothesisStackCubePruning & | stack, | |||
const Range & | range, | |||
BitmapContainer & | bitmapContainer, | |||
const SquareMatrix & | estimatedScores, | |||
const TranslationOptionList & | transOptList | |||
) |
Definition at line 251 of file HypothesisStackCubePruning.cpp.
References Moses::BitmapContainer::AddBackwardsEdge(), AddBitmapContainer(), Moses::Manager::GetSource(), m_deterministic, and Moses::HypothesisStack::m_manager.
Referenced by Moses::SearchCubePruning::CreateForwardTodos().
void Moses::HypothesisStackCubePruning::SetMaxHypoStackSize | ( | size_t | maxHypoStackSize | ) | [inline] |
set maximum number of hypotheses in the collection
maxHypoStackSize | maximum number (typical number: 100) |
Definition at line 92 of file HypothesisStackCubePruning.h.
References m_maxHypoStackSize.
Referenced by Moses::SearchCubePruning::SearchCubePruning().
Moses::HypothesisStackCubePruning::TO_STRING | ( | ) |
std::ostream& operator<< | ( | std::ostream & | out, | |
const HypothesisStackCubePruning & | hypoColl | |||
) | [friend] |
Definition at line 273 of file HypothesisStackCubePruning.cpp.
float Moses::HypothesisStackCubePruning::m_beamWidth [protected] |
minimum score due to threashold pruning
Definition at line 55 of file HypothesisStackCubePruning.h.
Referenced by Add(), PruneToSize(), and SetBeamWidth().
float Moses::HypothesisStackCubePruning::m_bestScore [protected] |
score of the best hypothesis in collection
Definition at line 53 of file HypothesisStackCubePruning.h.
Referenced by Add(), GetBestScore(), HypothesisStackCubePruning(), and PruneToSize().
Definition at line 51 of file HypothesisStackCubePruning.h.
Referenced by AddBitmapContainer(), AddHypothesesToBitmapContainers(), GetBitmapAccessor(), RemoveAll(), and ~HypothesisStackCubePruning().
bool Moses::HypothesisStackCubePruning::m_deterministic [protected] |
flag to determine whether to sort hypotheses deterministically
Definition at line 58 of file HypothesisStackCubePruning.h.
Referenced by AddBitmapContainer(), HypothesisStackCubePruning(), and SetBitmapAccessor().
size_t Moses::HypothesisStackCubePruning::m_maxHypoStackSize [protected] |
maximum number of hypothesis allowed in this stack
Definition at line 56 of file HypothesisStackCubePruning.h.
Referenced by Add(), GetMaxHypoStackSize(), and SetMaxHypoStackSize().
bool Moses::HypothesisStackCubePruning::m_nBestIsEnabled [protected] |
flag to determine whether to keep track of old arcs
Definition at line 57 of file HypothesisStackCubePruning.h.
Referenced by AddPrune(), CleanupArcList(), and HypothesisStackCubePruning().
float Moses::HypothesisStackCubePruning::m_worstScore [protected] |
score of the worse hypthesis in collection
Definition at line 54 of file HypothesisStackCubePruning.h.
Referenced by Add(), AddPrune(), GetWorstScore(), HypothesisStackCubePruning(), and PruneToSize().