#include <SearchNormal.h>
Public Member Functions | |
SearchNormal (Manager &manager, const TranslationOptionCollection &transOptColl) | |
~SearchNormal () | |
void | Decode () |
void | OutputHypoStackSize () |
void | OutputHypoStack () |
virtual const std::vector < HypothesisStack * > & | GetHypothesisStacks () const |
virtual const Hypothesis * | GetBestHypothesis () const |
Protected Member Functions | |
virtual bool | ProcessOneStack (HypothesisStack *hstack) |
virtual void | ProcessOneHypothesis (const Hypothesis &hypothesis) |
virtual void | ExpandAllHypotheses (const Hypothesis &hypothesis, size_t startPos, size_t endPos) |
virtual void | ExpandHypothesis (const Hypothesis &hypothesis, const TranslationOption &transOpt, float expectedScore, float estimatedScore, const Bitmap &bitmap) |
Protected Attributes | |
std::vector< HypothesisStack * > | m_hypoStackColl |
stacks to store hypotheses (partial translations) | |
HypothesisStackNormal * | actual_hypoStack |
const TranslationOptionCollection & | m_transOptColl |
Definition at line 20 of file SearchNormal.h.
Moses::SearchNormal::SearchNormal | ( | Manager & | manager, | |
const TranslationOptionCollection & | transOptColl | |||
) |
Organizing main function
/param source input sentence /param transOptColl collection of translation options to be used for this sentence
Definition at line 19 of file SearchNormal.cpp.
References Moses::SearchOptions::beam_width, m_hypoStackColl, Moses::Search::m_manager, Moses::Search::m_options, Moses::Search::m_source, Moses::AllOptions::search, Moses::HypothesisStackNormal::SetBeamWidth(), Moses::HypothesisStackNormal::SetMaxHypoStackSize(), Moses::SearchOptions::stack_size, and VERBOSE.
Moses::SearchNormal::~SearchNormal | ( | ) |
Definition at line 37 of file SearchNormal.cpp.
References m_hypoStackColl, and Moses::RemoveAllInColl().
void Moses::SearchNormal::Decode | ( | ) | [virtual] |
Main decoder loop that translates a sentence by expanding hypotheses stack by stack, until the end of the sentence.
Implements Moses::Search.
Definition at line 73 of file SearchNormal.cpp.
References actual_hypoStack, Moses::Bitmaps::GetInitialBitmap(), Moses::Manager::GetNextHypoId(), IFVERBOSE, Moses::Search::m_bitmaps, m_hypoStackColl, Moses::Search::m_initialTransOpt, Moses::Search::m_manager, Moses::Search::m_source, OutputHypoStackSize(), and ProcessOneStack().
void Moses::SearchNormal::ExpandAllHypotheses | ( | const Hypothesis & | hypothesis, | |
size_t | startPos, | |||
size_t | endPos | |||
) | [protected, virtual] |
Expand a hypothesis given a list of translation options
hypothesis | hypothesis to be expanded upon | |
startPos | first word position of span covered | |
endPos | last word position of span covered |
Definition at line 234 of file SearchNormal.cpp.
References Moses::TranslationOptionList::begin(), Moses::SquareMatrix::CalcEstimatedScore(), Moses::TranslationOptionList::end(), ExpandHypothesis(), Moses::Bitmaps::GetBitmap(), Moses::Hypothesis::GetCurrSourceWordsRange(), Moses::TranslationOptionCollection::GetEstimatedScores(), Moses::Hypothesis::GetScore(), Moses::TranslationOption::GetSourceWordsRange(), Moses::TranslationOptionCollection::GetTranslationOptionList(), Moses::Hypothesis::GetWordsBitmap(), Moses::Search::m_bitmaps, Moses::Search::m_options, m_transOptColl, Moses::AllOptions::search, Moses::TranslationOptionList::size(), and Moses::SearchOptions::UseEarlyDiscarding().
Referenced by ProcessOneHypothesis().
void Moses::SearchNormal::ExpandHypothesis | ( | const Hypothesis & | hypothesis, | |
const TranslationOption & | transOpt, | |||
float | expectedScore, | |||
float | estimatedScore, | |||
const Bitmap & | bitmap | |||
) | [protected, virtual] |
Expand one hypothesis with a translation option. this involves initial creation, scoring and adding it to the proper stack
hypothesis | hypothesis to be expanded upon | |
transOpt | translation option (phrase translation) that is applied to create the new hypothesis | |
expectedScore | base score for early discarding (base hypothesis score plus future score estimation) |
Definition at line 281 of file SearchNormal.cpp.
References Moses::SentenceStats::AddEarlyDiscarded(), Moses::SentenceStats::AddNotBuilt(), Moses::SearchOptions::early_discarding_threshold, Moses::Hypothesis::EvaluateWhenApplied(), Moses::TranslationOption::GetEndPos(), Moses::TranslationOption::GetFutureScore(), Moses::Bitmap::GetIDPlus(), Moses::Manager::GetNextHypoId(), Moses::Bitmap::GetNumWordsCovered(), Moses::Manager::GetSentenceStats(), Moses::TranslationOption::GetSize(), Moses::TranslationOption::GetStartPos(), Moses::Hypothesis::GetWordsBitmap(), IFVERBOSE, m_hypoStackColl, Moses::Search::m_manager, Moses::Search::m_options, NULL, Moses::Hypothesis::PrintHypothesis(), Moses::AllOptions::search, Moses::SearchOptions::stack_diversity, Moses::SentenceStats::StartTimeBuildHyp(), Moses::SentenceStats::StartTimeEstimateScore(), Moses::SentenceStats::StartTimeOtherScore(), Moses::SentenceStats::StartTimeStack(), Moses::stats, Moses::SentenceStats::StopTimeBuildHyp(), Moses::SentenceStats::StopTimeEstimateScore(), Moses::SentenceStats::StopTimeOtherScore(), Moses::SentenceStats::StopTimeStack(), and Moses::SearchOptions::UseEarlyDiscarding().
Referenced by ExpandAllHypotheses().
const Hypothesis * Moses::SearchNormal::GetBestHypothesis | ( | ) | const [virtual] |
Find best hypothesis on the last stack. This is the end point of the best translation, which can be traced back from here
Implements Moses::Search.
Definition at line 388 of file SearchNormal.cpp.
References actual_hypoStack, Moses::HypothesisStackNormal::GetBestHypothesis(), Moses::Search::interrupted_flag, and m_hypoStackColl.
const std::vector< HypothesisStack * > & Moses::SearchNormal::GetHypothesisStacks | ( | ) | const [virtual] |
Implements Moses::Search.
Definition at line 379 of file SearchNormal.cpp.
References m_hypoStackColl.
void Moses::SearchNormal::OutputHypoStack | ( | ) |
void Moses::SearchNormal::OutputHypoStackSize | ( | ) |
Logging of hypothesis stack sizes
Definition at line 402 of file SearchNormal.cpp.
References m_hypoStackColl, and TRACE_ERR.
Referenced by Decode().
void Moses::SearchNormal::ProcessOneHypothesis | ( | const Hypothesis & | hypothesis | ) | [protected, virtual] |
Find all translation options to expand one hypothesis, trigger expansion this is mostly a check for overlap with already covered words, and for violation of reordering limits.
hypothesis | hypothesis to be expanded upon |
Definition at line 97 of file SearchNormal.cpp.
References Moses::InputType::CanIGetFromAToB(), Moses::ReorderingConstraint::Check(), Moses::InputType::ComputeDistortionDistance(), ExpandAllHypotheses(), Moses::Hypothesis::GetCurrSourceWordsRange(), Moses::Bitmap::GetEdgeToTheLeftOf(), Moses::Bitmap::GetEdgeToTheRightOf(), Moses::Bitmap::GetFirstGapPos(), Moses::InputType::GetReorderingConstraint(), Moses::InputType::GetSize(), Moses::Range::GetStartPos(), Moses::TranslationOptionCollection::GetTranslationOptionList(), Moses::InputType::GetType(), Moses::Bitmap::GetValue(), Moses::Hypothesis::GetWordsBitmap(), Moses::InputType::IsCoveragePossible(), Moses::Search::m_options, Moses::Search::m_source, m_transOptColl, Moses::ReorderingOptions::max_distortion, Moses::SearchOptions::max_phrase_length, NOT_FOUND, Moses::Bitmap::Overlap(), Moses::AllOptions::reordering, Moses::AllOptions::search, Moses::TranslationOptionList::size(), and Moses::WordLatticeInput.
Referenced by ProcessOneStack().
bool Moses::SearchNormal::ProcessOneStack | ( | HypothesisStack * | hstack | ) | [protected, virtual] |
Definition at line 45 of file SearchNormal.cpp.
References Moses::HypothesisStack::begin(), Moses::HypothesisStackNormal::CleanupArcList(), Moses::HypothesisStack::end(), Moses::Manager::GetSentenceStats(), IFVERBOSE, Moses::Search::m_manager, Moses::Search::m_options, Moses::Search::out_of_time(), ProcessOneHypothesis(), Moses::HypothesisStackNormal::PruneToSize(), Moses::AllOptions::search, Moses::SearchOptions::stack_size, Moses::SentenceStats::StartTimeStack(), Moses::stats, Moses::SentenceStats::StopTimeStack(), and VERBOSE.
Referenced by Decode().
actual (full expanded) stack of hypotheses
Definition at line 28 of file SearchNormal.h.
Referenced by Decode(), and GetBestHypothesis().
std::vector< HypothesisStack* > Moses::SearchNormal::m_hypoStackColl [protected] |
stacks to store hypotheses (partial translations)
Definition at line 25 of file SearchNormal.h.
Referenced by Decode(), ExpandHypothesis(), GetBestHypothesis(), GetHypothesisStacks(), OutputHypoStack(), OutputHypoStackSize(), SearchNormal(), and ~SearchNormal().
const TranslationOptionCollection& Moses::SearchNormal::m_transOptColl [protected] |
pre-computed list of translation options for the phrases in this sentence
Definition at line 31 of file SearchNormal.h.
Referenced by ExpandAllHypotheses(), and ProcessOneHypothesis().