Moses::PhraseOrientationFeature Class Reference

#include <PhraseOrientationFeature.h>

Inheritance diagram for Moses::PhraseOrientationFeature:

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

Collaboration graph
[legend]

List of all members.

Classes

struct  ReoClassData

Public Member Functions

 PhraseOrientationFeature (const std::string &line)
 ~PhraseOrientationFeature ()
bool IsUseable (const FactorMask &mask) const
virtual const FFStateEmptyHypothesisState (const InputType &input) const
 return the state associated with the empty hypothesis for a given sentence
void SetParameter (const std::string &key, const std::string &value)
void Load (AllOptions::ptr const &opts)
 override to load model files
void EvaluateInIsolation (const Phrase &source, const TargetPhrase &targetPhrase, ScoreComponentCollection &scoreBreakdown, ScoreComponentCollection &estimatedScores) const
FFStateEvaluateWhenApplied (const Hypothesis &cur_hypo, const FFState *prev_state, ScoreComponentCollection *accumulator) const
 This interface should be implemented. Notes: When evaluating the value of this feature function, you should avoid calling hypo.GetPrevHypo(). If you need something from the "previous" hypothesis, you should store it in an FFState object which will be passed in as prev_state. If you don't do this, you will get in trouble.
FFStateEvaluateWhenApplied (const ChartHypothesis &cur_hypo, int featureID, ScoreComponentCollection *accumulator) const

Protected Member Functions

void LoadWordList (const std::string &filename, boost::unordered_set< const Factor * > &list)
void LookaheadScore (const OrientationPhraseProperty *orientationPhraseProperty, ScoreComponentCollection &scoreBreakdown, const Factor *targetPhraseLHS, bool subtract=false) const
size_t GetHeuristicScoreIndex (const std::vector< float > &scores, size_t weightsVectorOffset, const std::bitset< 3 > possibleFutureOrientations=0x7) const
void LeftBoundaryL2RScoreRecursive (int featureID, const PhraseOrientationFeatureState *state, const std::bitset< 3 > orientation, std::vector< float > &newScores, ScoreComponentCollection *scoreBreakdown) const
void RightBoundaryR2LScoreRecursive (int featureID, const PhraseOrientationFeatureState *state, const std::bitset< 3 > orientation, std::vector< float > &newScores, ScoreComponentCollection *scoreBreakdown) const
void SparseWordL2RScore (const ChartHypothesis *hypo, ScoreComponentCollection *scoreBreakdown, const std::string *o) const
void SparseWordR2LScore (const ChartHypothesis *hypo, ScoreComponentCollection *scoreBreakdown, const std::string *o) const
void SparseNonTerminalL2RScore (const Factor *nonTerminalSymbol, ScoreComponentCollection *scoreBreakdown, const std::string *o) const
void SparseNonTerminalR2LScore (const Factor *nonTerminalSymbol, ScoreComponentCollection *scoreBreakdown, const std::string *o) const
const std::string * ToString (const MosesTraining::PhraseOrientation::REO_CLASS o) const

Protected Attributes

std::string m_glueLabelStr
const Factorm_glueLabel
bool m_noScoreBoundary
bool m_monotoneScoreBoundary
bool m_distinguishStates
bool m_lookaheadScore
bool m_heuristicScoreUseWeights
bool m_useSparseWord
bool m_useSparseNT
size_t m_offsetR2LScores
std::vector< float > m_weightsVector
std::string m_filenameTargetWordList
boost::unordered_set< const
Factor * > 
m_targetWordList
bool m_useTargetWordList
std::string m_filenameSourceWordList
boost::unordered_set< const
Factor * > 
m_sourceWordList
bool m_useSourceWordList

Static Protected Attributes

static const std::string MORIENT
static const std::string SORIENT
static const std::string DORIENT


Detailed Description

Definition at line 309 of file PhraseOrientationFeature.h.


Constructor & Destructor Documentation

Moses::PhraseOrientationFeature::PhraseOrientationFeature ( const std::string &  line  ) 

Moses::PhraseOrientationFeature::~PhraseOrientationFeature (  )  [inline]

Definition at line 327 of file PhraseOrientationFeature.h.


Member Function Documentation

virtual const FFState* Moses::PhraseOrientationFeature::EmptyHypothesisState ( const InputType input  )  const [inline, virtual]

