Moses::Hypothesis Class Reference

#include <Hypothesis.h>

Collaboration diagram for Moses::Hypothesis:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 ~Hypothesis ()
HypothesisCreateNext (const TranslationOption &transOpt, const Phrase *constraint) const
void PrintHypothesis () const
const InputTypeGetInput () const
const TargetPhraseGetCurrTargetPhrase () const
const WordsRangeGetCurrSourceWordsRange () const
const WordsRangeGetCurrTargetWordsRange () const
ManagerGetManager () const
size_t GetCurrTargetLength () const
void ResetScore ()
void CalcScore (const SquareMatrix &futureScore)
float CalcExpectedScore (const SquareMatrix &futureScore)
void CalcRemainingScore ()
int GetId () const
const HypothesisGetPrevHypo () const
size_t GetSize () const
const PhraseGetSourcePhrase () const
std::string GetSourcePhraseStringRep (const std::vector< FactorType > factorsToPrint) const
std::string GetTargetPhraseStringRep (const std::vector< FactorType > factorsToPrint) const
std::string GetSourcePhraseStringRep () const
std::string GetTargetPhraseStringRep () const
const WordGetCurrWord (size_t pos) const
const FactorGetCurrFactor (size_t pos, FactorType factorType) const
const WordGetWord (size_t pos) const
const FactorGetFactor (size_t pos, FactorType factorType) const
const WordsBitmapGetWordsBitmap () const
bool IsSourceCompleted () const
int RecombineCompare (const Hypothesis &compare) const
void ToStream (std::ostream &out) const
 TO_STRING ()
void SetWinningHypo (const Hypothesis *hypo)
const HypothesisGetWinningHypo () const
void AddArc (Hypothesis *loserHypo)
void CleanupArcList ()
const ArcListGetArcList () const
 returns a list alternative previous hypotheses (or NULL if n-best support is disabled)
const ScoreComponentCollectionGetScoreBreakdown () const
float GetTotalScore () const
float GetScore () const
size_t GetNextStartPos (const TranslationOption &transOpt) const
 target span that trans opt would populate if applied to this hypo. Used for alignment check
std::vector< std::vector
< unsigned int > > * 
GetLMStats () const
const TranslationOptionGetTranslationOption () const

Static Public Member Functions

static ObjectPool< Hypothesis > & GetObjectPool ()
static HypothesisCreate (const Hypothesis &prevHypo, const TranslationOption &transOpt, const Phrase *constraint)
static HypothesisCreate (Manager &manager, const WordsBitmap &initialCoverage)
static HypothesisCreate (Manager &manager, InputType const &source, const TargetPhrase &emptyTarget)

Protected Member Functions

 Hypothesis (Manager &manager, InputType const &source, const TargetPhrase &emptyTarget)
 Hypothesis (const Hypothesis &prevHypo, const TranslationOption &transOpt)

Protected Attributes

const Hypothesism_prevHypo
const TargetPhrasem_targetPhrase
Phrase const * m_sourcePhrase
WordsBitmap m_sourceCompleted
InputType const & m_sourceInput
WordsRange m_currSourceWordsRange
WordsRange m_currTargetWordsRange
bool m_wordDeleted
float m_totalScore
float m_futureScore
ScoreComponentCollection m_scoreBreakdown
std::vector< const FFState * > m_ffStates
const Hypothesism_winningHypo
ArcListm_arcList
const TranslationOptionm_transOpt
Managerm_manager
int m_id

Static Protected Attributes

static ObjectPool< Hypothesiss_objectPool

Friends

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


Detailed Description

Used to store a state in the beam search for the best translation. With its link back to the previous hypothesis m_prevHypo, we can trace back to the sentence start to read of the (partial) translation to this point.

The expansion of hypotheses is handled in the class Manager, which stores active hypothesis in the search in hypothesis stacks.

Definition at line 61 of file Hypothesis.h.


Constructor & Destructor Documentation

