Moses::HypothesisStackCubePruning Class Reference

#include <HypothesisStackCubePruning.h>

Inheritance diagram for Moses::HypothesisStackCubePruning:

Inheritance graph
[legend]
Collaboration diagram for Moses::HypothesisStackCubePruning:

Collaboration graph
[legend]

List of all members.

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 _BMTypeGetBitmapAccessor () 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 HypothesisGetBestHypothesis () 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 ()
BitmapContainerAddBitmapContainer (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 &)


Detailed Description

A stack for phrase-based decoding with cube-pruning.

Definition at line 45 of file HypothesisStackCubePruning.h.


Constructor & Destructor Documentation

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().

Here is the call graph for this function:

Moses::HypothesisStackCubePruning::~HypothesisStackCubePruning (  )  [inline]

Definition at line 72 of file HypothesisStackCubePruning.h.

References m_bitmapAccessor, and RemoveAll().

Here is the call graph for this function:


Member Function Documentation

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::HypothesisStackCubePruning::AddInitial ( Hypothesis hypo  ) 

Definition at line 145 of file HypothesisStackCubePruning.cpp.

References Add(), AddBitmapContainer(), Moses::Hypothesis::GetWordsBitmap(), and UTIL_THROW_IF2.

Here is the call graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Here is the call graph for this function:

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]

size_t Moses::HypothesisStackCubePruning::GetMaxHypoStackSize (  )  const [inline]

Definition at line 96 of file HypothesisStackCubePruning.h.

References m_maxHypoStackSize.

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().

Here is the call graph for this function:

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.

Parameters:
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().

Here is the call graph for this function:

Here is the caller graph for this function:

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().

Here is the caller graph for this function:

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

Parameters:
beamThreshold minimum factor (typical number: 0.03)

Definition at line 104 of file HypothesisStackCubePruning.h.

References m_beamWidth.

Referenced by Moses::SearchCubePruning::SearchCubePruning().

Here is the caller graph for this function:

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().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::HypothesisStackCubePruning::SetMaxHypoStackSize ( size_t  maxHypoStackSize  )  [inline]

set maximum number of hypotheses in the collection

Parameters:
maxHypoStackSize maximum number (typical number: 100)

Definition at line 92 of file HypothesisStackCubePruning.h.

References m_maxHypoStackSize.

Referenced by Moses::SearchCubePruning::SearchCubePruning().

Here is the caller graph for this function:

Moses::HypothesisStackCubePruning::TO_STRING (  ) 


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const HypothesisStackCubePruning hypoColl 
) [friend]

Definition at line 273 of file HypothesisStackCubePruning.cpp.


Member Data Documentation

minimum score due to threashold pruning

Definition at line 55 of file HypothesisStackCubePruning.h.

Referenced by Add(), PruneToSize(), and SetBeamWidth().

score of the best hypothesis in collection

Definition at line 53 of file HypothesisStackCubePruning.h.

Referenced by Add(), GetBestScore(), HypothesisStackCubePruning(), and PruneToSize().

flag to determine whether to sort hypotheses deterministically

Definition at line 58 of file HypothesisStackCubePruning.h.

Referenced by AddBitmapContainer(), HypothesisStackCubePruning(), and SetBitmapAccessor().

maximum number of hypothesis allowed in this stack

Definition at line 56 of file HypothesisStackCubePruning.h.

Referenced by Add(), GetMaxHypoStackSize(), and SetMaxHypoStackSize().

flag to determine whether to keep track of old arcs

Definition at line 57 of file HypothesisStackCubePruning.h.

Referenced by AddPrune(), CleanupArcList(), and HypothesisStackCubePruning().

score of the worse hypthesis in collection

Definition at line 54 of file HypothesisStackCubePruning.h.

Referenced by Add(), AddPrune(), GetWorstScore(), HypothesisStackCubePruning(), and PruneToSize().


The documentation for this class was generated from the following files:

Generated on Sat Jun 25 00:32:05 2016 for Moses by  doxygen 1.5.9