Moses::Phrase Class Reference

#include <Phrase.h>

Inheritance diagram for Moses::Phrase:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 Phrase (size_t reserveSize)
 Phrase (const std::vector< const Word * > &mergeWords)
virtual ~Phrase ()
void CreateFromString (const std::vector< FactorType > &factorOrder, const StringPiece &phraseString, const StringPiece &factorDelimiter)
void CreateFromStringNewFormat (FactorDirection direction, const std::vector< FactorType > &factorOrder, const std::string &phraseString, const std::string &factorDelimiter, Word &lhs)
void MergeFactors (const Phrase &copy)
void MergeFactors (const Phrase &copy, FactorType factorType)
 copy a single factor (specified by factorType)
void MergeFactors (const Phrase &copy, const std::vector< FactorType > &factorVec)
 copy all factors specified in factorVec and none others
bool IsCompatible (const Phrase &inputPhrase) const
bool IsCompatible (const Phrase &inputPhrase, FactorType factorType) const
bool IsCompatible (const Phrase &inputPhrase, const std::vector< FactorType > &factorVec) const
size_t GetSize () const
 number of words
const WordGetWord (size_t pos) const
 word at a particular position
WordGetWord (size_t pos)
const FactorGetFactor (size_t pos, FactorType factorType) const
 particular factor at a particular position
void SetFactor (size_t pos, FactorType factorType, const Factor *factor)
size_t GetNumTerminals () const
bool Contains (const std::vector< std::vector< std::string > > &subPhraseVector, const std::vector< FactorType > &inputFactor) const
 whether the 2D vector is a substring of this phrase
WordAddWord ()
 create an empty word at the end of the phrase
void AddWord (const Word &newWord)
 create copy of input word at the end of the phrase
void Append (const Phrase &endPhrase)
void PrependWord (const Word &newWord)
void Clear ()
void RemoveWord (size_t pos)
Phrase GetSubString (const WordsRange &wordsRange) const
 create new phrase class that is a substring of this phrase
std::string GetStringRep (const std::vector< FactorType > factorsToPrint) const
 return a string rep of the phrase. Each factor is separated by the factor delimiter as specified in StaticData class
 TO_STRING ()
int Compare (const Phrase &other) const
bool operator< (const Phrase &compare) const
bool operator== (const Phrase &compare) const

Static Public Member Functions

static void InitializeMemPool ()
static void FinalizeMemPool ()

Friends

std::ostream & operator<< (std::ostream &, const Phrase &)


Detailed Description

Definition at line 40 of file Phrase.h.


Constructor & Destructor Documentation

Moses::Phrase::Phrase ( size_t  reserveSize  ) 

create empty phrase

Definition at line 40 of file Phrase.cpp.

Moses::Phrase::Phrase ( const std::vector< const Word * > &  mergeWords  ) 

create phrase from vectors of words

Moses::Phrase::~Phrase (  )  [virtual]

destructor

Definition at line 53 of file Phrase.cpp.


Member Function Documentation

void Moses::Phrase::AddWord ( const Word newWord  )  [inline]

create copy of input word at the end of the phrase

Definition at line 121 of file Phrase.h.

References AddWord().

Here is the call graph for this function:

Word & Moses::Phrase::AddWord (  ) 

void Moses::Phrase::Append ( const Phrase endPhrase  ) 

appends a phrase at the end of current phrase

Definition at line 118 of file Phrase.cpp.

References AddWord(), GetSize(), and GetWord().

Referenced by Moses::ChartTrellisNode::GetOutputPhrase(), and Moses::TrellisPath::GetTargetPhrase().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Phrase::Clear (  )  [inline]

Definition at line 129 of file Phrase.h.

int Moses::Phrase::Compare ( const Phrase other  )  const

Definition at line 208 of file Phrase.cpp.

References GetSize(), and GetWord().

Referenced by operator<(), and operator==().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::Phrase::Contains ( const std::vector< std::vector< std::string > > &  subPhraseVector,
const std::vector< FactorType > &  inputFactor 
) const

whether the 2D vector is a substring of this phrase

void Moses::Phrase::CreateFromString ( const std::vector< FactorType > &  factorOrder,
const StringPiece phraseString,
const StringPiece factorDelimiter 
)

Fills phrase with words from format string, typically from phrase table or sentence input

