Moses::Manager Class Reference

#include <Manager.h>

Inheritance diagram for Moses::Manager:

Inheritance graph
[legend]
Collaboration diagram for Moses::Manager:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 Manager (ttasksptr const &ttask)
 ~Manager ()
const TranslationOptionCollectiongetSntTranslationOptions ()
void Decode ()
const HypothesisGetBestHypothesis () const
const HypothesisGetActualBestHypothesis () const
void CalcNBest (size_t count, TrellisPathList &ret, bool onlyDistinct=0) const
void CalcLatticeSamples (size_t count, TrellisPathList &ret) const
void PrintAllDerivations (long translationId, std::ostream &outputStream) const
void printDivergentHypothesis (long translationId, const Hypothesis *hypo, const std::vector< const TargetPhrase * > &remainingPhrases, float remainingScore, std::ostream &outputStream) const
void printThisHypothesis (long translationId, const Hypothesis *hypo, const std::vector< const TargetPhrase * > &remainingPhrases, float remainingScore, std::ostream &outputStream) const
void GetOutputLanguageModelOrder (std::ostream &out, const Hypothesis *hypo) const
void GetWordGraph (long translationId, std::ostream &outputWordGraphStream) const
int GetNextHypoId ()
void OutputLatticeMBRNBest (std::ostream &out, const std::vector< LatticeMBRSolution > &solutions, long translationId) const
void OutputBestHypo (const std::vector< Moses::Word > &mbrBestHypo, long, char reportSegmentation, bool reportAllFactors, std::ostream &out) const
void OutputBestHypo (const Moses::TrellisPath &path, long, char reportSegmentation, bool reportAllFactors, std::ostream &out) const
void OutputSearchGraph (long translationId, std::ostream &outputSearchGraphStream) const
void OutputSearchGraphAsSLF (long translationId, std::ostream &outputSearchGraphStream) const
void OutputSearchGraphAsHypergraph (std::ostream &outputSearchGraphStream) const
void GetSearchGraph (std::vector< SearchGraphNode > &searchGraph) const
const InputTypeGetSource () const
 the input sentence being decoded
void CalcDecoderStatistics () const
void ResetSentenceStats (const InputType &source)
SentenceStatsGetSentenceStats () const
void GetForwardBackwardSearchGraph (std::map< int, bool > *pConnected, std::vector< const Hypothesis * > *pConnectedList, std::map< const Hypothesis *, std::set< const Hypothesis * > > *pOutgoingHyps, std::vector< float > *pFwdBwdScores) const
void OutputBest (OutputCollector *collector) const
void OutputNBest (OutputCollector *collector) const
void OutputAlignment (OutputCollector *collector) const
void OutputLatticeSamples (OutputCollector *collector) const
void OutputDetailedTranslationReport (OutputCollector *collector) const
void OutputUnknowns (OutputCollector *collector) const
void OutputDetailedTreeFragmentsTranslationReport (OutputCollector *collector) const
void OutputWordGraph (OutputCollector *collector) const
void OutputSearchGraph (OutputCollector *collector) const
void OutputSearchGraphSLF () const

Protected Member Functions

void GetConnectedGraph (std::map< int, bool > *pConnected, std::vector< const Hypothesis * > *pConnectedList) const
void GetWinnerConnectedGraph (std::map< int, bool > *pConnected, std::vector< const Hypothesis * > *pConnectedList) const
void OutputNBest (std::ostream &out, const Moses::TrellisPathList &nBestList, const std::vector< Moses::FactorType > &outputFactorOrder, long translationId, char reportSegmentation) const
void OutputSurface (std::ostream &out, const Hypothesis &edge, const std::vector< FactorType > &outputFactorOrder, char reportSegmentation, bool reportAllFactors) const
void OutputAlignment (std::ostream &out, const AlignmentInfo &ai, size_t sourceOffset, size_t targetOffset) const
void OutputInput (std::ostream &os, const Hypothesis *hypo) const
void OutputInput (std::vector< const Phrase * > &map, const Hypothesis *hypo) const
std::map< size_t, const Factor * > GetPlaceholders (const Hypothesis &hypo, FactorType placeholderFactor) const
void OutputAlignment (OutputCollector *collector, size_t lineNo, const std::vector< const Hypothesis * > &edges) const
void OutputAlignment (std::ostream &out, const std::vector< const Hypothesis * > &edges) const
void OutputWordGraph (std::ostream &outputWordGraphStream, const Hypothesis *hypo, size_t &linkId) const
void OutputAlignment (std::ostringstream &out, const TrellisPath &path) const