Moses::Hypothesis::Hypothesis ( Manager manager,
InputType const &  source,
const TargetPhrase emptyTarget 
) [protected]

numeric ID of this hypothesis, used for logging

used by initial seeding of the translation process

Definition at line 51 of file Hypothesis.cpp.

References Moses::SentenceStats::AddCreated(), Moses::Manager::GetSentenceStats(), Moses::TranslationSystem::GetStatefulFeatureFunctions(), Moses::Manager::GetTranslationSystem(), m_ffStates, m_manager, and ResetScore().

Referenced by Create().

Here is the call graph for this function:

Here is the caller graph for this function:

Moses::Hypothesis::Hypothesis ( const Hypothesis prevHypo,
const TranslationOption transOpt 
) [protected]

Moses::Hypothesis::~Hypothesis (  ) 

Definition at line 112 of file Hypothesis.cpp.

References FREEHYPO, m_arcList, m_ffStates, and NULL.


Member Function Documentation

void Moses::Hypothesis::AddArc ( Hypothesis loserHypo  ) 

Definition at line 129 of file Hypothesis.cpp.

References m_arcList.

Referenced by Moses::HypothesisStackNormal::AddPrune(), and Moses::HypothesisStackCubePruning::AddPrune().

Here is the caller graph for this function:

float Moses::Hypothesis::CalcExpectedScore ( const SquareMatrix futureScore  ) 

Calculates the expected score of extending this hypothesis with the specified translation option. Includes actual costs for everything except for expensive actual language model score. This function is used by early discarding. /param transOpt - translation option being considered

Definition at line 313 of file Hypothesis.cpp.

References Moses::SentenceStats::AddTimeEstimateScore(), Moses::SquareMatrix::CalcFutureScore(), CHECK, Moses::StaticData::GetAllWeights(), Moses::TranslationOption::GetFutureScore(), Moses::TranslationOption::GetScoreBreakdown(), Moses::Manager::GetSentenceStats(), IFVERBOSE, Moses::ScoreComponentCollection::InnerProduct(), Moses::StaticData::Instance(), m_futureScore, m_manager, m_scoreBreakdown, m_sourceCompleted, and m_transOpt.

Referenced by Moses::SearchNormal::ExpandHypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::CalcRemainingScore (  ) 

void Moses::Hypothesis::CalcScore ( const SquareMatrix futureScore  ) 

void Moses::Hypothesis::CleanupArcList (  ) 

Hypothesis * Moses::Hypothesis::Create ( Manager manager,
InputType const &  source,
const TargetPhrase emptyTarget 
) [static]

return the subclass of Hypothesis most appropriate to the given target phrase

Definition at line 219 of file Hypothesis.cpp.

References ObjectPool< T >::getPtr(), Hypothesis(), and s_objectPool.

Here is the call graph for this function:

static Hypothesis* Moses::Hypothesis::Create ( Manager manager,
const WordsBitmap initialCoverage 
) [static]

Hypothesis * Moses::Hypothesis::Create ( const Hypothesis prevHypo,
const TranslationOption transOpt,
const Phrase constraint 
) [static]

return the subclass of Hypothesis most appropriate to the given translation option

Definition at line 164 of file Hypothesis.cpp.

References GetCurrTargetWordsRange(), Moses::WordsRange::GetEndPos(), ObjectPool< T >::getPtr(), Moses::Phrase::GetSize(), Moses::Phrase::GetSubString(), Moses::TranslationOption::GetTargetPhrase(), Hypothesis(), Moses::Phrase::IsCompatible(), NULL, and s_objectPool.

Referenced by CreateNext(), Moses::SearchNormal::ProcessSentence(), and Moses::SearchCubePruning::ProcessSentence().

Here is the call graph for this function:

Here is the caller graph for this function:

Hypothesis * Moses::Hypothesis::CreateNext ( const TranslationOption transOpt,
const Phrase constraint 
) const

return the subclass of Hypothesis most appropriate to the given translation option

Definition at line 156 of file Hypothesis.cpp.