return the state associated with the empty hypothesis for a given sentence

Implements Moses::StatefulFeatureFunction.

Definition at line 334 of file PhraseOrientationFeature.h.

References m_distinguishStates, m_useSparseNT, and m_useSparseWord.

void Moses::PhraseOrientationFeature::EvaluateInIsolation ( const Phrase source,
const TargetPhrase targetPhrase,
ScoreComponentCollection scoreBreakdown,
ScoreComponentCollection estimatedScores 
) const [virtual]

FFState * Moses::PhraseOrientationFeature::EvaluateWhenApplied ( const ChartHypothesis cur_hypo,
int  featureID,
ScoreComponentCollection accumulator 
) const [virtual]

Implements Moses::StatefulFeatureFunction.

Definition at line 286 of file PhraseOrientationFeature.cpp.

References Moses::AlignmentInfo::begin(), Moses::AlignmentInfo::end(), FEATUREVERBOSE, FEATUREVERBOSE2, Moses::PhraseOrientationFeature::ReoClassData::firstNonTerminalFollowingSourceSpanIsAligned, Moses::PhraseOrientationFeature::ReoClassData::firstNonTerminalIsBoundary, Moses::PhraseOrientationFeature::ReoClassData::firstNonTerminalPreviousSourceSpanIsAligned, Moses::TargetPhrase::GetAlignNonTerm(), Moses::TargetPhrase::GetAlignTerm(), Moses::ChartHypothesis::GetCurrTargetPhrase(), Moses::TargetPhrase::GetData(), Moses::ChartHypothesis::GetFFState(), GetHeuristicScoreIndex(), Moses::OrientationPhraseProperty::GetLeftToRightProbabilityDiscontinuous(), Moses::OrientationPhraseProperty::GetLeftToRightProbabilityDleft(), Moses::OrientationPhraseProperty::GetLeftToRightProbabilityDright(), Moses::OrientationPhraseProperty::GetLeftToRightProbabilityMono(), Moses::OrientationPhraseProperty::GetLeftToRightProbabilitySwap(), Moses::AlignmentInfo::GetNonTermIndexMap(), Moses::ChartHypothesis::GetPrevHypo(), Moses::TargetPhrase::GetProperty(), Moses::OrientationPhraseProperty::GetRightToLeftProbabilityDiscontinuous(), Moses::OrientationPhraseProperty::GetRightToLeftProbabilityDleft(), Moses::OrientationPhraseProperty::GetRightToLeftProbabilityDright(), Moses::OrientationPhraseProperty::GetRightToLeftProbabilityMono(), Moses::OrientationPhraseProperty::GetRightToLeftProbabilitySwap(), Moses::TargetPhrase::GetRuleSource(), Moses::FeatureFunction::GetScoreProducerDescription(), Moses::AlignmentInfo::GetSize(), Moses::TargetPhrase::GetTargetLHS(), Moses::Phrase::GetWord(), IFFEATUREVERBOSE, Moses::Word::IsOOV(), Moses::PhraseOrientationFeature::ReoClassData::lastNonTerminalFollowingSourceSpanIsAligned, Moses::PhraseOrientationFeature::ReoClassData::lastNonTerminalIsBoundary, Moses::PhraseOrientationFeature::ReoClassData::lastNonTerminalPreviousSourceSpanIsAligned, LeftBoundaryL2RScoreRecursive(), LookaheadScore(), m_distinguishStates, Moses::PhraseOrientationFeatureState::m_leftBoundaryNonTerminalL2RPossibleFutureOrientations, Moses::PhraseOrientationFeatureState::m_leftBoundaryRecursionGuard, m_lookaheadScore, m_monotoneScoreBoundary, m_noScoreBoundary, Moses::FeatureFunction::m_numScoreComponents, m_offsetR2LScores, Moses::PhraseOrientationFeatureState::m_rightBoundaryNonTerminalR2LPossibleFutureOrientations, Moses::PhraseOrientationFeatureState::m_rightBoundaryRecursionGuard, m_useSparseNT, m_useSparseWord, Moses::PhraseOrientationFeature::ReoClassData::nonTerminalReoClassL2R, Moses::PhraseOrientationFeature::ReoClassData::nonTerminalReoClassR2L, NULL, Moses::ScoreComponentCollection::PlusEquals(), MosesTraining::PhraseOrientation::REO_CLASS_DLEFT, MosesTraining::PhraseOrientation::REO_CLASS_DRIGHT, MosesTraining::PhraseOrientation::REO_CLASS_LEFT, MosesTraining::PhraseOrientation::REO_CLASS_RIGHT, MosesTraining::PhraseOrientation::REO_CLASS_UNKNOWN, RightBoundaryR2LScoreRecursive(), Moses::PhraseOrientationFeatureState::SetLeftBoundaryL2R(), Moses::PhraseOrientationFeatureState::SetRightBoundaryR2L(), SparseNonTerminalL2RScore(), SparseNonTerminalR2LScore(), SparseWordL2RScore(), SparseWordR2LScore(), state, ToString(), Moses::TransformScore(), UTIL_THROW2, and UTIL_THROW_IF2.