Protected Attributes

TranslationOptionCollectionm_transOptColl
Searchm_search
HypothesisStackactual_hypoStack
size_t interrupted_flag
std::auto_ptr< SentenceStatsm_sentenceStats
int m_hypoId
std::ostringstream m_latticeNBestOut
std::ostringstream m_alignmentOut


Detailed Description

The Manager class implements a stack decoding algorithm for phrase-based decoding Hypotheses are organized in stacks. One stack contains all hypothesis that have the same number of foreign words translated. The data structure for hypothesis stacks is the class HypothesisStack. The data structure for a hypothesis is the class Hypothesis.

The main decoder loop in the function ProcessSentence() consists of the steps:

Definition at line 96 of file Manager.h.


Constructor & Destructor Documentation

Moses::Manager::Manager ( ttasksptr const &  ttask  ) 

Moses::Manager::~Manager (  ) 

Definition at line 81 of file Manager.cpp.

References Moses::StaticData::CleanUpAfterSentenceProcessing(), Moses::StaticData::Instance(), m_search, m_transOptColl, and Moses::BaseManager::m_ttask.

Here is the call graph for this function:


Member Function Documentation

void Moses::Manager::CalcDecoderStatistics (  )  const [virtual]

void Moses::Manager::CalcLatticeSamples ( size_t  count,
TrellisPathList ret 
) const

Implements lattice sampling, as in Chatterjee & Cancedda, emnlp 2010

Definition at line 309 of file Manager.cpp.

References Moses::TrellisPathList::Add(), Moses::Hypothesis::GetId(), Moses::Hypothesis::GetPrevHypo(), Moses::Hypothesis::GetScore(), GetSearchGraph(), Moses::log_sum(), util::rand_incl(), sort(), and UTIL_THROW_IF2.

Referenced by OutputLatticeSamples().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Manager::CalcNBest ( size_t  count,
TrellisPathList ret,
bool  onlyDistinct = 0 
) const

After decoding, the hypotheses in the stacks and additional arcs form a search graph that can be mined for n-best lists. The heavy lifting is done in the TrellisPath and TrellisPathCollection this function controls this for one sentence.

Parameters:
count the number of n-best translations to produce
ret holds the n-best list that was calculated

Definition at line 242 of file Manager.cpp.

References Moses::TrellisPathList::Add(), Moses::TrellisPathCollection::Add(), Moses::TrellisPath::CreateDeviantPaths(), Moses::Search::GetHypothesisStacks(), Moses::StaticData::GetNBestFactor(), Moses::TrellisPathCollection::GetSize(), Moses::TrellisPathList::GetSize(), Moses::TrellisPath::GetSurfacePhrase(), Moses::StaticData::Instance(), m_search, NULL, Moses::TrellisPathCollection::pop(), Moses::TrellisPathCollection::Prune(), and UTIL_THROW_IF2.

Referenced by main(), OutputBest(), and OutputNBest().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Manager::Decode (  )  [virtual]

const Hypothesis* Moses::Manager::GetActualBestHypothesis (  )  const

const Hypothesis * Moses::Manager::GetBestHypothesis (  )  const

Definition at line 1450 of file Manager.cpp.

References Moses::Search::GetBestHypothesis(), and m_search.

Referenced by CalcDecoderStatistics(), Moses::doConsensusDecoding(), Moses::getLatticeMBRNBest(), OutputAlignment(), OutputBest(), and OutputDetailedTranslationReport().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Manager::GetConnectedGraph ( std::map< int, bool > *  pConnected,
std::vector< const Hypothesis * > *  pConnectedList 
) const [protected]