References Create().

Referenced by Moses::SearchNormal::ExpandHypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

const ArcList* Moses::Hypothesis::GetArcList (  )  const [inline]

returns a list alternative previous hypotheses (or NULL if n-best support is disabled)

Definition at line 227 of file Hypothesis.h.

References m_arcList.

Referenced by Moses::TrellisPath::CreateDeviantPaths(), Moses::Manager::GetConnectedGraph(), Moses::Manager::GetWinnerConnectedGraph(), Moses::Manager::GetWordGraph(), and pruneLatticeFB().

Here is the caller graph for this function:

const Factor* Moses::Hypothesis::GetCurrFactor ( size_t  pos,
FactorType  factorType 
) const [inline]

Definition at line 178 of file Hypothesis.h.

References Moses::Phrase::GetFactor(), and m_targetPhrase.

Here is the call graph for this function:

const WordsRange& Moses::Hypothesis::GetCurrSourceWordsRange (  )  const [inline]

size_t Moses::Hypothesis::GetCurrTargetLength (  )  const [inline]

output length of the translation option used to create this hypothesis

Definition at line 141 of file Hypothesis.h.

References Moses::WordsRange::GetNumWordsCovered(), and m_currTargetWordsRange.

Referenced by Moses::LanguageModelImplementation::Evaluate(), and Moses::TrellisPath::GetTargetWordsRange().

Here is the call graph for this function:

Here is the caller graph for this function:

const TargetPhrase& Moses::Hypothesis::GetCurrTargetPhrase (  )  const [inline]

const WordsRange& Moses::Hypothesis::GetCurrTargetWordsRange (  )  const [inline]

Definition at line 132 of file Hypothesis.h.

References m_currTargetWordsRange.

Referenced by Moses::SentenceStats::AddDeletedWords(), Create(), Moses::LanguageModelImplementation::Evaluate(), and GetWord().

Here is the caller graph for this function:

const Word& Moses::Hypothesis::GetCurrWord ( size_t  pos  )  const [inline]

curr - pos is relative from CURRENT hypothesis's starting index (ie, start of sentence would be some negative number, which is not allowed- USE WITH CAUTION)

Definition at line 175 of file Hypothesis.h.

References Moses::Phrase::GetWord(), and m_targetPhrase.

Referenced by GetWord().

Here is the call graph for this function:

Here is the caller graph for this function:

const Factor* Moses::Hypothesis::GetFactor ( size_t  pos,
FactorType  factorType 
) const [inline]

Definition at line 190 of file Hypothesis.h.

References GetWord().

Here is the call graph for this function:

int Moses::Hypothesis::GetId (  )  const [inline]

const InputType& Moses::Hypothesis::GetInput (  )  const [inline]

Definition at line 115 of file Hypothesis.h.

References m_sourceInput.

Referenced by Moses::Manager::CalcDecoderStatistics(), Moses::DistortionScoreProducer::CalculateDistortionScore(), and OutputInput().

Here is the caller graph for this function:

std::vector<std::vector<unsigned int> >* Moses::Hypothesis::GetLMStats (  )  const [inline]

Definition at line 246 of file Hypothesis.h.

References NULL.

Manager& Moses::Hypothesis::GetManager (  )  const [inline]

Definition at line 136 of file Hypothesis.h.

References m_manager.

Referenced by Moses::LanguageModelImplementation::Evaluate().

Here is the caller graph for this function:

size_t Moses::Hypothesis::GetNextStartPos ( const TranslationOption transOpt  )  const

target span that trans opt would populate if applied to this hypo. Used for alignment check

static ObjectPool<Hypothesis>& Moses::Hypothesis::GetObjectPool (  )  [inline, static]

Definition at line 96 of file Hypothesis.h.

References s_objectPool.

const Hypothesis * Moses::Hypothesis::GetPrevHypo (  )  const

float Moses::Hypothesis::GetScore (  )  const [inline]