Parameters:
factorOrder factor types of each element in 2D string vector
phraseString formatted input string to parse
factorDelimiter delimiter between factors.

Definition at line 139 of file Phrase.cpp.

References Moses::FactorCollection::AddFactor(), AddWord(), index, Moses::FactorCollection::Instance(), StringPiece::size(), and TRACE_ERR.

Referenced by Moses::BilingualDynSuffixArray::addSntPair(), Moses::StaticData::LoadData(), main(), Moses::ProcessAndStripXMLTags(), and Moses::TargetPhrase::TargetPhrase().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Phrase::CreateFromStringNewFormat ( FactorDirection  direction,
const std::vector< FactorType > &  factorOrder,
const std::string &  phraseString,
const std::string &  factorDelimiter,
Word lhs 
)

Definition at line 161 of file Phrase.cpp.

References AddWord(), CHECK, Moses::Word::CreateFromString(), Moses::Input, Moses::Word::IsNonTerminal(), and Moses::Tokenize().

Referenced by Moses::RuleTableLoaderStandard::Load().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Phrase::FinalizeMemPool (  )  [static]

Definition at line 329 of file Phrase.cpp.

Referenced by Moses::StaticData::~StaticData().

Here is the caller graph for this function:

const Factor* Moses::Phrase::GetFactor ( size_t  pos,
FactorType  factorType 
) const [inline]

particular factor at a particular position

Definition at line 103 of file Phrase.h.

Referenced by Moses::Hypothesis::GetCurrFactor(), GetOutputFactors(), Moses::TrellisPath::GetSurfacePhrase(), IsCompatible(), main(), MergeFactors(), OutputSurface(), and Moses::LanguageModelSingleFactor::Useable().

Here is the caller graph for this function:

size_t Moses::Phrase::GetNumTerminals (  )  const

Definition at line 314 of file Phrase.cpp.

References GetSize(), GetWord(), and Moses::Word::IsNonTerminal().

Here is the call graph for this function:

size_t Moses::Phrase::GetSize (  )  const [inline]

number of words

Reimplemented in Moses::Sentence.

Definition at line 91 of file Phrase.h.

Referenced by Moses::BilingualDynSuffixArray::addSntPair(), Append(), calcNgramExpectations(), Moses::TranslationOption::CalcScore(), Moses::LanguageModelImplementation::CalcScore(), Compare(), Moses::Hypothesis::Create(), Moses::ChartHypothesis::CreateOutputPhrase(), Moses::PhraseDictionaryMemory::CreateTargetPhraseCollection(), Moses::SyntacticLanguageModel::Evaluate(), Moses::WordPenaltyProducer::Evaluate(), Moses::LanguageModelImplementation::EvaluateChart(), GetNumTerminals(), Moses::PhraseDictionarySCFG::GetOrCreateNode(), GetOutputFactors(), Moses::ChartTrellisNode::GetOutputPhrase(), GetOutputWords(), Edge::GetPhraseSuffix(), Moses::LexicalReorderingTableTree::GetScore(), Moses::LexicalReorderingTableMemory::GetScore(), Moses::TrellisPath::GetSurfacePhrase(), Moses::PhraseDictionaryMemory::GetTargetPhraseCollection(), Moses::PDTAimp::GetTargetPhraseCollection(), Moses::BilingualDynSuffixArray::GetTargetPhrasesByLexicalWeight(), Edge::GetWordsSize(), IsCompatible(), Moses::TranslationOption::IsDeletionOption(), LatticeMBRSolution::LatticeMBRSolution(), main(), MergeFactors(), Moses::TranslationOption::MergeNewFeatures(), Moses::TargetPhrase::MergeNext(), Moses::operator<<(), OutputAlignment(), OutputBestHypo(), OutputSurface(), PrependWord(), Moses::Hypothesis::PrintHypothesis(), Moses::DecodeStepTranslation::Process(), Moses::DecodeStepGeneration::Process(), Moses::SearchNormal::SearchNormal(), Moses::ReorderingConstraint::SetMonotoneAtPunctuation(), Moses::LanguageModelSingleFactor::Useable(), and Moses::LanguageModelMultiFactor::Useable().

Here is the caller graph for this function:

std::string Moses::Phrase::GetStringRep ( const std::vector< FactorType factorsToPrint  )  const