void Moses::Manager::GetForwardBackwardSearchGraph ( std::map< int, bool > *  pConnected,
std::vector< const Hypothesis * > *  pConnectedList,
std::map< const Hypothesis *, std::set< const Hypothesis * > > *  pOutgoingHyps,
std::vector< float > *  pFwdBwdScores 
) const

Referenced by Moses::doConsensusDecoding(), and Moses::getLatticeMBRNBest().

Here is the caller graph for this function:

int Moses::Manager::GetNextHypoId (  ) 

Definition at line 1455 of file Manager.cpp.

References m_hypoId.

void Moses::Manager::GetOutputLanguageModelOrder ( std::ostream &  out,
const Hypothesis hypo 
) const

Definition at line 572 of file Manager.cpp.

References Moses::Hypothesis::GetOutputPhrase(), and Moses::StatefulFeatureFunction::GetStatefulFeatureFunctions().

Referenced by OutputBest().

Here is the call graph for this function:

Here is the caller graph for this function:

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

void Moses::Manager::GetSearchGraph ( std::vector< SearchGraphNode > &  searchGraph  )  const

Referenced by CalcLatticeSamples(), OutputSearchGraph(), OutputSearchGraphAsHypergraph(), and OutputSearchGraphAsSLF().

Here is the caller graph for this function:

SentenceStats & Moses::Manager::GetSentenceStats (  )  const

const TranslationOptionCollection * Moses::Manager::getSntTranslationOptions (  ) 

Definition at line 169 of file Manager.cpp.

References m_transOptColl.

const InputType & Moses::Manager::GetSource (  )  const

void Moses::Manager::GetWinnerConnectedGraph ( std::map< int, bool > *  pConnected,
std::vector< const Hypothesis * > *  pConnectedList 
) const [protected]

void Moses::Manager::GetWordGraph ( long  translationId,
std::ostream &  outputWordGraphStream 
) const

void Moses::Manager::OutputAlignment ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputAlignment ( std::ostringstream &  out,
const TrellisPath path 
) const [protected]

Definition at line 2039 of file Manager.cpp.

References Moses::TrellisPath::GetEdges(), and OutputAlignment().

Here is the call graph for this function:

void Moses::Manager::OutputAlignment ( std::ostream &  out,
const std::vector< const Hypothesis * > &  edges 
) const [protected]

void Moses::Manager::OutputAlignment ( OutputCollector collector,
size_t  lineNo,
const std::vector< const Hypothesis * > &  edges 
) const [protected]

void Moses::Manager::OutputAlignment ( std::ostream &  out,
const AlignmentInfo ai,
size_t  sourceOffset,
size_t  targetOffset 
) const [protected]

Referenced by OutputAlignment(), OutputBest(), OutputNBest(), and OutputSurface().

Here is the caller graph for this function:

void Moses::Manager::OutputBest ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputBestHypo ( const Moses::TrellisPath path,
long  ,
char  reportSegmentation,
bool  reportAllFactors,
std::ostream &  out 
) const

Definition at line 2028 of file Manager.cpp.

References Moses::TrellisPath::GetEdges(), Moses::StaticData::Instance(), and OutputSurface().

Here is the call graph for this function:

void Moses::Manager::OutputBestHypo ( const std::vector< Moses::Word > &  mbrBestHypo,
long  ,
char  reportSegmentation,
bool  reportAllFactors,
std::ostream &  out 
) const

Referenced by main(), and OutputBest().

Here is the caller graph for this function:

void Moses::Manager::OutputDetailedTranslationReport ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputDetailedTreeFragmentsTranslationReport ( OutputCollector collector  )  const [inline, virtual]

Implements Moses::BaseManager.

Definition at line 207 of file Manager.h.

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

void Moses::Manager::OutputInput ( std::ostream &  os,
const Hypothesis hypo 
) const [protected]

Definition at line 1790 of file Manager.cpp.

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

Referenced by OutputInput(), and OutputNBest().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Manager::OutputLatticeMBRNBest ( std::ostream &  out,
const std::vector< LatticeMBRSolution > &  solutions,
long  translationId 
) const

Referenced by OutputBest().

Here is the caller graph for this function:

