Moses::Hypothesis Class Reference

#include <Hypothesis.h>

Collaboration diagram for Moses::Hypothesis:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Hypothesis (Manager &manager, InputType const &source, const TranslationOption &initialTransOpt, const Bitmap &bitmap, int id)
 Hypothesis (const Hypothesis &prevHypo, const TranslationOption &transOpt, const Bitmap &bitmap, int id)
 ~Hypothesis ()
void PrintHypothesis () const
const InputTypeGetInput () const
const TargetPhraseGetCurrTargetPhrase () const
const RangeGetCurrSourceWordsRange () const
const RangeGetCurrTargetWordsRange () const
ManagerGetManager () const
size_t GetCurrTargetLength () const
void EvaluateWhenApplied (float estimatedScore)
int GetId () const
const HypothesisGetPrevHypo () const
size_t GetSize () 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 BitmapGetWordsBitmap () const
bool IsSourceCompleted () const
void GetOutputPhrase (Phrase &out) const
void ToStream (std::ostream &out) const
void ToStringStream (std::stringstream &out) const
std::string GetOutputString () const
 TO_STRING ()
void SetWinningHypo (const Hypothesis *hypo)
const HypothesisGetWinningHypo () const
void AddArc (Hypothesis *loserHypo)
void CleanupArcList (size_t nBestSize, bool distinctNBest)
const ArcListGetArcList () const
 returns a list alternative previous hypotheses (or NULL if n-best support is disabled)
const ScoreComponentCollectionGetScoreBreakdown () const
float GetFutureScore () const
float GetScore () const
const FFStateGetFFState (int idx) const
void SetFFState (int idx, FFState *state)
std::vector< std::vector
< unsigned int > > * 
GetLMStats () const
const TranslationOptionGetTranslationOption () const
size_t OutputAlignment (std::ostream &out, bool recursive) const
void OutputInput (std::ostream &os) const
std::map< size_t, const
Moses::Factor * > 
GetPlaceholders (const Moses::Hypothesis &hypo, Moses::FactorType placeholderFactor) const
size_t hash () const
bool operator== (const Hypothesis &other) const
bool beats (Hypothesis const &b) const

Static Public Member Functions

static void OutputInput (std::vector< const Phrase * > &map, const Hypothesis *hypo)

Protected Attributes

const Hypothesism_prevHypo
const Bitmapm_sourceCompleted
InputType const & m_sourceInput
Range m_currSourceWordsRange
Range m_currTargetWordsRange
bool m_wordDeleted
float m_futureScore
float m_estimatedScore
boost::scoped_ptr
< ScoreComponentCollection
m_scoreBreakdown
ScoreComponentCollection m_currScoreBreakdown
std::vector< const FFState * > m_ffStates
const Hypothesism_winningHypo
ArcListm_arcList
const TranslationOptionm_transOpt
Managerm_manager
int m_id

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 65 of file Hypothesis.h.


Constructor & Destructor Documentation

Moses::Hypothesis::Hypothesis ( Manager manager,
InputType const &  source,
const TranslationOption initialTransOpt,
const Bitmap bitmap,
int  id 
)

numeric ID of this hypothesis, used for logging

used by initial seeding of the translation process

Definition at line 49 of file Hypothesis.cpp.

References Moses::StatefulFeatureFunction::GetStatefulFeatureFunctions(), and m_ffStates.

Here is the call graph for this function:

Moses::Hypothesis::Hypothesis ( const Hypothesis prevHypo,
const TranslationOption transOpt,
const Bitmap bitmap,
int  id 
)

used when creating a new hypothesis using a translation option (phrase translation)

Definition at line 80 of file Hypothesis.cpp.

References Moses::TranslationOption::GetScoreBreakdown(), Moses::TranslationOption::IsDeletionOption(), m_currScoreBreakdown, m_wordDeleted, and Moses::ScoreComponentCollection::PlusEquals().

Here is the call graph for this function:

Moses::Hypothesis::~Hypothesis (  ) 

Definition at line 104 of file Hypothesis.cpp.

References m_arcList, m_ffStates, and NULL.


Member Function Documentation

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

Definition at line 123 of file Hypothesis.cpp.

References m_arcList.

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

Here is the caller graph for this function:

bool Moses::Hypothesis::beats ( Hypothesis const &  b  )  const

