Moses::ChartHypothesisCollection Class Reference

#include <ChartHypothesisCollection.h>

List of all members.

Public Types

typedef HCType::iterator iterator
typedef HCType::const_iterator const_iterator

Public Member Functions

const_iterator begin () const
 iterators
const_iterator end () const
 ChartHypothesisCollection (AllOptions const &opts)
 ~ChartHypothesisCollection ()
bool AddHypothesis (ChartHypothesis *hypo, ChartManager &manager)
void Detach (const HCType::iterator &iter)
void Remove (const HCType::iterator &iter)
void PruneToSize (ChartManager &manager)
size_t GetSize () const
size_t GetHypo () const
void SortHypotheses ()
 sort hypothses by descending score. Put these hypos into a vector m_hyposOrdered to be returned by function GetSortedHypotheses()
void CleanupArcList ()
 Call CleanupArcList() for each main hypo in collection.
const HypoListGetSortedHypotheses () const
 return vector of hypothesis that has been sorted by score
float GetBestScore () const
 return the best total score of all hypos in this collection
void WriteSearchGraph (const ChartSearchGraphWriter &writer, const std::map< unsigned, bool > &reachable) const

Protected Types

typedef boost::unordered_set
< ChartHypothesis
*, UnorderedComparer
< ChartHypothesis >
, UnorderedComparer
< ChartHypothesis > > 
HCType

Protected Member Functions

std::pair< HCType::iterator, bool > Add (ChartHypothesis *hypo, ChartManager &manager)

Protected Attributes

HCType m_hypos
HypoList m_hyposOrdered
float m_bestScore
float m_beamWidth
size_t m_maxHypoStackSize
bool m_nBestIsEnabled

Friends

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


Detailed Description

Contains a set of unique hypos that have the same HS non-term. ie. 1 of these for each target LHS in each cell

Definition at line 46 of file ChartHypothesisCollection.h.


Member Typedef Documentation

typedef HCType::const_iterator Moses::ChartHypothesisCollection::const_iterator

Definition at line 65 of file ChartHypothesisCollection.h.

Definition at line 52 of file ChartHypothesisCollection.h.

Definition at line 64 of file ChartHypothesisCollection.h.


Constructor & Destructor Documentation

Moses::ChartHypothesisCollection::ChartHypothesisCollection ( AllOptions const &  opts  ) 

Moses::ChartHypothesisCollection::~ChartHypothesisCollection (  ) 

Definition at line 47 of file ChartHypothesisCollection.cpp.

References m_hypos.


Member Function Documentation

pair< ChartHypothesisCollection::HCType::iterator, bool > Moses::ChartHypothesisCollection::Add ( ChartHypothesis hypo,
ChartManager manager 
) [protected]

add hypothesis to stack. Prune if necessary. Returns false if equiv hypo exists in collection, otherwise returns true, and the iterator that points to the place where the hypo was added

Parameters:
hypo hypothesis to add
manager pointer back to manager

Definition at line 133 of file ChartHypothesisCollection.cpp.

References Moses::ChartHypothesis::GetFutureScore(), m_bestScore, m_hypos, m_maxHypoStackSize, PruneToSize(), and VERBOSE.

Referenced by AddHypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::ChartHypothesisCollection::AddHypothesis ( ChartHypothesis hypo,
ChartManager manager 
)

public function to add hypothesis to this collection. Returns false if equiv hypo exists in collection, otherwise returns true. Takes care of update arc list for n-best list creation. Will delete hypo if it exists - once this function is call don't delete hypothesis.

Parameters:
hypo hypothesis to add
manager pointer back to manager

Definition at line 64 of file ChartHypothesisCollection.cpp.

References Add(), Moses::ChartHypothesis::AddArc(), Moses::SentenceStats::AddDiscarded(), Detach(), Moses::ChartHypothesis::GetFutureScore(), Moses::ChartHypothesis::GetId(), Moses::ChartManager::GetSentenceStats(), m_beamWidth, m_bestScore, m_hypos, m_nBestIsEnabled, Remove(), UTIL_THROW2, UTIL_THROW_IF2, and VERBOSE.

Here is the call graph for this function:

const_iterator Moses::ChartHypothesisCollection::begin (  )  const [inline]

iterators

Definition at line 67 of file ChartHypothesisCollection.h.

References m_hypos.

void Moses::ChartHypothesisCollection::CleanupArcList (  ) 

Call CleanupArcList() for each main hypo in collection.

Definition at line 269 of file ChartHypothesisCollection.cpp.

References Moses::ChartHypothesis::CleanupArcList(), and m_hypos.

Referenced by Moses::ChartCell::CleanupArcList().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::ChartHypothesisCollection::Detach ( const HCType::iterator &  iter  ) 

Remove hypothesis pointed to by iterator but DOES NOT delete the object.