void Moses::Manager::OutputLatticeSamples ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputNBest ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputNBest ( std::ostream &  out,
const Moses::TrellisPathList nBestList,
const std::vector< Moses::FactorType > &  outputFactorOrder,
long  translationId,
char  reportSegmentation 
) const [protected]

void Moses::Manager::OutputSearchGraph ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputSearchGraph ( long  translationId,
std::ostream &  outputSearchGraphStream 
) const

Definition at line 1363 of file Manager.cpp.

References GetSearchGraph(), and Moses::OutputSearchNode().

Referenced by OutputSearchGraph().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Manager::OutputSearchGraphAsHypergraph ( std::ostream &  outputSearchGraphStream  )  const [virtual]

void Moses::Manager::OutputSearchGraphAsSLF ( long  translationId,
std::ostream &  outputSearchGraphStream 
) const

! Output search graph in HTK standard lattice format (SLF)

Definition at line 1014 of file Manager.cpp.

References Moses::Hypothesis::GetCurrTargetPhrase(), Moses::Hypothesis::GetId(), Moses::Hypothesis::GetPrevHypo(), GetSearchGraph(), Moses::Phrase::GetSize(), Moses::Phrase::GetWord(), and lineNumber.

Referenced by OutputSearchGraphSLF().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Manager::OutputSearchGraphSLF (  )  const [virtual]

void Moses::Manager::OutputSurface ( std::ostream &  out,
const Hypothesis edge,
const std::vector< FactorType > &  outputFactorOrder,
char  reportSegmentation,
bool  reportAllFactors 
) const [protected]

void Moses::Manager::OutputUnknowns ( OutputCollector collector  )  const [virtual]

void Moses::Manager::OutputWordGraph ( OutputCollector collector  )  const [virtual]

Implements Moses::BaseManager.

Definition at line 1912 of file Manager.cpp.

References Moses::FixPrecision(), Moses::InputType::GetTranslationId(), GetWordGraph(), Moses::BaseManager::m_source, and Moses::OutputCollector::Write().

Here is the call graph for this function:

void Moses::Manager::OutputWordGraph ( std::ostream &  outputWordGraphStream,
const Hypothesis hypo,
size_t &  linkId 
) const [protected]

void Moses::Manager::PrintAllDerivations ( long  translationId,
std::ostream &  outputStream 
) const

Referenced by OutputBest().

Here is the caller graph for this function:

void Moses::Manager::printDivergentHypothesis ( long  translationId,
const Hypothesis hypo,
const std::vector< const TargetPhrase * > &  remainingPhrases,
float  remainingScore,
std::ostream &  outputStream 
) const

void Moses::Manager::printThisHypothesis ( long  translationId,
const Hypothesis hypo,
const std::vector< const TargetPhrase * > &  remainingPhrases,
float  remainingScore,
std::ostream &  outputStream 
) const

void Moses::Manager::ResetSentenceStats ( const InputType source  ) 

Definition at line 1460 of file Manager.cpp.

References m_sentenceStats.

Referenced by Decode().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 118 of file Manager.h.

actual (full expanded) stack of hypotheses

Definition at line 119 of file Manager.h.

std::ostringstream Moses::Manager::m_alignmentOut [mutable, protected]

Definition at line 133 of file Manager.h.

Referenced by OutputAlignment(), and OutputBest().

int Moses::Manager::m_hypoId [protected]

Definition at line 121 of file Manager.h.

Referenced by GetNextHypoId().

std::ostringstream Moses::Manager::m_latticeNBestOut [mutable, protected]

Definition at line 132 of file Manager.h.

Referenced by OutputBest(), and OutputNBest().

std::auto_ptr<SentenceStats> Moses::Manager::m_sentenceStats [protected]

Definition at line 120 of file Manager.h.

Referenced by GetSentenceStats(), and ResetSentenceStats().

pre-computed list of translation options for the phrases in this sentence

Definition at line 115 of file Manager.h.

Referenced by Decode(), getSntTranslationOptions(), Manager(), OutputUnknowns(), and ~Manager().


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

Generated on Mon Jul 6 00:33:36 2015 for Moses by  doxygen 1.5.9