return a string rep of the phrase. Each factor is separated by the factor delimiter as specified in StaticData class

Referenced by main(), and Moses::OutputSearchNode().

Here is the caller graph for this function:

Phrase Moses::Phrase::GetSubString ( const WordsRange wordsRange  )  const

create new phrase class that is a substring of this phrase

Reimplemented in Moses::Sentence.

Definition at line 90 of file Phrase.cpp.

References AddWord(), Moses::WordsRange::GetEndPos(), Moses::WordsRange::GetNumWordsCovered(), Moses::WordsRange::GetStartPos(), and GetWord().

Referenced by Moses::Hypothesis::Create(), Moses::LexicalReorderingTableMemory::GetScore(), and Moses::Hypothesis::PrintHypothesis().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 99 of file Phrase.h.

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

void Moses::Phrase::InitializeMemPool (  )  [static]

No longer does anything as not using mem pool for Phrase class anymore

Definition at line 325 of file Phrase.cpp.

Referenced by Moses::StaticData::StaticData().

Here is the caller graph for this function:

bool Moses::Phrase::IsCompatible ( const Phrase inputPhrase,
const std::vector< FactorType > &  factorVec 
) const

Definition at line 299 of file Phrase.cpp.

References GetFactor(), and GetSize().

Here is the call graph for this function:

bool Moses::Phrase::IsCompatible ( const Phrase inputPhrase,
FactorType  factorType 
) const

Definition at line 287 of file Phrase.cpp.

References GetFactor(), and GetSize().

Here is the call graph for this function:

bool Moses::Phrase::IsCompatible ( const Phrase inputPhrase  )  const

compare 2 phrases to ensure no factors are lost if the phrases are merged must run IsCompatible() to ensure incompatible factors aren't being overwritten

Definition at line 265 of file Phrase.cpp.

References GetFactor(), GetSize(), Moses::MAX_NUM_FACTORS, and NULL.

Referenced by Moses::Hypothesis::Create(), Moses::TranslationOption::IsCompatible(), and Moses::TargetPhrase::MergeNext().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::Phrase::MergeFactors ( const Phrase copy,
const std::vector< FactorType > &  factorVec 
)

copy all factors specified in factorVec and none others

Definition at line 79 of file Phrase.cpp.

References CHECK, GetFactor(), GetSize(), and SetFactor().

Here is the call graph for this function:

void Moses::Phrase::MergeFactors ( const Phrase copy,
FactorType  factorType 
)

copy a single factor (specified by factorType)

Definition at line 72 of file Phrase.cpp.

References CHECK, GetFactor(), GetSize(), and SetFactor().

Here is the call graph for this function:

void Moses::Phrase::MergeFactors ( const Phrase copy  ) 

copy factors from the other phrase to this phrase. IsCompatible() must be run beforehand to ensure incompatible factors aren't overwritten

Definition at line 57 of file Phrase.cpp.

References CHECK, GetFactor(), GetSize(), Moses::MAX_NUM_FACTORS, NULL, and SetFactor().

Referenced by Moses::TranslationOption::MergeNewFeatures().

Here is the call graph for this function:

Here is the caller graph for this function:

bool Moses::Phrase::operator< ( const Phrase compare  )  const [inline]

transitive comparison between 2 phrases used to insert & find phrase in dictionary

Definition at line 152 of file Phrase.h.

References Compare().

Here is the call graph for this function:

bool Moses::Phrase::operator== ( const Phrase compare  )  const [inline]

Definition at line 156 of file Phrase.h.

References Compare().

Here is the call graph for this function:

void Moses::Phrase::PrependWord ( const Word newWord  ) 

Definition at line 126 of file Phrase.cpp.

References AddWord(), and GetSize().

Here is the call graph for this function:

void Moses::Phrase::RemoveWord ( size_t  pos  )  [inline]

Definition at line 133 of file Phrase.h.

References CHECK.

void Moses::Phrase::SetFactor ( size_t  pos,
FactorType  factorType,
const Factor factor 
) [inline]

Definition at line 107 of file Phrase.h.

Referenced by MergeFactors().

Here is the caller graph for this function:

Moses::Phrase::TO_STRING (  ) 

Reimplemented in Moses::TargetPhrase.


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
const Phrase  
) [friend]


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

Generated on Wed Feb 8 08:04:09 2012 for Moses by  doxygen 1.5.9