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 WordsBitmap &newBitmap, HypothesisStackCubePruning &stack, const WordsRange &range, BitmapContainer &bitmapContainer, const SquareMatrix &futureScore, 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 ()

Protected Attributes

_BMType m_bitmapAccessor
float m_bestScore
float m_worstScore
float m_beamWidth
size_t m_maxHypoStackSize
bool m_nBestIsEnabled

Friends

std::ostream & operator<< (std::ostream &, const HypothesisStackCubePruning &)


Detailed Description

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

Definition at line 42 of file HypothesisStackCubePruning.h.


Constructor & Destructor Documentation

Moses::HypothesisStackCubePruning::HypothesisStackCubePruning ( Manager manager  ) 

Definition at line 35 of file HypothesisStackCubePruning.cpp.

References Moses::StaticData::Instance(), Moses::StaticData::IsNBestEnabled(), m_bestScore, m_nBestIsEnabled, and m_worstScore.

Here is the call graph for this function:

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

Definition at line 66 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 53 of file HypothesisStackCubePruning.cpp.

References Moses::Hypothesis::GetTotalScore(), 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:

void Moses::HypothesisStackCubePruning::AddHypothesesToBitmapContainers (  ) 

Definition at line 283 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 137 of file HypothesisStackCubePruning.cpp.

References Add(), CHECK, Moses::Hypothesis::GetWordsBitmap(), and m_bitmapAccessor.

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

Here is the call graph for this function:

Here is the caller 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 82 of file HypothesisStackCubePruning.cpp.

References Add(), Moses::Hypothesis::AddArc(), Moses::SentenceStats::AddDiscarded(), Moses::SentenceStats::AddRecombination(), CHECK, Moses::HypothesisStack::Detach(), FREEHYPO, Moses::Hypothesis::GetId(), Moses::Manager::GetSentenceStats(), Moses::Hypothesis::GetTotalScore(), Moses::HypothesisStack::m_hypos, Moses::HypothesisStack::m_manager, m_nBestIsEnabled, m_worstScore, Moses::HypothesisStack::Remove(), TRACE_ERR, 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 228 of file HypothesisStackCubePruning.cpp.

References Moses::Hypothesis::CleanupArcList(), Moses::HypothesisStack::m_hypos, and m_nBestIsEnabled.

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

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 202 of file HypothesisStackCubePruning.cpp.

References Moses::Hypothesis::GetTotalScore(), 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 103 of file HypothesisStackCubePruning.h.

References m_bestScore.

const _BMType& Moses::HypothesisStackCubePruning::GetBitmapAccessor (  )  const [inline]

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

Definition at line 90 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 217 of file HypothesisStackCubePruning.cpp.

References Moses::HypothesisStack::m_hypos.

float Moses::HypothesisStackCubePruning::GetWorstScore (  )  const [inline, virtual]

return worst score allowed for the stack

Reimplemented from Moses::HypothesisStack.

Definition at line 108 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 146 of file HypothesisStackCubePruning.cpp.

References Moses::SentenceStats::AddPruning(), Moses::Hypothesis::GetId(), Moses::Manager::GetSentenceStats(), Moses::Hypothesis::GetTotalScore(), 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::ProcessSentence().

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 44 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 98 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 WordsBitmap newBitmap,
HypothesisStackCubePruning stack,
const WordsRange range,
BitmapContainer bitmapContainer,
const SquareMatrix futureScore,
const TranslationOptionList transOptList 
)

Definition at line 240 of file HypothesisStackCubePruning.cpp.

References Moses::BitmapContainer::AddBackwardsEdge(), Moses::Manager::GetSource(), m_bitmapAccessor, 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 86 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 270 of file HypothesisStackCubePruning.cpp.


Member Data Documentation

minimum score due to threashold pruning

Definition at line 52 of file HypothesisStackCubePruning.h.

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

score of the best hypothesis in collection

Definition at line 50 of file HypothesisStackCubePruning.h.

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

maximum number of hypothesis allowed in this stack

Definition at line 53 of file HypothesisStackCubePruning.h.

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

flag to determine whether to keep track of old arcs

Definition at line 54 of file HypothesisStackCubePruning.h.

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

score of the worse hypthesis in collection

Definition at line 51 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 Sun Apr 20 00:31:10 2014 for Moses by  doxygen 1.5.9