Parameters:
iter iterator to delete

Definition at line 161 of file ChartHypothesisCollection.cpp.

References m_hypos.

Referenced by AddHypothesis(), and Remove().

Here is the caller graph for this function:

const_iterator Moses::ChartHypothesisCollection::end (  )  const [inline]

Definition at line 70 of file ChartHypothesisCollection.h.

References m_hypos.

float Moses::ChartHypothesisCollection::GetBestScore (  )  const [inline]

return the best total score of all hypos in this collection

Definition at line 99 of file ChartHypothesisCollection.h.

References m_bestScore.

size_t Moses::ChartHypothesisCollection::GetHypo (  )  const [inline]

Definition at line 86 of file ChartHypothesisCollection.h.

References m_hypos.

size_t Moses::ChartHypothesisCollection::GetSize (  )  const [inline]

Definition at line 83 of file ChartHypothesisCollection.h.

References m_hypos.

Referenced by Moses::ChartCell::GetSize(), Moses::ChartCell::OutputSizes(), PruneToSize(), and Moses::ChartCell::SortHypotheses().

Here is the caller graph for this function:

const HypoList& Moses::ChartHypothesisCollection::GetSortedHypotheses (  )  const [inline]

return vector of hypothesis that has been sorted by score

Definition at line 94 of file ChartHypothesisCollection.h.

References m_hyposOrdered.

Referenced by Moses::ChartCell::GetAllSortedHypotheses(), and Moses::ChartCell::SortHypotheses().

Here is the caller graph for this function:

void Moses::ChartHypothesisCollection::PruneToSize ( ChartManager manager  ) 

prune number of hypo to a particular number of hypos, specified by m_maxHypoStackSize, according to score Don't prune of hypos have identical scores on the boundary, so occasionally number of hypo can remain above m_maxHypoStackSize.

Parameters:
manager reference back to manager. Used for collecting stats

Definition at line 179 of file ChartHypothesisCollection.cpp.

References Moses::SentenceStats::AddPruning(), Moses::ChartHypothesis::GetFutureScore(), Moses::ChartHypothesis::GetId(), Moses::ChartManager::GetSentenceStats(), GetSize(), IFVERBOSE, m_beamWidth, m_bestScore, m_hypos, m_maxHypoStackSize, Remove(), sort(), TRACE_ERR, UTIL_THROW_IF2, and VERBOSE.

Referenced by Add(), and Moses::ChartCell::PruneToSize().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::ChartHypothesisCollection::Remove ( const HCType::iterator &  iter  ) 

destroy iterator AND hypothesis pointed to by iterator. If in an object pool, takes care of that too

Definition at line 168 of file ChartHypothesisCollection.cpp.

References Detach().

Referenced by AddHypothesis(), and PruneToSize().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::ChartHypothesisCollection::SortHypotheses (  ) 

sort hypothses by descending score. Put these hypos into a vector m_hyposOrdered to be returned by function GetSortedHypotheses()

Definition at line 255 of file ChartHypothesisCollection.cpp.

References m_hypos, m_hyposOrdered, sort(), and UTIL_THROW_IF2.

Referenced by Moses::ChartCell::SortHypotheses().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::ChartHypothesisCollection::WriteSearchGraph ( const ChartSearchGraphWriter writer,
const std::map< unsigned, bool > &  reachable 
) const

Return all hypos, and all hypos in the arclist, in order to create the output searchgraph, ie. the hypergraph. The output is the debug hypo information.

Todo:
this is a useful function. Make sure it outputs everything required, especially scores.
Parameters:
translationId unique, contiguous id for the input sentence
outputSearchGraphStream stream to output the info to
reachable 
Todo:
don't know

Definition at line 284 of file ChartHypothesisCollection.cpp.

References Moses::ChartSearchGraphWriter::WriteHypos().

Referenced by Moses::ChartCell::WriteSearchGraph().

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const ChartHypothesisCollection coll 
) [friend]

Definition at line 289 of file ChartHypothesisCollection.cpp.


Member Data Documentation

minimum score due to threashold pruning

Definition at line 57 of file ChartHypothesisCollection.h.

Referenced by AddHypothesis(), ChartHypothesisCollection(), and PruneToSize().

score of the best hypothesis in collection

Definition at line 56 of file ChartHypothesisCollection.h.

Referenced by Add(), AddHypothesis(), ChartHypothesisCollection(), GetBestScore(), and PruneToSize().

maximum number of hypothesis allowed in this stack

Definition at line 58 of file ChartHypothesisCollection.h.

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

flag to determine whether to keep track of old arcs

Definition at line 59 of file ChartHypothesisCollection.h.

Referenced by AddHypothesis(), and ChartHypothesisCollection().


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

Generated on Thu Jul 6 00:32:54 2017 for Moses by  doxygen 1.5.9