Definition at line 444 of file Hypothesis.cpp.

References beats(), m_estimatedScore, m_futureScore, and m_prevHypo.

Referenced by beats(), and Moses::CompareHypothesisTotalScore::operator()().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::CleanupArcList ( size_t  nBestSize,
bool  distinctNBest 
)

Definition at line 237 of file Hypothesis.cpp.

References m_arcList, NTH_ELEMENT4, and SetWinningHypo().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::EvaluateWhenApplied ( float  estimatedScore  ) 

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

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

Definition at line 208 of file Hypothesis.h.

References m_arcList.

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

Here is the caller graph for this function:

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

Definition at line 147 of file Hypothesis.h.

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

Here is the call graph for this function:

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

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

TargetPhrase const & Moses::Hypothesis::GetCurrTargetPhrase (  )  const

return target phrase used to create this hypothesis

Definition at line 270 of file Hypothesis.cpp.

References Moses::TranslationOption::GetTargetPhrase(), and m_transOpt.

Referenced by Moses::Manager::CalcDecoderStatistics(), Moses::BitmapContainer::Enqueue(), Moses::BackwardLanguageModel< Model >::Evaluate(), Moses::BilingualLM::EvaluateWhenApplied(), Moses::TargetNgramFeature::EvaluateWhenApplied(), Moses::TargetConstituentAdjacencyFeature::EvaluateWhenApplied(), Moses::TargetBigramFeature::EvaluateWhenApplied(), Moses::PhraseBoundaryFeature::EvaluateWhenApplied(), Moses::OpSequenceModel::EvaluateWhenApplied(), Moses::GlobalLexicalModelUnlimited::EvaluateWhenApplied(), Moses::DesegModel::EvaluateWhenApplied(), Moses::DistortionScoreProducer::EvaluateWhenApplied(), Moses::CoveredReferenceFeature::EvaluateWhenApplied(), Moses::BleuScoreFeature::EvaluateWhenApplied(), GetCurrFactor(), GetCurrWord(), GetOutputFactors(), GetOutputPhrase(), Moses::GetOutputWords(), Moses::TrellisPath::GetTargetPhrase(), Moses::LatticeMBRSolution::LatticeMBRSolution(), Moses::HypothesisScoreOrderer::operator()(), Moses::HypothesisScoreOrdererWithDistortion::operator()(), Moses::Manager::OutputAlignment(), OutputAlignment(), Moses::Manager::OutputNBest(), Moses::Manager::OutputSearchGraphAsHypergraph(), Moses::Manager::OutputSearchGraphAsSLF(), Moses::OutputSearchNode(), Moses::Manager::OutputSurface(), Moses::Manager::OutputWordGraph(), PrintHypothesis(), Moses::pruneLatticeFB(), ToStringStream(), and Moses::VWState::VWState().

Here is the call graph for this function:

Here is the caller graph for this function:

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

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 144 of file Hypothesis.h.

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

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 159 of file Hypothesis.h.

References GetWord().

Here is the call graph for this function:

const FFState* Moses::Hypothesis::GetFFState ( int  idx  )  const [inline]

Definition at line 227 of file Hypothesis.h.

References m_ffStates.

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

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

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

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

Definition at line 234 of file Hypothesis.h.

References NULL.

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

void Moses::Hypothesis::GetOutputPhrase ( Phrase out  )  const

std::string Moses::Hypothesis::GetOutputString (  )  const [inline]

Definition at line 189 of file Hypothesis.h.

References ToStringStream().

Here is the call graph for this function:

std::map< size_t, const Factor * > Moses::Hypothesis::GetPlaceholders ( const Moses::Hypothesis hypo,
Moses::FactorType  placeholderFactor 
) const

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

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

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

Definition at line 211 of file Hypothesis.h.

References GetScoreBreakdown(), m_currScoreBreakdown, m_prevHypo, and m_scoreBreakdown.

Referenced by Moses::TrellisPath::GetScoreBreakdown(), GetScoreBreakdown(), Moses::OutputSearchNode(), Moses::Manager::OutputSurface(), and Moses::Manager::OutputWordGraph().

Here is the call graph for this function:

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 132 of file Hypothesis.h.

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