const ScoreComponentCollection& Moses::Hypothesis::GetScoreBreakdown (  )  const [inline]

Definition at line 230 of file Hypothesis.h.

References m_scoreBreakdown.

Referenced by Moses::TrellisPath::InitScore(), Moses::OutputSearchNode(), Moses::OutputWordGraph(), and Moses::TrellisPath::TrellisPath().

Here is the caller graph for this function:

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

length of the partial translation (from the start of the sentence)

Definition at line 159 of file Hypothesis.h.

References Moses::WordsRange::GetEndPos(), and m_currTargetWordsRange.

Referenced by Moses::LanguageModelImplementation::Evaluate(), and pruneLatticeFB().

Here is the call graph for this function:

Here is the caller graph for this function:

const Phrase* Moses::Hypothesis::GetSourcePhrase (  )  const [inline]

Definition at line 163 of file Hypothesis.h.

References m_sourcePhrase.

Referenced by Moses::SentenceStats::AddDeletedWords(), and OutputInput().

Here is the caller graph for this function:

std::string Moses::Hypothesis::GetSourcePhraseStringRep (  )  const

Definition at line 494 of file Hypothesis.cpp.

References Moses::StaticData::GetMaxNumFactors(), Moses::Input, and Moses::StaticData::Instance().

Here is the call graph for this function:

std::string Moses::Hypothesis::GetSourcePhraseStringRep ( const std::vector< FactorType factorsToPrint  )  const

Referenced by Moses::OutputSearchNode(), and Moses::OutputWordGraph().

Here is the caller graph for this function:

std::string Moses::Hypothesis::GetTargetPhraseStringRep (  )  const

Definition at line 503 of file Hypothesis.cpp.

References Moses::StaticData::GetMaxNumFactors(), Moses::StaticData::Instance(), and Moses::Output.

Here is the call graph for this function:

std::string Moses::Hypothesis::GetTargetPhraseStringRep ( const std::vector< FactorType factorsToPrint  )  const

float Moses::Hypothesis::GetTotalScore (  )  const [inline]

const TranslationOption& Moses::Hypothesis::GetTranslationOption (  )  const [inline]

Definition at line 250 of file Hypothesis.h.

References m_transOpt.

Referenced by Moses::LexicalReordering::Evaluate().

Here is the caller graph for this function:

const Hypothesis* Moses::Hypothesis::GetWinningHypo (  )  const [inline]

Definition at line 219 of file Hypothesis.h.

References m_winningHypo.

Referenced by Moses::TrellisPath::InitScore().

Here is the caller graph for this function:

const Word& Moses::Hypothesis::GetWord ( size_t  pos  )  const [inline]

recursive - pos is relative from start of sentence

Definition at line 182 of file Hypothesis.h.

References CHECK, GetCurrTargetWordsRange(), GetCurrWord(), GetPrevHypo(), Moses::WordsRange::GetStartPos(), and NULL.

Referenced by Moses::LanguageModelImplementation::Evaluate(), and GetFactor().

Here is the call graph for this function:

Here is the caller graph for this function:

const WordsBitmap& Moses::Hypothesis::GetWordsBitmap (  )  const [inline]

bool Moses::Hypothesis::IsSourceCompleted (  )  const [inline]

Definition at line 201 of file Hypothesis.h.

References Moses::WordsBitmap::IsComplete(), and m_sourceCompleted.

Referenced by Moses::LanguageModelImplementation::Evaluate().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::PrintHypothesis (  )  const

int Moses::Hypothesis::RecombineCompare ( const Hypothesis compare  )  const

check, if two hypothesis can be recombined. this is actually a sorting function that allows us to keep an ordered list of hypotheses. This makes recombination much quicker.

Definition at line 234 of file Hypothesis.cpp.

References Moses::WordsBitmap::Compare(), m_ffStates, m_sourceCompleted, and NULL.

Referenced by Moses::HypothesisRecombinationOrderer::operator()().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::ResetScore (  ) 

Definition at line 255 of file Hypothesis.cpp.

