#include <ChartHypothesisCollection.h>
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 HypoList & | GetSortedHypotheses () 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 &) |
Definition at line 46 of file ChartHypothesisCollection.h.
typedef HCType::const_iterator Moses::ChartHypothesisCollection::const_iterator |
Definition at line 65 of file ChartHypothesisCollection.h.
typedef boost::unordered_set< ChartHypothesis*, UnorderedComparer<ChartHypothesis>, UnorderedComparer<ChartHypothesis> > Moses::ChartHypothesisCollection::HCType [protected] |
Definition at line 52 of file ChartHypothesisCollection.h.
typedef HCType::iterator Moses::ChartHypothesisCollection::iterator |
Definition at line 64 of file ChartHypothesisCollection.h.
Moses::ChartHypothesisCollection::ChartHypothesisCollection | ( | AllOptions const & | opts | ) |
Definition at line 37 of file ChartHypothesisCollection.cpp.
References Moses::SearchOptions::beam_width, Moses::NBestOptions::enabled, m_beamWidth, m_bestScore, m_maxHypoStackSize, m_nBestIsEnabled, Moses::AllOptions::nbest, Moses::AllOptions::search, and Moses::SearchOptions::stack_size.
Moses::ChartHypothesisCollection::~ChartHypothesisCollection | ( | ) |
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
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().
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.
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.
const_iterator Moses::ChartHypothesisCollection::begin | ( | ) | const [inline] |
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().
void Moses::ChartHypothesisCollection::Detach | ( | const HCType::iterator & | iter | ) |
Remove hypothesis pointed to by iterator but DOES NOT delete the object.
iter | iterator to delete |
Definition at line 161 of file ChartHypothesisCollection.cpp.
References m_hypos.
Referenced by AddHypothesis(), and Remove().
const_iterator Moses::ChartHypothesisCollection::end | ( | ) | const [inline] |
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] |
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().
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().
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.
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().
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().
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().
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.
translationId | unique, contiguous id for the input sentence | |
outputSearchGraphStream | stream to output the info to | |
reachable |
Definition at line 284 of file ChartHypothesisCollection.cpp.
References Moses::ChartSearchGraphWriter::WriteHypos().
Referenced by Moses::ChartCell::WriteSearchGraph().
std::ostream& operator<< | ( | std::ostream & | out, | |
const ChartHypothesisCollection & | coll | |||
) | [friend] |
Definition at line 289 of file ChartHypothesisCollection.cpp.
float Moses::ChartHypothesisCollection::m_beamWidth [protected] |
minimum score due to threashold pruning
Definition at line 57 of file ChartHypothesisCollection.h.
Referenced by AddHypothesis(), ChartHypothesisCollection(), and PruneToSize().
float Moses::ChartHypothesisCollection::m_bestScore [protected] |
score of the best hypothesis in collection
Definition at line 56 of file ChartHypothesisCollection.h.
Referenced by Add(), AddHypothesis(), ChartHypothesisCollection(), GetBestScore(), and PruneToSize().
HCType Moses::ChartHypothesisCollection::m_hypos [protected] |
Definition at line 53 of file ChartHypothesisCollection.h.
Referenced by Add(), AddHypothesis(), begin(), CleanupArcList(), Detach(), end(), GetHypo(), GetSize(), PruneToSize(), SortHypotheses(), and ~ChartHypothesisCollection().
Definition at line 54 of file ChartHypothesisCollection.h.
Referenced by GetSortedHypotheses(), Moses::operator<<(), and SortHypotheses().
size_t Moses::ChartHypothesisCollection::m_maxHypoStackSize [protected] |
maximum number of hypothesis allowed in this stack
Definition at line 58 of file ChartHypothesisCollection.h.
Referenced by Add(), ChartHypothesisCollection(), and PruneToSize().
bool Moses::ChartHypothesisCollection::m_nBestIsEnabled [protected] |
flag to determine whether to keep track of old arcs
Definition at line 59 of file ChartHypothesisCollection.h.
Referenced by AddHypothesis(), and ChartHypothesisCollection().