#include <ChartHypothesis.h>
Public Member Functions | |
ChartHypothesis (const ChartTranslationOptions &, const RuleCubeItem &item, ChartManager &manager) | |
ChartHypothesis (const ChartHypothesis &, const ChartKBestExtractor &) | |
only used by ChartKBestExtractor | |
~ChartHypothesis () | |
unsigned | GetId () const |
const ChartTranslationOption & | GetTranslationOption () const |
const TargetPhrase & | GetCurrTargetPhrase () const |
Get the rule that created this hypothesis. | |
const Range & | GetCurrSourceRange () const |
the source range that this hypothesis spans | |
const ChartArcList * | GetArcList () const |
the arc list when creating n-best lists | |
const FFState * | GetFFState (size_t featureID) const |
the feature function states for a particular feature | |
const ChartManager & | GetManager () const |
reference back to the manager | |
void | GetOutputPhrase (Phrase &outPhrase) const |
Phrase | GetOutputPhrase () const |
void | GetOutputPhrase (size_t leftRightMost, size_t numWords, Phrase &outPhrase) const |
void | EvaluateWhenApplied () |
void | AddArc (ChartHypothesis *loserHypo) |
void | CleanupArcList () |
void | SetWinningHypo (const ChartHypothesis *hypo) |
const ScoreComponentCollection & | GetScoreBreakdown () const |
get the unweighted score for each feature function | |
const ScoreComponentCollection & | GetDeltaScoreBreakdown () const |
get the unweighted score delta for each feature function | |
float | GetFutureScore () const |
Get the weighted total score. | |
const std::vector< const ChartHypothesis * > & | GetPrevHypos () const |
vector of previous hypotheses this hypo is built on | |
const ChartHypothesis * | GetPrevHypo (size_t pos) const |
get a particular previous hypos | |
const Word & | GetTargetLHS () const |
get the constituency label that covers this hypo | |
const ChartHypothesis * | GetWinningHypothesis () const |
get the best hypo in the arc list when doing n-best list creation. It's either this hypothesis, or the best hypo is this hypo is in the arc list | |
size_t | hash () const |
bool | operator== (const ChartHypothesis &other) const |
TO_STRING () | |
Protected Member Functions | |
ChartHypothesis () | |
not implemented | |
ChartHypothesis (const ChartHypothesis ©) | |
not implemented | |
Protected Attributes | |
boost::shared_ptr < ChartTranslationOption > | m_transOpt |
Range | m_currSourceWordsRange |
std::vector< const FFState * > | m_ffStates |
boost::scoped_ptr < ScoreComponentCollection > | m_scoreBreakdown |
boost::scoped_ptr < ScoreComponentCollection > | m_deltaScoreBreakdown |
ScoreComponentCollection | m_currScoreBreakdown |
ScoreComponentCollection | m_lmNGram |
ScoreComponentCollection | m_lmPrefix |
float | m_totalScore |
ChartArcList * | m_arcList |
const ChartHypothesis * | m_winningHypo |
std::vector< const ChartHypothesis * > | m_prevHypos |
ChartManager & | m_manager |
unsigned | m_id |
Friends | |
std::ostream & | operator<< (std::ostream &, const ChartHypothesis &) |
Definition at line 46 of file ChartHypothesis.h.
Moses::ChartHypothesis::ChartHypothesis | ( | ) | [protected] |
not implemented
Moses::ChartHypothesis::ChartHypothesis | ( | const ChartHypothesis & | copy | ) | [protected] |
not implemented
Moses::ChartHypothesis::ChartHypothesis | ( | const ChartTranslationOptions & | transOpt, | |
const RuleCubeItem & | item, | |||
ChartManager & | manager | |||
) |
Create a hypothesis from a rule
transOpt | wrapper around the rule | |
item |
manager | reference back to manager |
Definition at line 45 of file ChartHypothesis.cpp.
References Moses::RuleCubeItem::GetHypothesisDimensions(), and m_prevHypos.
Moses::ChartHypothesis::ChartHypothesis | ( | const ChartHypothesis & | pred, | |
const ChartKBestExtractor & | ||||
) |
only used by ChartKBestExtractor
Definition at line 67 of file ChartHypothesis.cpp.
References m_prevHypos.
Moses::ChartHypothesis::~ChartHypothesis | ( | ) |
void Moses::ChartHypothesis::AddArc | ( | ChartHypothesis * | loserHypo | ) |
Definition at line 214 of file ChartHypothesis.cpp.
References m_arcList.
Referenced by Moses::ChartHypothesisCollection::AddHypothesis().
void Moses::ChartHypothesis::CleanupArcList | ( | ) |
Definition at line 248 of file ChartHypothesis.cpp.
References Moses::MBR_Options::enabled, Moses::StaticData::Instance(), m_arcList, m_winningHypo, Moses::AllOptions::mbr, Moses::AllOptions::nbest, Moses::NBestOptions::nbest_size, Moses::ReportingOptions::NeedSearchGraph(), NTH_ELEMENT4, Moses::NBestOptions::only_distinct, Moses::StaticData::options(), Moses::AllOptions::output, Moses::ReportingOptions::SearchGraphHG, and SetWinningHypo().
Referenced by Moses::ChartHypothesisCollection::CleanupArcList().
void Moses::ChartHypothesis::EvaluateWhenApplied | ( | ) |
calculate total score
Definition at line 181 of file ChartHypothesis.cpp.
References GetFutureScore(), Moses::ChartTranslationOption::GetScores(), Moses::StatefulFeatureFunction::GetStatefulFeatureFunctions(), Moses::StatelessFeatureFunction::GetStatelessFeatureFunctions(), GetTranslationOption(), Moses::ScoreComponentCollection::GetWeightedScore(), Moses::StaticData::Instance(), Moses::StaticData::IsFeatureFunctionIgnored(), m_currScoreBreakdown, m_ffStates, m_prevHypos, and m_totalScore.
Referenced by Moses::ChartManager::AddXmlChartOptions(), and Moses::RuleCubeItem::CreateHypothesis().
const ChartArcList* Moses::ChartHypothesis::GetArcList | ( | ) | const [inline] |
the arc list when creating n-best lists
Definition at line 108 of file ChartHypothesis.h.
References m_arcList.
const Range& Moses::ChartHypothesis::GetCurrSourceRange | ( | ) | const [inline] |
the source range that this hypothesis spans
Definition at line 103 of file ChartHypothesis.h.
References m_currSourceWordsRange.
Referenced by Moses::SparseHieroReorderingFeature::EvaluateWhenApplied(), Moses::ConstrainedDecoding::EvaluateWhenApplied(), Moses::BleuScoreFeature::EvaluateWhenApplied(), Moses::LanguageModelChartState::hash(), Moses::LanguageModelChartState::operator==(), Moses::PhraseOrientationFeature::SparseWordL2RScore(), Moses::PhraseOrientationFeature::SparseWordR2LScore(), and Moses::TargetNgramChartState::TargetNgramChartState().
const TargetPhrase& Moses::ChartHypothesis::GetCurrTargetPhrase | ( | ) | const [inline] |
Get the rule that created this hypothesis.
Definition at line 98 of file ChartHypothesis.h.
References m_transOpt.
Referenced by Moses::RDLM::EvaluateWhenApplied(), Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), Moses::LanguageModelImplementation::EvaluateWhenApplied(), Moses::LanguageModelDALM::EvaluateWhenApplied(), Moses::BilingualLM::EvaluateWhenApplied(), Moses::TreeStructureFeature::EvaluateWhenApplied(), Moses::TargetPreferencesFeature::EvaluateWhenApplied(), Moses::TargetNgramFeature::EvaluateWhenApplied(), Moses::SparseHieroReorderingFeature::EvaluateWhenApplied(), Moses::SoftMatchingFeature::EvaluateWhenApplied(), Moses::PhraseOrientationFeature::EvaluateWhenApplied(), Moses::BleuScoreFeature::EvaluateWhenApplied(), Moses::ChartKBestExtractor::GetOutputPhrase(), GetOutputPhrase(), Moses::ChartKBestExtractor::GetOutputScoreBreakdown(), Moses::ChartKBestExtractor::GetOutputTree(), GetTargetLHS(), Moses::LanguageModelChartState::LanguageModelChartState(), Moses::PhraseOrientationFeature::SparseWordL2RScore(), Moses::PhraseOrientationFeature::SparseWordR2LScore(), and Moses::TargetNgramChartState::TargetNgramChartState().
const ScoreComponentCollection& Moses::ChartHypothesis::GetDeltaScoreBreakdown | ( | ) | const [inline] |
get the unweighted score delta for each feature function
Definition at line 155 of file ChartHypothesis.h.
References GetTranslationOption(), m_currScoreBreakdown, m_deltaScoreBreakdown, and m_transOpt.
Referenced by Moses::ChartKBestExtractor::GetOutputScoreBreakdown().
const FFState* Moses::ChartHypothesis::GetFFState | ( | size_t | featureID | ) | const [inline] |
the feature function states for a particular feature
featureID |
Definition at line 113 of file ChartHypothesis.h.
References m_ffStates.
Referenced by Moses::RDLM::EvaluateWhenApplied(), Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), Moses::LanguageModelImplementation::EvaluateWhenApplied(), Moses::LanguageModelDALM::EvaluateWhenApplied(), Moses::TreeStructureFeature::EvaluateWhenApplied(), Moses::TargetPreferencesFeature::EvaluateWhenApplied(), Moses::TargetNgramFeature::EvaluateWhenApplied(), Moses::PhraseOrientationFeature::EvaluateWhenApplied(), Moses::BleuScoreFeature::EvaluateWhenApplied(), and Moses::ChartManager::OutputDetailedTreeFragmentsTranslationReport().
float Moses::ChartHypothesis::GetFutureScore | ( | ) | const [inline] |
Get the weighted total score.
Definition at line 170 of file ChartHypothesis.h.
References m_totalScore.
Referenced by Moses::ChartHypothesisCollection::Add(), Moses::ChartHypothesisCollection::AddHypothesis(), Moses::RuleCubeItem::CreateHypothesis(), EvaluateWhenApplied(), Moses::ChartKBestExtractor::Extract(), Moses::ChartCell::GetBestHypothesis(), Moses::ChartHypothesisScoreOrderer::operator()(), Moses::CompareChartHypothesisTotalScore::operator()(), and Moses::ChartHypothesisCollection::PruneToSize().
unsigned Moses::ChartHypothesis::GetId | ( | ) | const [inline] |
Definition at line 89 of file ChartHypothesis.h.
References m_id.
Referenced by Moses::ChartHypothesisCollection::AddHypothesis(), Moses::operator<<(), and Moses::ChartHypothesisCollection::PruneToSize().
const ChartManager& Moses::ChartHypothesis::GetManager | ( | ) | const [inline] |
reference back to the manager
Definition at line 118 of file ChartHypothesis.h.
References m_manager.
Referenced by Moses::BilingualLM::EvaluateWhenApplied(), Moses::SparseHieroReorderingFeature::EvaluateWhenApplied(), Moses::ConstrainedDecoding::EvaluateWhenApplied(), Moses::LanguageModelChartState::hash(), Moses::LanguageModelChartState::operator==(), Moses::PhraseOrientationFeature::SparseWordL2RScore(), Moses::PhraseOrientationFeature::SparseWordR2LScore(), and Moses::TargetNgramChartState::TargetNgramChartState().
void Moses::ChartHypothesis::GetOutputPhrase | ( | size_t | leftRightMost, | |
size_t | numWords, | |||
Phrase & | outPhrase | |||
) | const |
TODO: this method isn't used anywhere. Remove?
Definition at line 148 of file ChartHypothesis.cpp.
References Moses::Phrase::AddWord(), Moses::TargetPhrase::GetAlignNonTerm(), GetCurrTargetPhrase(), Moses::AlignmentInfo::GetNonTermIndexMap(), GetOutputPhrase(), Moses::Phrase::GetSize(), Moses::Phrase::GetWord(), Moses::Word::IsNonTerminal(), and m_prevHypos.
Phrase Moses::ChartHypothesis::GetOutputPhrase | ( | ) | const |
Return full output phrase
Definition at line 140 of file ChartHypothesis.cpp.
References Moses::ARRAY_SIZE_INCR.
void Moses::ChartHypothesis::GetOutputPhrase | ( | Phrase & | outPhrase | ) | const |
Create full output phrase that is contained in the hypothesis (and its children)
outPhrase | full output phrase as return argument |
Definition at line 103 of file ChartHypothesis.cpp.
References Moses::Phrase::AddWord(), Moses::Phrase::Back(), Moses::AlignmentInfo::GetAlignmentsForTarget(), Moses::TargetPhrase::GetAlignNonTerm(), Moses::TargetPhrase::GetAlignTerm(), GetCurrTargetPhrase(), Moses::Word::GetFactor(), Moses::AlignmentInfo::GetNonTermIndexMap(), GetOutputPhrase(), Moses::Phrase::GetSize(), Moses::ChartTranslationOption::GetSourceRuleFromInputPath(), GetTranslationOption(), Moses::Phrase::GetWord(), Moses::StaticData::Instance(), Moses::Word::IsNonTerminal(), m_prevHypos, NOT_FOUND, NULL, Moses::StaticData::options(), and UTIL_THROW_IF2.
Referenced by Moses::ConstrainedDecodingState::ConstrainedDecodingState(), Moses::ControlRecombinationState::ControlRecombinationState(), Moses::BleuScoreFeature::EvaluateWhenApplied(), and GetOutputPhrase().
const ChartHypothesis* Moses::ChartHypothesis::GetPrevHypo | ( | size_t | pos | ) | const [inline] |
get a particular previous hypos
Definition at line 181 of file ChartHypothesis.h.
References m_prevHypos.
Referenced by Moses::RDLM::EvaluateWhenApplied(), Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), Moses::LanguageModelImplementation::EvaluateWhenApplied(), Moses::LanguageModelDALM::EvaluateWhenApplied(), Moses::BilingualLM::EvaluateWhenApplied(), Moses::TreeStructureFeature::EvaluateWhenApplied(), Moses::TargetPreferencesFeature::EvaluateWhenApplied(), Moses::TargetNgramFeature::EvaluateWhenApplied(), Moses::SparseHieroReorderingFeature::EvaluateWhenApplied(), Moses::SoftMatchingFeature::EvaluateWhenApplied(), Moses::PhraseOrientationFeature::EvaluateWhenApplied(), Moses::BleuScoreFeature::EvaluateWhenApplied(), Moses::PhraseOrientationFeature::SparseWordL2RScore(), and Moses::PhraseOrientationFeature::SparseWordR2LScore().
const std::vector<const ChartHypothesis*>& Moses::ChartHypothesis::GetPrevHypos | ( | ) | const [inline] |
vector of previous hypotheses this hypo is built on
Definition at line 176 of file ChartHypothesis.h.
References m_prevHypos.
Referenced by Moses::BilingualLM::EvaluateWhenApplied(), Moses::SparseHieroReorderingFeature::EvaluateWhenApplied(), Moses::BleuScoreFeature::EvaluateWhenApplied(), Moses::LanguageModelChartState::LanguageModelChartState(), and Moses::TargetNgramChartState::TargetNgramChartState().
const ScoreComponentCollection& Moses::ChartHypothesis::GetScoreBreakdown | ( | ) | const [inline] |
get the unweighted score for each feature function
Definition at line 136 of file ChartHypothesis.h.
References GetScoreBreakdown(), GetTranslationOption(), m_currScoreBreakdown, m_prevHypos, m_scoreBreakdown, and m_transOpt.
Referenced by Moses::BilingualLM::EvaluateWhenApplied(), and GetScoreBreakdown().
const Word& Moses::ChartHypothesis::GetTargetLHS | ( | ) | const [inline] |
get the constituency label that covers this hypo
Definition at line 186 of file ChartHypothesis.h.
References GetCurrTargetPhrase(), and Moses::TargetPhrase::GetTargetLHS().
Referenced by Moses::ChartCell::AddHypothesis(), and Moses::SoftMatchingFeature::EvaluateWhenApplied().
const ChartTranslationOption& Moses::ChartHypothesis::GetTranslationOption | ( | ) | const [inline] |
Definition at line 93 of file ChartHypothesis.h.
References m_transOpt.
Referenced by Moses::LanguageModelKen< Model >::EvaluateWhenApplied(), Moses::LanguageModelImplementation::EvaluateWhenApplied(), Moses::LanguageModelDALM::EvaluateWhenApplied(), EvaluateWhenApplied(), GetDeltaScoreBreakdown(), Moses::ChartKBestExtractor::GetOutputPhrase(), GetOutputPhrase(), and GetScoreBreakdown().
const ChartHypothesis* Moses::ChartHypothesis::GetWinningHypothesis | ( | ) | const [inline] |
get the best hypo in the arc list when doing n-best list creation. It's either this hypothesis, or the best hypo is this hypo is in the arc list
Definition at line 191 of file ChartHypothesis.h.
References m_winningHypo.
size_t Moses::ChartHypothesis::hash | ( | ) | const |
Definition at line 298 of file ChartHypothesis.cpp.
References Moses::FFState::hash(), m_ffStates, and state.
bool Moses::ChartHypothesis::operator== | ( | const ChartHypothesis & | other | ) | const |
void Moses::ChartHypothesis::SetWinningHypo | ( | const ChartHypothesis * | hypo | ) |
Definition at line 293 of file ChartHypothesis.cpp.
References m_winningHypo.
Referenced by CleanupArcList().
Moses::ChartHypothesis::TO_STRING | ( | ) |
std::ostream& operator<< | ( | std::ostream & | out, | |
const ChartHypothesis & | hypo | |||
) | [friend] |
Definition at line 328 of file ChartHypothesis.cpp.
ChartArcList* Moses::ChartHypothesis::m_arcList [protected] |
Definition at line 65 of file ChartHypothesis.h.
Referenced by AddArc(), CleanupArcList(), GetArcList(), and ~ChartHypothesis().
scores for this hypothesis only
Definition at line 61 of file ChartHypothesis.h.
Referenced by EvaluateWhenApplied(), GetDeltaScoreBreakdown(), and GetScoreBreakdown().
Range Moses::ChartHypothesis::m_currSourceWordsRange [protected] |
boost::scoped_ptr<ScoreComponentCollection> Moses::ChartHypothesis::m_deltaScoreBreakdown [mutable, protected] |
std::vector<const FFState*> Moses::ChartHypothesis::m_ffStates [protected] |
Definition at line 56 of file ChartHypothesis.h.
Referenced by EvaluateWhenApplied(), GetFFState(), hash(), operator==(), and ~ChartHypothesis().
unsigned Moses::ChartHypothesis::m_id [protected] |
Definition at line 61 of file ChartHypothesis.h.
Definition at line 61 of file ChartHypothesis.h.
ChartManager& Moses::ChartHypothesis::m_manager [protected] |
std::vector<const ChartHypothesis*> Moses::ChartHypothesis::m_prevHypos [protected] |
Definition at line 68 of file ChartHypothesis.h.
Referenced by ChartHypothesis(), EvaluateWhenApplied(), GetOutputPhrase(), GetPrevHypo(), GetPrevHypos(), and GetScoreBreakdown().
boost::scoped_ptr<ScoreComponentCollection> Moses::ChartHypothesis::m_scoreBreakdown [mutable, protected] |
stateful feature function states
sum of scores of this hypothesis, and previous hypotheses. Lazily initialised.
Definition at line 58 of file ChartHypothesis.h.
Referenced by GetScoreBreakdown().
float Moses::ChartHypothesis::m_totalScore [protected] |
Definition at line 63 of file ChartHypothesis.h.
Referenced by EvaluateWhenApplied(), and GetFutureScore().
boost::shared_ptr<ChartTranslationOption> Moses::ChartHypothesis::m_transOpt [protected] |
Definition at line 53 of file ChartHypothesis.h.
Referenced by GetCurrTargetPhrase(), GetDeltaScoreBreakdown(), GetScoreBreakdown(), and GetTranslationOption().
const ChartHypothesis* Moses::ChartHypothesis::m_winningHypo [protected] |
all arcs that end at the same trellis point as this hypothesis
Definition at line 66 of file ChartHypothesis.h.
Referenced by CleanupArcList(), GetWinningHypothesis(), and SetWinningHypo().