Referenced by Moses::LanguageModelImplementation::EvaluateWhenApplied(), Moses::TargetNgramFeature::EvaluateWhenApplied(), Moses::GlobalLexicalModelUnlimited::EvaluateWhenApplied(), and Moses::pruneLatticeFB().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 322 of file Hypothesis.cpp.

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

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

Here is the caller graph for this function:

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

Definition at line 332 of file Hypothesis.cpp.

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

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

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

Definition at line 200 of file Hypothesis.h.

References m_winningHypo.

Referenced by Moses::TrellisPath::GetScoreBreakdown(), and Moses::TrellisPath::InitTotalScore().

Here is the caller graph for this function:

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

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

size_t Moses::Hypothesis::hash (  )  const

Definition at line 401 of file Hypothesis.cpp.

References Moses::FFState::hash(), Moses::Bitmap::hash(), m_ffStates, m_sourceCompleted, and state.

Here is the call graph for this function:

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

bool Moses::Hypothesis::operator== ( const Hypothesis other  )  const

Definition at line 424 of file Hypothesis.cpp.

References m_ffStates, and m_sourceCompleted.

size_t Moses::Hypothesis::OutputAlignment ( std::ostream &  out,
bool  recursive = true 
) const

void Moses::Hypothesis::OutputInput ( std::vector< const Phrase * > &  map,
const Hypothesis hypo 
) [static]

void Moses::Hypothesis::OutputInput ( std::ostream &  os  )  const

Definition at line 370 of file Hypothesis.cpp.

References GetInput(), and Moses::InputType::GetSize().

Referenced by Moses::Manager::OutputBest(), and OutputInput().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::PrintHypothesis (  )  const

void Moses::Hypothesis::SetFFState ( int  idx,
FFState state 
) [inline]

Definition at line 230 of file Hypothesis.h.

References m_ffStates.

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

Definition at line 197 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 176 of file Hypothesis.h.

References GetOutputPhrase().

Referenced by ToStringStream().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Hypothesis::ToStringStream ( std::stringstream &  out  )  const [inline]

Definition at line 182 of file Hypothesis.h.

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

Referenced by GetOutputString().

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 82 of file Hypothesis.h.

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

Definition at line 79 of file Hypothesis.h.

Referenced by EvaluateWhenApplied(), GetScoreBreakdown(), Hypothesis(), and PrintHypothesis().

Definition at line 72 of file Hypothesis.h.

Referenced by GetCurrSourceWordsRange(), and PrintHypothesis().

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

Definition at line 73 of file Hypothesis.h.

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

score so far

Definition at line 76 of file Hypothesis.h.

Referenced by beats(), EvaluateWhenApplied(), GetScore(), and PrintHypothesis().

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

scores for this hypothesis only

Definition at line 80 of file Hypothesis.h.

Referenced by EvaluateWhenApplied(), GetFFState(), hash(), Hypothesis(), operator==(), SetFFState(), and ~Hypothesis().

Definition at line 75 of file Hypothesis.h.

Referenced by beats(), EvaluateWhenApplied(), GetFutureScore(), GetScore(), and PrintHypothesis().

int Moses::Hypothesis::m_id [protected]

Definition at line 86 of file Hypothesis.h.

Referenced by GetId(), and PrintHypothesis().

Definition at line 84 of file Hypothesis.h.

Referenced by GetManager(), and OutputAlignment().

boost::scoped_ptr<ScoreComponentCollection> Moses::Hypothesis::m_scoreBreakdown [mutable, protected]

estimated future cost to translate rest of sentence

sum of scores of this hypothesis, and previous hypotheses. Lazily initialised.

Definition at line 78 of file Hypothesis.h.

Referenced by GetScoreBreakdown().

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

Definition at line 70 of file Hypothesis.h.

Referenced by GetWordsBitmap(), hash(), IsSourceCompleted(), and operator==().

keeps track of which words have been translated so far

Definition at line 71 of file Hypothesis.h.

Referenced by GetInput().

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

Definition at line 83 of file Hypothesis.h.

Referenced by GetCurrTargetPhrase(), GetTranslationOption(), and PrintHypothesis().

Definition at line 81 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 74 of file Hypothesis.h.

Referenced by Hypothesis(), and PrintHypothesis().


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

Generated on Thu Jul 6 00:33:17 2017 for Moses by  doxygen 1.5.9