#include <HypothesisStackNormal.h>
Public Member Functions | |
float | GetWorstScoreForBitmap (WordsBitmapID id) |
virtual float | GetWorstScoreForBitmap (const Bitmap &coverage) |
HypothesisStackNormal (Manager &manager) | |
bool | AddPrune (Hypothesis *hypothesis) |
void | SetMaxHypoStackSize (size_t maxHypoStackSize, size_t minHypoStackDiversity) |
void | SetBeamWidth (float beamWidth) |
float | GetBestScore () const |
float | GetWorstScore () const |
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 | |
std::vector< Hypothesis * > | GetSortedListNOTCONST () |
void | CleanupArcList () |
TO_STRING () | |
Protected Member Functions | |
std::pair < HypothesisStackNormal::iterator, bool > | Add (Hypothesis *hypothesis) |
void | RemoveAll () |
void | SetWorstScoreForBitmap (WordsBitmapID id, float worstScore) |
Protected Attributes | |
float | m_bestScore |
float | m_worstScore |
std::map< WordsBitmapID, float > | m_diversityWorstScore |
float | m_beamWidth |
size_t | m_maxHypoStackSize |
size_t | m_minHypoStackDiversity |
bool | m_nBestIsEnabled |
Friends | |
std::ostream & | operator<< (std::ostream &, const HypothesisStackNormal &) |
Definition at line 37 of file HypothesisStackNormal.h.
Moses::HypothesisStackNormal::HypothesisStackNormal | ( | Manager & | manager | ) |
Definition at line 35 of file HypothesisStackNormal.cpp.
References m_bestScore, m_nBestIsEnabled, m_worstScore, and Moses::BaseManager::options().
pair< HypothesisStackNormal::iterator, bool > Moses::HypothesisStackNormal::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 51 of file HypothesisStackNormal.cpp.
References Moses::Hypothesis::GetFutureScore(), Moses::Bitmap::GetID(), Moses::Hypothesis::GetWordsBitmap(), GetWorstScoreForBitmap(), m_beamWidth, m_bestScore, Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_maxHypoStackSize, m_minHypoStackDiversity, m_worstScore, Moses::BaseManager::options(), PruneToSize(), SetWorstScoreForBitmap(), and VERBOSE.
Referenced by AddPrune().
bool Moses::HypothesisStackNormal::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 93 of file HypothesisStackNormal.cpp.
References Add(), Moses::Hypothesis::AddArc(), Moses::SentenceStats::AddDiscarded(), Moses::SentenceStats::AddRecombination(), Moses::HypothesisStack::Detach(), Moses::Hypothesis::GetFutureScore(), Moses::Hypothesis::GetId(), Moses::Manager::GetSentenceStats(), Moses::Hypothesis::GetWordsBitmap(), GetWorstScoreForBitmap(), Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_minHypoStackDiversity, m_nBestIsEnabled, m_worstScore, Moses::BaseManager::options(), Moses::HypothesisStack::Remove(), UTIL_THROW2, and VERBOSE.
void Moses::HypothesisStackNormal::CleanupArcList | ( | ) |
make all arcs in point to the equiv hypothesis that contains them. Ie update doubly linked list be hypo & arcs
Definition at line 264 of file HypothesisStackNormal.cpp.
References Moses::Hypothesis::CleanupArcList(), Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_nBestIsEnabled, and Moses::BaseManager::options().
Referenced by Moses::SearchNormal::ProcessOneStack().
const Hypothesis * Moses::HypothesisStackNormal::GetBestHypothesis | ( | ) | const [virtual] |
return the hypothesis with best score. Used to get the translated at end of decoding
Implements Moses::HypothesisStack.
Definition at line 229 of file HypothesisStackNormal.cpp.
References Moses::Hypothesis::GetFutureScore(), Moses::HypothesisStack::m_hypos, and NULL.
Referenced by Moses::SearchNormal::GetBestHypothesis().
float Moses::HypothesisStackNormal::GetBestScore | ( | ) | const [inline] |
return score of the best hypothesis in the stack
Definition at line 102 of file HypothesisStackNormal.h.
References m_bestScore.
vector< const Hypothesis * > Moses::HypothesisStackNormal::GetSortedList | ( | ) | const [virtual] |
return all hypothesis, sorted by descending score. Used in creation of N best list
Implements Moses::HypothesisStack.
Definition at line 244 of file HypothesisStackNormal.cpp.
References Moses::HypothesisStack::m_hypos, and sort().
vector< Hypothesis * > Moses::HypothesisStackNormal::GetSortedListNOTCONST | ( | ) |
Definition at line 254 of file HypothesisStackNormal.cpp.
References Moses::HypothesisStack::m_hypos, and sort().
Referenced by PruneToSize().
float Moses::HypothesisStackNormal::GetWorstScore | ( | ) | const [inline, virtual] |
return worst allowable score
Reimplemented from Moses::HypothesisStack.
Definition at line 106 of file HypothesisStackNormal.h.
References m_worstScore.
virtual float Moses::HypothesisStackNormal::GetWorstScoreForBitmap | ( | const Bitmap & | coverage | ) | [inline, virtual] |
Reimplemented from Moses::HypothesisStack.
Definition at line 69 of file HypothesisStackNormal.h.
References Moses::Bitmap::GetID(), and GetWorstScoreForBitmap().
float Moses::HypothesisStackNormal::GetWorstScoreForBitmap | ( | WordsBitmapID | id | ) | [inline, virtual] |
Reimplemented from Moses::HypothesisStack.
Definition at line 64 of file HypothesisStackNormal.h.
References m_diversityWorstScore.
Referenced by Add(), AddPrune(), and GetWorstScoreForBitmap().
void Moses::HypothesisStackNormal::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 157 of file HypothesisStackNormal.cpp.
References Moses::SentenceStats::AddPruning(), Moses::HypothesisStack::Detach(), Moses::Hypothesis::GetFutureScore(), Moses::Hypothesis::GetId(), Moses::Bitmap::GetID(), Moses::Manager::GetSentenceStats(), GetSortedListNOTCONST(), Moses::Hypothesis::GetWordsBitmap(), IFVERBOSE, m_beamWidth, m_bestScore, Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_minHypoStackDiversity, m_worstScore, SetWorstScoreForBitmap(), Moses::HypothesisStack::size(), TRACE_ERR, and VERBOSE.
Referenced by Add(), and Moses::SearchNormal::ProcessOneStack().
void Moses::HypothesisStackNormal::RemoveAll | ( | ) | [protected] |
destroy all instances of Hypothesis in this collection
remove all hypotheses from the collection
Definition at line 44 of file HypothesisStackNormal.cpp.
References Moses::HypothesisStack::m_hypos, and Moses::HypothesisStack::Remove().
void Moses::HypothesisStackNormal::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 98 of file HypothesisStackNormal.h.
References m_beamWidth.
Referenced by Moses::SearchNormal::SearchNormal().
void Moses::HypothesisStackNormal::SetMaxHypoStackSize | ( | size_t | maxHypoStackSize, | |
size_t | minHypoStackDiversity | |||
) | [inline] |
set maximum number of hypotheses in the collection
maxHypoStackSize | maximum number (typical number: 100) | |
maxHypoStackSize | maximum number (defauly: 0) |
Definition at line 89 of file HypothesisStackNormal.h.
References m_maxHypoStackSize, and m_minHypoStackDiversity.
Referenced by Moses::SearchNormal::SearchNormal().
void Moses::HypothesisStackNormal::SetWorstScoreForBitmap | ( | WordsBitmapID | id, | |
float | worstScore | |||
) | [inline, protected] |
Definition at line 59 of file HypothesisStackNormal.h.
References m_diversityWorstScore.
Referenced by Add(), and PruneToSize().
Moses::HypothesisStackNormal::TO_STRING | ( | ) |
std::ostream& operator<< | ( | std::ostream & | out, | |
const HypothesisStackNormal & | hypoColl | |||
) | [friend] |
Definition at line 280 of file HypothesisStackNormal.cpp.
float Moses::HypothesisStackNormal::m_beamWidth [protected] |
minimum score due to threashold pruning
Definition at line 46 of file HypothesisStackNormal.h.
Referenced by Add(), PruneToSize(), and SetBeamWidth().
float Moses::HypothesisStackNormal::m_bestScore [protected] |
score of the best hypothesis in collection
Definition at line 43 of file HypothesisStackNormal.h.
Referenced by Add(), GetBestScore(), HypothesisStackNormal(), and PruneToSize().
std::map< WordsBitmapID, float > Moses::HypothesisStackNormal::m_diversityWorstScore [protected] |
score of worst hypothesis for particular source word coverage
Definition at line 45 of file HypothesisStackNormal.h.
Referenced by GetWorstScoreForBitmap(), and SetWorstScoreForBitmap().
size_t Moses::HypothesisStackNormal::m_maxHypoStackSize [protected] |
maximum number of hypothesis allowed in this stack
Definition at line 47 of file HypothesisStackNormal.h.
Referenced by Add(), and SetMaxHypoStackSize().
size_t Moses::HypothesisStackNormal::m_minHypoStackDiversity [protected] |
minimum number of hypothesis with different source word coverage
Definition at line 48 of file HypothesisStackNormal.h.
Referenced by Add(), AddPrune(), PruneToSize(), and SetMaxHypoStackSize().
bool Moses::HypothesisStackNormal::m_nBestIsEnabled [protected] |
flag to determine whether to keep track of old arcs
Definition at line 49 of file HypothesisStackNormal.h.
Referenced by AddPrune(), CleanupArcList(), and HypothesisStackNormal().
float Moses::HypothesisStackNormal::m_worstScore [protected] |
score of the worse hypothesis in collection
Definition at line 44 of file HypothesisStackNormal.h.
Referenced by Add(), AddPrune(), GetWorstScore(), HypothesisStackNormal(), and PruneToSize().