References m_futureScore, m_scoreBreakdown, m_totalScore, and Moses::ScoreComponentCollection::ZeroAll().

Referenced by Hypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::SetWinningHypo ( const Hypothesis hypo  )  [inline]

Definition at line 216 of file Hypothesis.h.

References m_winningHypo.

Referenced by CleanupArcList().

Here is the caller graph for this function:

Moses::Hypothesis::TO_STRING (  ) 

void Moses::Hypothesis::ToStream ( std::ostream &  out  )  const [inline]

Definition at line 207 of file Hypothesis.h.

References GetCurrTargetPhrase(), m_prevHypo, NULL, and ToStream().

Referenced by ToStream().

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 &  ,
const Hypothesis  
) [friend]


Member Data Documentation

Definition at line 84 of file Hypothesis.h.

Referenced by AddArc(), CleanupArcList(), GetArcList(), and ~Hypothesis().

Definition at line 76 of file Hypothesis.h.

Referenced by GetCurrSourceWordsRange(), Hypothesis(), and PrintHypothesis().

source word positions of the last phrase that was used to create this hypothesis

Definition at line 77 of file Hypothesis.h.

Referenced by CalcRemainingScore(), GetCurrTargetLength(), GetCurrTargetWordsRange(), GetSize(), and PrintHypothesis().

std::vector<const FFState*> Moses::Hypothesis::m_ffStates [protected]

detailed score break-down by components (for instance language model, word penalty, etc)

Definition at line 82 of file Hypothesis.h.

Referenced by CalcScore(), Hypothesis(), RecombineCompare(), and ~Hypothesis().

score so far

Definition at line 80 of file Hypothesis.h.

Referenced by CalcExpectedScore(), CalcRemainingScore(), CalcScore(), GetScore(), PrintHypothesis(), and ResetScore().

int Moses::Hypothesis::m_id [protected]

Definition at line 88 of file Hypothesis.h.

Referenced by GetId(), and PrintHypothesis().

Definition at line 86 of file Hypothesis.h.

Referenced by CalcExpectedScore(), CalcRemainingScore(), CalcScore(), GetManager(), and Hypothesis().

Definition at line 68 of file Hypothesis.h.

Referenced by CalcScore(), GetPrevHypo(), PrintHypothesis(), and ToStream().

estimated future cost to translate rest of sentence

Definition at line 81 of file Hypothesis.h.

Referenced by CalcExpectedScore(), CalcRemainingScore(), CalcScore(), GetScoreBreakdown(), PrintHypothesis(), and ResetScore().

input sentence

Definition at line 72 of file Hypothesis.h.

Referenced by CalcExpectedScore(), CalcScore(), GetWordsBitmap(), Hypothesis(), IsSourceCompleted(), and RecombineCompare().

keeps track of which words have been translated so far

Definition at line 75 of file Hypothesis.h.

Referenced by GetInput().

target phrase being created at the current decoding step

Definition at line 71 of file Hypothesis.h.

Referenced by GetSourcePhrase(), and PrintHypothesis().

backpointer to previous hypothesis (from which this one was created)

Definition at line 70 of file Hypothesis.h.

Referenced by CalcScore(), GetCurrFactor(), GetCurrTargetPhrase(), GetCurrWord(), and PrintHypothesis().

all arcs that end at the same trellis point as this hypothesis

Definition at line 85 of file Hypothesis.h.

Referenced by CalcExpectedScore(), CalcScore(), and GetTranslationOption().

Definition at line 83 of file Hypothesis.h.

Referenced by GetWinningHypo(), and SetWinningHypo().

target word positions of the last phrase that was used to create this hypothesis

Definition at line 78 of file Hypothesis.h.

Referenced by Hypothesis(), and PrintHypothesis().

Definition at line 66 of file Hypothesis.h.

Referenced by Create(), and GetObjectPool().


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

Generated on Wed Feb 8 22:04:09 2012 for Moses by  doxygen 1.5.9