#include <TranslationOption.h>
Classes | |
struct | Better |
Public Member Functions | |
TranslationOption () | |
TranslationOption (const Range &range, const TargetPhrase &targetPhrase) | |
bool | IsCompatible (const Phrase &phrase, const std::vector< FactorType > &featuresToCheck) const |
const TargetPhrase & | GetTargetPhrase () const |
const Range & | GetSourceWordsRange () const |
const InputPath & | GetInputPath () const |
void | SetInputPath (const InputPath &inputPath) |
bool | Overlap (const Hypothesis &hypothesis) const |
size_t | GetStartPos () const |
size_t | GetEndPos () const |
size_t | GetSize () const |
float | GetFutureScore () const |
bool | IsDeletionOption () const |
const ScoreComponentCollection & | GetScoreBreakdown () const |
ScoreComponentCollection & | GetScoreBreakdown () |
void | EvaluateWithSourceContext (const InputType &input) |
void | UpdateScore (ScoreComponentCollection *futureScoreBreakdown=NULL) |
const Scores * | GetLexReorderingScores (const LexicalReordering *scoreProducer) const |
void | CacheLexReorderingScores (const LexicalReordering &scoreProducer, const Scores &score) |
TO_STRING () | |
bool | operator== (const TranslationOption &rhs) const |
Protected Attributes | |
TargetPhrase | m_targetPhrase |
const InputPath * | m_inputPath |
const Range | m_sourceWordsRange |
float | m_futureScore |
Friends | |
std::ostream & | operator<< (std::ostream &out, const TranslationOption &possibleTranslation) |
A translation option contains source and target phrase, aggregate and details scores (in m_scoreBreakdown), including an estimate how expensive this option will be in search (used to build the future cost matrix.)
m_targetPhrase points to a phrase-table entry. The source word range is zero-indexed, so it can't refer to an empty range. The target phrase may be empty.
Definition at line 62 of file TranslationOption.h.
Moses::TranslationOption::TranslationOption | ( | ) | [explicit] |
Definition at line 35 of file TranslationOption.cpp.
Moses::TranslationOption::TranslationOption | ( | const Range & | range, | |
const TargetPhrase & | targetPhrase | |||
) |
constructor. Used by initial translation step
Definition at line 42 of file TranslationOption.cpp.
void Moses::TranslationOption::CacheLexReorderingScores | ( | const LexicalReordering & | scoreProducer, | |
const Scores & | score | |||
) |
Definition at line 71 of file TranslationOption.cpp.
References m_targetPhrase, and Moses::TargetPhrase::SetExtraScores().
Referenced by Moses::LexicalReordering::SetCache().
void Moses::TranslationOption::EvaluateWithSourceContext | ( | const InputType & | input | ) |
Definition at line 79 of file TranslationOption.cpp.
References Moses::TargetPhrase::EvaluateWithSourceContext(), GetInputPath(), and m_targetPhrase.
Referenced by Moses::TranslationOptionCollectionLattice::CreateTranslationOptions().
size_t Moses::TranslationOption::GetEndPos | ( | ) | const [inline] |
return end index of source phrase
Definition at line 124 of file TranslationOption.h.
References Moses::Range::GetEndPos(), and m_sourceWordsRange.
Referenced by Moses::VW::EvaluateWhenApplied(), Moses::SearchNormal::ExpandHypothesis(), Moses::hash_value(), and Moses::VWState::VWState().
float Moses::TranslationOption::GetFutureScore | ( | ) | const [inline] |
return estimate of total cost of this option
Definition at line 134 of file TranslationOption.h.
References m_futureScore.
Referenced by Moses::PartialTranslOptColl::AddNoPrune(), Moses::BackwardsEdge::BackwardsEdge(), Moses::TranslationOptionCollection::CalcEstimatedScore(), Moses::ComparePartialTranslationOption(), Moses::SearchNormal::ExpandHypothesis(), Moses::TranslationOption::Better::operator()(), Moses::operator<<(), and Moses::TranslationOptionList::PruneByThreshold().
const InputPath & Moses::TranslationOption::GetInputPath | ( | ) | const |
returns source phrase
Definition at line 85 of file TranslationOption.cpp.
References m_inputPath, NULL, and UTIL_THROW_IF2.
Referenced by Moses::SentenceStats::AddDeletedWords(), Moses::SparseReordering::CopyScores(), Moses::PhraseBoundaryFeature::EvaluateWhenApplied(), EvaluateWithSourceContext(), Moses::Manager::GetPlaceholders(), Moses::Hypothesis::GetPlaceholders(), Moses::Manager::OutputInput(), Moses::Hypothesis::OutputInput(), Moses::Hypothesis::PrintHypothesis(), Moses::DecodeStepTranslation::Process(), Moses::DecodeStepGeneration::Process(), Moses::DecodeStepTranslation::ProcessLEGACY(), and Moses::LexicalReordering::SetCache().
const Scores * Moses::TranslationOption::GetLexReorderingScores | ( | const LexicalReordering * | scoreProducer | ) | const |
returns cached scores
Definition at line 115 of file TranslationOption.cpp.
References Moses::TargetPhrase::GetExtraScores(), and m_targetPhrase.
Referenced by Moses::LRState::ComparePrevScores(), Moses::LRState::CopyScores(), and Moses::LexicalReordering::SetCache().
ScoreComponentCollection& Moses::TranslationOption::GetScoreBreakdown | ( | ) | [inline] |
Definition at line 148 of file TranslationOption.h.
References Moses::TargetPhrase::GetScoreBreakdown(), and m_targetPhrase.
const ScoreComponentCollection& Moses::TranslationOption::GetScoreBreakdown | ( | ) | const [inline] |
returns detailed component scores
Definition at line 144 of file TranslationOption.h.
References Moses::TargetPhrase::GetScoreBreakdown(), and m_targetPhrase.
Referenced by Moses::VW::EvaluateTranslationOptionListWithSourceContext(), Moses::ExampleTranslationOptionListFeature::EvaluateTranslationOptionListWithSourceContext(), Moses::Hypothesis::Hypothesis(), Moses::operator<<(), and Moses::TranslationOptionCollection::SetInputScore().
size_t Moses::TranslationOption::GetSize | ( | ) | const [inline] |
return length of source phrase
Definition at line 129 of file TranslationOption.h.
References Moses::Range::GetEndPos(), Moses::Range::GetStartPos(), and m_sourceWordsRange.
Referenced by Moses::SearchNormal::ExpandHypothesis().
const Range& Moses::TranslationOption::GetSourceWordsRange | ( | ) | const [inline] |
returns source word range
Definition at line 106 of file TranslationOption.h.
References m_sourceWordsRange.
Referenced by Moses::TranslationOptionCollection::Add(), Moses::BackwardsEdge::BackwardsEdge(), Moses::SparseReordering::CopyScores(), Moses::VW::EvaluateTranslationOptionListWithSourceContext(), Moses::PhraseBasedReorderingState::Expand(), Moses::HReorderingForwardState::Expand(), Moses::HReorderingBackwardState::Expand(), Moses::SearchNormal::ExpandAllHypotheses(), Moses::BackwardsEdge::Initialize(), Moses::operator<<(), Overlap(), Moses::DecodeStepTranslation::Process(), Moses::DecodeStepGeneration::Process(), and Moses::DecodeStepTranslation::ProcessLEGACY().
size_t Moses::TranslationOption::GetStartPos | ( | ) | const [inline] |
return start index of source phrase
Definition at line 119 of file TranslationOption.h.
References Moses::Range::GetStartPos(), and m_sourceWordsRange.
Referenced by Moses::VW::EvaluateWhenApplied(), Moses::SearchNormal::ExpandHypothesis(), Moses::hash_value(), and Moses::VWState::VWState().
const TargetPhrase& Moses::TranslationOption::GetTargetPhrase | ( | ) | const [inline] |
returns target phrase
Definition at line 101 of file TranslationOption.h.
References m_targetPhrase.
Referenced by Moses::SparseReordering::CopyScores(), Moses::VW::EvaluateTranslationOptionListWithSourceContext(), Moses::VW::EvaluateWhenApplied(), Moses::Hypothesis::GetCurrTargetPhrase(), Moses::Manager::GetPlaceholders(), Moses::Hypothesis::GetPlaceholders(), Moses::hash_value(), Moses::operator<<(), Moses::DecodeStepTranslation::Process(), Moses::DecodeStepGeneration::Process(), Moses::DecodeStepTranslation::ProcessLEGACY(), Moses::LexicalReordering::SetCache(), and Moses::TranslationOptionCollectionText::ViolatesXmlOptionsConstraint().
bool Moses::TranslationOption::IsCompatible | ( | const Phrase & | phrase, | |
const std::vector< FactorType > & | featuresToCheck | |||
) | const |
returns true if all feature types in featuresToCheck are compatible between the two phrases
Definition at line 51 of file TranslationOption.cpp.
References Moses::Phrase::IsCompatible(), and m_targetPhrase.
Referenced by Moses::DecodeStepTranslation::Process(), Moses::DecodeStepGeneration::Process(), and Moses::DecodeStepTranslation::ProcessLEGACY().
bool Moses::TranslationOption::IsDeletionOption | ( | ) | const [inline] |
return true if the source phrase translates into nothing
Definition at line 139 of file TranslationOption.h.
References Moses::Phrase::GetSize(), and m_targetPhrase.
Referenced by Moses::Hypothesis::Hypothesis().
bool Moses::TranslationOption::operator== | ( | const TranslationOption & | rhs | ) | const [inline] |
Definition at line 171 of file TranslationOption.h.
References m_sourceWordsRange, and m_targetPhrase.
bool Moses::TranslationOption::Overlap | ( | const Hypothesis & | hypothesis | ) | const |
whether source span overlaps with those of a hypothesis
Definition at line 63 of file TranslationOption.cpp.
References GetSourceWordsRange(), Moses::Hypothesis::GetWordsBitmap(), and Moses::Bitmap::Overlap().
void Moses::TranslationOption::SetInputPath | ( | const InputPath & | inputPath | ) |
Definition at line 92 of file TranslationOption.cpp.
References m_inputPath, and UTIL_THROW_IF2.
Referenced by Moses::TranslationOptionCollectionLattice::CreateTranslationOptions(), Moses::TranslationOptionCollectionText::CreateXmlOptionsForRange(), Moses::DecodeStepTranslation::Process(), Moses::DecodeStepGeneration::Process(), Moses::DecodeStepTranslation::ProcessInitialTranslation(), Moses::DecodeStepTranslation::ProcessInitialTransLEGACY(), Moses::DecodeStepTranslation::ProcessLEGACY(), Moses::TranslationOptionCollection::ProcessOneUnknownWord(), and Moses::Search::Search().
Moses::TranslationOption::TO_STRING | ( | ) |
void Moses::TranslationOption::UpdateScore | ( | ScoreComponentCollection * | futureScoreBreakdown = NULL |
) | [inline] |
Definition at line 154 of file TranslationOption.h.
References m_targetPhrase, and Moses::TargetPhrase::UpdateScore().
Referenced by Moses::VW::EvaluateTranslationOptionListWithSourceContext(), and Moses::ExampleTranslationOptionListFeature::EvaluateTranslationOptionListWithSourceContext().
std::ostream& operator<< | ( | std::ostream & | out, | |
const TranslationOption & | possibleTranslation | |||
) | [friend] |
float Moses::TranslationOption::m_futureScore [protected] |
const InputPath* Moses::TranslationOption::m_inputPath [protected] |
Definition at line 69 of file TranslationOption.h.
Referenced by GetInputPath(), and SetInputPath().
const Range Moses::TranslationOption::m_sourceWordsRange [protected] |
Definition at line 70 of file TranslationOption.h.
Referenced by GetEndPos(), GetSize(), GetSourceWordsRange(), GetStartPos(), and operator==().
TargetPhrase Moses::TranslationOption::m_targetPhrase [protected] |
Definition at line 68 of file TranslationOption.h.
Referenced by CacheLexReorderingScores(), EvaluateWithSourceContext(), GetLexReorderingScores(), GetScoreBreakdown(), GetTargetPhrase(), IsCompatible(), IsDeletionOption(), operator==(), and UpdateScore().