Here is the call graph for this function:

FFState* Moses::PhraseOrientationFeature::EvaluateWhenApplied ( const Hypothesis cur_hypo,
const FFState prev_state,
ScoreComponentCollection accumulator 
) const [inline, virtual]

This interface should be implemented. Notes: When evaluating the value of this feature function, you should avoid calling hypo.GetPrevHypo(). If you need something from the "previous" hypothesis, you should store it in an FFState object which will be passed in as prev_state. If you don't do this, you will get in trouble.

Implements Moses::StatefulFeatureFunction.

Definition at line 347 of file PhraseOrientationFeature.h.

References Moses::FeatureFunction::GetScoreProducerDescription(), m_distinguishStates, m_useSparseNT, m_useSparseWord, and UTIL_THROW2.

Here is the call graph for this function:

size_t Moses::PhraseOrientationFeature::GetHeuristicScoreIndex ( const std::vector< float > &  scores,
size_t  weightsVectorOffset,
const std::bitset< 3 >  possibleFutureOrientations = 0x7 
) const [protected]

bool Moses::PhraseOrientationFeature::IsUseable ( const FactorMask mask  )  const [inline, virtual]

Implements Moses::FeatureFunction.

Definition at line 330 of file PhraseOrientationFeature.h.

void Moses::PhraseOrientationFeature::LeftBoundaryL2RScoreRecursive ( int  featureID,
const PhraseOrientationFeatureState state,
const std::bitset< 3 >  orientation,
std::vector< float > &  newScores,
ScoreComponentCollection scoreBreakdown 
) const [protected]

Definition at line 706 of file PhraseOrientationFeature.cpp.

References FEATUREVERBOSE, state, and UTIL_THROW2.

Referenced by EvaluateWhenApplied().

Here is the caller graph for this function:

void Moses::PhraseOrientationFeature::Load ( AllOptions::ptr const &  opts  )  [virtual]

override to load model files

Reimplemented from Moses::FeatureFunction.

Definition at line 133 of file PhraseOrientationFeature.cpp.

References LoadWordList(), m_filenameSourceWordList, m_filenameTargetWordList, Moses::FeatureFunction::m_options, m_sourceWordList, m_targetWordList, m_useSourceWordList, and m_useTargetWordList.

Here is the call graph for this function:

void Moses::PhraseOrientationFeature::LoadWordList ( const std::string &  filename,
boost::unordered_set< const Factor * > &  list 
) [protected]

Definition at line 147 of file PhraseOrientationFeature.cpp.

References Moses::FactorCollection::AddFactor(), Moses::InputFileStream::Close(), FEATUREVERBOSE, and Moses::FactorCollection::Instance().

Referenced by Load().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::PhraseOrientationFeature::LookaheadScore ( const OrientationPhraseProperty orientationPhraseProperty,
ScoreComponentCollection scoreBreakdown,
const Factor targetPhraseLHS,
bool  subtract = false 
) const [protected]

void Moses::PhraseOrientationFeature::RightBoundaryR2LScoreRecursive ( int  featureID,
const PhraseOrientationFeatureState state,
const std::bitset< 3 >  orientation,
std::vector< float > &  newScores,
ScoreComponentCollection scoreBreakdown 
) const [protected]

Definition at line 767 of file PhraseOrientationFeature.cpp.

References FEATUREVERBOSE, state, and UTIL_THROW2.

Referenced by EvaluateWhenApplied().

Here is the caller graph for this function:

void Moses::PhraseOrientationFeature::SetParameter ( const std::string &  key,
const std::string &  value 
) [virtual]

void Moses::PhraseOrientationFeature::SparseNonTerminalL2RScore ( const Factor nonTerminalSymbol,
ScoreComponentCollection scoreBreakdown,
const std::string *  o 
) const [protected]

Definition at line 946 of file PhraseOrientationFeature.cpp.

References StringPiece::as_string(), FEATUREVERBOSE, Moses::Factor::GetString(), m_glueLabel, and Moses::ScoreComponentCollection::PlusEquals().

Referenced by EvaluateWhenApplied().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::PhraseOrientationFeature::SparseNonTerminalR2LScore ( const Factor nonTerminalSymbol,
ScoreComponentCollection scoreBreakdown,
const std::string *  o 
) const [protected]

Definition at line 960 of file PhraseOrientationFeature.cpp.

References StringPiece::as_string(), FEATUREVERBOSE, Moses::Factor::GetString(), m_glueLabel, and Moses::ScoreComponentCollection::PlusEquals().

Referenced by EvaluateWhenApplied().

Here is the call graph for this function:

Here is the caller graph for this function:

void Moses::PhraseOrientationFeature::SparseWordL2RScore ( const ChartHypothesis hypo,
ScoreComponentCollection scoreBreakdown,
const std::string *  o 
) const [protected]

void Moses::PhraseOrientationFeature::SparseWordR2LScore ( const ChartHypothesis hypo,
ScoreComponentCollection scoreBreakdown,
const std::string *  o 
) const [protected]

const std::string * Moses::PhraseOrientationFeature::ToString ( const MosesTraining::PhraseOrientation::REO_CLASS  o  )  const [protected]


Member Data Documentation

const std::string Moses::PhraseOrientationFeature::DORIENT [static, protected]

Definition at line 407 of file PhraseOrientationFeature.h.

Referenced by ToString().

Definition at line 423 of file PhraseOrientationFeature.h.

Referenced by Load(), and SetParameter().

Definition at line 420 of file PhraseOrientationFeature.h.

Referenced by Load(), and SetParameter().

Definition at line 409 of file PhraseOrientationFeature.h.

Referenced by PhraseOrientationFeature(), and SetParameter().

Definition at line 415 of file PhraseOrientationFeature.h.

Referenced by GetHeuristicScoreIndex(), and SetParameter().

Definition at line 412 of file PhraseOrientationFeature.h.

Referenced by EvaluateWhenApplied(), and SetParameter().

Definition at line 411 of file PhraseOrientationFeature.h.

Referenced by EvaluateWhenApplied(), and SetParameter().

Definition at line 418 of file PhraseOrientationFeature.h.

Referenced by EvaluateWhenApplied(), and LookaheadScore().

boost::unordered_set<const Factor*> Moses::PhraseOrientationFeature::m_sourceWordList [protected]

Definition at line 424 of file PhraseOrientationFeature.h.

Referenced by Load(), SparseWordL2RScore(), and SparseWordR2LScore().

boost::unordered_set<const Factor*> Moses::PhraseOrientationFeature::m_targetWordList [protected]

Definition at line 421 of file PhraseOrientationFeature.h.

Referenced by Load(), SparseWordL2RScore(), and SparseWordR2LScore().

Definition at line 425 of file PhraseOrientationFeature.h.

Referenced by Load(), SparseWordL2RScore(), and SparseWordR2LScore().

Definition at line 422 of file PhraseOrientationFeature.h.

Referenced by Load(), SparseWordL2RScore(), and SparseWordR2LScore().

std::vector<float> Moses::PhraseOrientationFeature::m_weightsVector [mutable, protected]

Definition at line 419 of file PhraseOrientationFeature.h.

Referenced by GetHeuristicScoreIndex().

const std::string Moses::PhraseOrientationFeature::MORIENT [static, protected]

Definition at line 405 of file PhraseOrientationFeature.h.

Referenced by ToString().

const std::string Moses::PhraseOrientationFeature::SORIENT [static, protected]

Definition at line 406 of file PhraseOrientationFeature.h.

Referenced by ToString().


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

Generated on Thu Jul 6 00:33:09 2017 for Moses by  doxygen 1.5.9