#include <SoftSourceSyntacticConstraintsFeature.h>
Public Member Functions | |
SoftSourceSyntacticConstraintsFeature (const std::string &line) | |
~SoftSourceSyntacticConstraintsFeature () | |
bool | IsUseable (const FactorMask &mask) const |
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 |
void | EvaluateWithSourceContext (const InputType &input, const InputPath &inputPath, const TargetPhrase &targetPhrase, const StackVec *stackVec, ScoreComponentCollection &scoreBreakdown, ScoreComponentCollection *estimatedScores=NULL) const |
void | EvaluateTranslationOptionListWithSourceContext (const InputType &input, const TranslationOptionList &translationOptionList) const |
void | EvaluateWhenApplied (const Hypothesis &cur_hypo, ScoreComponentCollection *accumulator) const |
void | EvaluateWhenApplied (const ChartHypothesis &cur_hypo, ScoreComponentCollection *accumulator) const |
Protected Member Functions | |
void | LoadSourceLabelSet () |
void | LoadCoreSourceLabelSet () |
void | LoadTargetSourceLeftHandSideJointCountFile () |
void | LoadLabelSet (std::string &filename, boost::unordered_set< size_t > &labelSet) |
std::pair< float, float > | GetLabelPairProbabilities (const Factor *target, const size_t source) const |
Protected Attributes | |
std::string | m_sourceLabelSetFile |
std::string | m_coreSourceLabelSetFile |
std::string | m_targetSourceLHSJointCountFile |
std::string | m_unknownLeftHandSideFile |
bool | m_useCoreSourceLabels |
bool | m_useLogprobs |
bool | m_useSparse |
bool | m_useSparseLabelPairs |
bool | m_noMismatches |
float | m_floor |
boost::unordered_map < std::string, size_t > | m_sourceLabels |
std::vector< std::string > | m_sourceLabelsByIndex |
std::vector< std::string > | m_sourceLabelsByIndex_RHS_1 |
std::vector< std::string > | m_sourceLabelsByIndex_RHS_0 |
std::vector< std::string > | m_sourceLabelsByIndex_LHS_1 |
std::vector< std::string > | m_sourceLabelsByIndex_LHS_0 |
boost::unordered_set< size_t > | m_coreSourceLabels |
boost::unordered_map< const Factor *, size_t > | m_sourceLabelIndexesByFactor |
size_t | m_GlueTopLabel |
boost::unordered_map< const Factor *, std::vector < std::pair< float, float > > * > | m_labelPairProbabilities |
boost::unordered_map< size_t, float > | m_unknownLHSProbabilities |
float | m_smoothingWeight |
float | m_unseenLHSSmoothingFactorForUnknowns |
Definition at line 14 of file SoftSourceSyntacticConstraintsFeature.h.
Moses::SoftSourceSyntacticConstraintsFeature::SoftSourceSyntacticConstraintsFeature | ( | const std::string & | line | ) |
Definition at line 22 of file SoftSourceSyntacticConstraintsFeature.cpp.
References Moses::FeatureFunction::GetScoreProducerDescription(), m_noMismatches, m_useCoreSourceLabels, m_useLogprobs, m_useSparse, m_useSparseLabelPairs, Moses::FeatureFunction::ReadParameters(), and VERBOSE.
Moses::SoftSourceSyntacticConstraintsFeature::~SoftSourceSyntacticConstraintsFeature | ( | ) | [inline] |
Definition at line 21 of file SoftSourceSyntacticConstraintsFeature.h.
References m_labelPairProbabilities.
void Moses::SoftSourceSyntacticConstraintsFeature::EvaluateInIsolation | ( | const Phrase & | source, | |
const TargetPhrase & | targetPhrase, | |||
ScoreComponentCollection & | scoreBreakdown, | |||
ScoreComponentCollection & | estimatedScores | |||
) | const [inline, virtual] |
Implements Moses::FeatureFunction.
Definition at line 36 of file SoftSourceSyntacticConstraintsFeature.h.
References Moses::TargetPhrase::SetRuleSource().
void Moses::SoftSourceSyntacticConstraintsFeature::EvaluateTranslationOptionListWithSourceContext | ( | const InputType & | input, | |
const TranslationOptionList & | translationOptionList | |||
) | const [inline, virtual] |
Implements Moses::FeatureFunction.
Definition at line 50 of file SoftSourceSyntacticConstraintsFeature.h.
void Moses::SoftSourceSyntacticConstraintsFeature::EvaluateWhenApplied | ( | const ChartHypothesis & | hypo, | |
ScoreComponentCollection * | accumulator | |||
) | const [inline, virtual] |
Same for chart-based features.
Implements Moses::StatelessFeatureFunction.
Definition at line 59 of file SoftSourceSyntacticConstraintsFeature.h.
void Moses::SoftSourceSyntacticConstraintsFeature::EvaluateWhenApplied | ( | const Hypothesis & | hypo, | |
ScoreComponentCollection * | accumulator | |||
) | const [inline, virtual] |
This should be implemented for features that apply to phrase-based models.
Implements Moses::StatelessFeatureFunction.
Definition at line 54 of file SoftSourceSyntacticConstraintsFeature.h.
void Moses::SoftSourceSyntacticConstraintsFeature::EvaluateWithSourceContext | ( | const InputType & | input, | |
const InputPath & | inputPath, | |||
const TargetPhrase & | targetPhrase, | |||
const StackVec * | stackVec, | |||
ScoreComponentCollection & | scoreBreakdown, | |||
ScoreComponentCollection * | estimatedScores = NULL | |||
) | const [virtual] |
Implements Moses::FeatureFunction.
Definition at line 287 of file SoftSourceSyntacticConstraintsFeature.cpp.
References StringPiece::as_string(), begin, Moses::AlignmentInfo::begin(), Moses::AlignmentInfo::end(), FEATUREVERBOSE, Moses::TargetPhrase::GetAlignNonTerm(), Moses::ChartCellLabel::GetCoverage(), Moses::Range::GetEndPos(), GetLabelPairProbabilities(), Moses::TreeInput::GetLabelSet(), Moses::SourceLabelsPhraseProperty::GetNumberOfNonTerminals(), Moses::TargetPhrase::GetProperty(), Moses::TargetPhrase::GetRuleSource(), Moses::FeatureFunction::GetScoreProducerDescription(), Moses::Phrase::GetSize(), Moses::SourceLabelsPhraseProperty::GetSourceLabelItems(), Moses::Range::GetStartPos(), Moses::Factor::GetString(), Moses::TargetPhrase::GetTargetLHS(), Moses::SourceLabelsPhraseProperty::GetTotalCount(), Moses::Phrase::GetWord(), Moses::InputPath::GetWordsRange(), IFFEATUREVERBOSE, Moses::Word::IsNonTerminal(), Moses::Word::IsOOV(), m_coreSourceLabels, m_floor, m_GlueTopLabel, m_noMismatches, Moses::FeatureFunction::m_numScoreComponents, Moses::FeatureFunction::m_options, m_sourceLabelIndexesByFactor, m_sourceLabels, m_sourceLabelsByIndex, m_sourceLabelsByIndex_LHS_0, m_sourceLabelsByIndex_LHS_1, m_sourceLabelsByIndex_RHS_0, m_sourceLabelsByIndex_RHS_1, m_targetSourceLHSJointCountFile, m_useCoreSourceLabels, m_useLogprobs, m_useSparse, m_useSparseLabelPairs, Moses::ScoreComponentCollection::PlusEquals(), range, totalCount, Moses::TransformScore(), and UTIL_THROW_IF2.
std::pair< float, float > Moses::SoftSourceSyntacticConstraintsFeature::GetLabelPairProbabilities | ( | const Factor * | target, | |
const size_t | source | |||
) | const [protected] |
Definition at line 633 of file SoftSourceSyntacticConstraintsFeature.cpp.
References m_floor, and m_labelPairProbabilities.
Referenced by EvaluateWithSourceContext().
bool Moses::SoftSourceSyntacticConstraintsFeature::IsUseable | ( | const FactorMask & | mask | ) | const [inline, virtual] |
Implements Moses::FeatureFunction.
Definition at line 28 of file SoftSourceSyntacticConstraintsFeature.h.
void Moses::SoftSourceSyntacticConstraintsFeature::Load | ( | AllOptions::ptr const & | opts | ) | [virtual] |
override to load model files
Reimplemented from Moses::FeatureFunction.
Definition at line 91 of file SoftSourceSyntacticConstraintsFeature.cpp.
References LoadCoreSourceLabelSet(), LoadSourceLabelSet(), LoadTargetSourceLeftHandSideJointCountFile(), m_coreSourceLabelSetFile, Moses::FeatureFunction::m_options, and m_targetSourceLHSJointCountFile.
void Moses::SoftSourceSyntacticConstraintsFeature::LoadCoreSourceLabelSet | ( | ) | [protected] |
Definition at line 174 of file SoftSourceSyntacticConstraintsFeature.cpp.
References FEATUREVERBOSE, FEATUREVERBOSE2, LoadLabelSet(), m_coreSourceLabels, and m_coreSourceLabelSetFile.
Referenced by Load().
void Moses::SoftSourceSyntacticConstraintsFeature::LoadLabelSet | ( | std::string & | filename, | |
boost::unordered_set< size_t > & | labelSet | |||
) | [protected] |
Definition at line 182 of file SoftSourceSyntacticConstraintsFeature.cpp.
References Moses::InputFileStream::Close(), FEATUREVERBOSE, and m_sourceLabels.
Referenced by LoadCoreSourceLabelSet().
void Moses::SoftSourceSyntacticConstraintsFeature::LoadSourceLabelSet | ( | ) | [protected] |
Definition at line 104 of file SoftSourceSyntacticConstraintsFeature.cpp.
References Moses::FactorCollection::AddFactor(), Moses::InputFileStream::Close(), FEATUREVERBOSE, FEATUREVERBOSE2, Moses::FeatureFunction::GetScoreProducerDescription(), index, Moses::FactorCollection::Instance(), m_GlueTopLabel, m_sourceLabelIndexesByFactor, m_sourceLabels, m_sourceLabelsByIndex, m_sourceLabelsByIndex_LHS_0, m_sourceLabelsByIndex_LHS_1, m_sourceLabelsByIndex_RHS_0, m_sourceLabelsByIndex_RHS_1, m_sourceLabelSetFile, UTIL_THROW2, and UTIL_THROW_IF2.
Referenced by Load().
void Moses::SoftSourceSyntacticConstraintsFeature::LoadTargetSourceLeftHandSideJointCountFile | ( | ) | [protected] |
Definition at line 205 of file SoftSourceSyntacticConstraintsFeature.cpp.
References Moses::FactorCollection::AddFactor(), Moses::InputFileStream::Close(), count, FEATUREVERBOSE, FEATUREVERBOSE2, Moses::FeatureFunction::GetScoreProducerDescription(), index, init(), Moses::FactorCollection::Instance(), m_labelPairProbabilities, m_sourceLabels, m_targetSourceLHSJointCountFile, MosesTraining::sourceLHSCounts, and UTIL_THROW_IF2.
Referenced by Load().
void Moses::SoftSourceSyntacticConstraintsFeature::SetParameter | ( | const std::string & | key, | |
const std::string & | value | |||
) | [virtual] |
Reimplemented from Moses::FeatureFunction.
Definition at line 69 of file SoftSourceSyntacticConstraintsFeature.cpp.
References m_coreSourceLabelSetFile, m_noMismatches, m_sourceLabelSetFile, m_targetSourceLHSJointCountFile, m_useCoreSourceLabels, m_useLogprobs, m_useSparse, m_useSparseLabelPairs, and Moses::Scan< bool >().
boost::unordered_set<size_t> Moses::SoftSourceSyntacticConstraintsFeature::m_coreSourceLabels [protected] |
Definition at line 84 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadCoreSourceLabelSet().
std::string Moses::SoftSourceSyntacticConstraintsFeature::m_coreSourceLabelSetFile [protected] |
Definition at line 68 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by Load(), LoadCoreSourceLabelSet(), and SetParameter().
float Moses::SoftSourceSyntacticConstraintsFeature::m_floor [protected] |
Definition at line 76 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and GetLabelPairProbabilities().
size_t Moses::SoftSourceSyntacticConstraintsFeature::m_GlueTopLabel [protected] |
Definition at line 86 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
boost::unordered_map<const Factor*, std::vector< std::pair<float,float> >* > Moses::SoftSourceSyntacticConstraintsFeature::m_labelPairProbabilities [protected] |
Definition at line 90 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by GetLabelPairProbabilities(), LoadTargetSourceLeftHandSideJointCountFile(), and ~SoftSourceSyntacticConstraintsFeature().
bool Moses::SoftSourceSyntacticConstraintsFeature::m_noMismatches [protected] |
Definition at line 75 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), SetParameter(), and SoftSourceSyntacticConstraintsFeature().
float Moses::SoftSourceSyntacticConstraintsFeature::m_smoothingWeight [protected] |
Definition at line 92 of file SoftSourceSyntacticConstraintsFeature.h.
boost::unordered_map<const Factor*,size_t> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelIndexesByFactor [protected] |
Definition at line 85 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
boost::unordered_map<std::string,size_t> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabels [protected] |
Definition at line 78 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), LoadLabelSet(), LoadSourceLabelSet(), and LoadTargetSourceLeftHandSideJointCountFile().
std::vector<std::string> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelsByIndex [protected] |
Definition at line 79 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
std::vector<std::string> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelsByIndex_LHS_0 [protected] |
Definition at line 83 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
std::vector<std::string> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelsByIndex_LHS_1 [protected] |
Definition at line 82 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
std::vector<std::string> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelsByIndex_RHS_0 [protected] |
Definition at line 81 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
std::vector<std::string> Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelsByIndex_RHS_1 [protected] |
Definition at line 80 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), and LoadSourceLabelSet().
std::string Moses::SoftSourceSyntacticConstraintsFeature::m_sourceLabelSetFile [protected] |
Definition at line 62 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by LoadSourceLabelSet(), and SetParameter().
std::string Moses::SoftSourceSyntacticConstraintsFeature::m_targetSourceLHSJointCountFile [protected] |
Definition at line 69 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), Load(), LoadTargetSourceLeftHandSideJointCountFile(), and SetParameter().
std::string Moses::SoftSourceSyntacticConstraintsFeature::m_unknownLeftHandSideFile [protected] |
Definition at line 70 of file SoftSourceSyntacticConstraintsFeature.h.
boost::unordered_map<size_t,float> Moses::SoftSourceSyntacticConstraintsFeature::m_unknownLHSProbabilities [protected] |
Definition at line 91 of file SoftSourceSyntacticConstraintsFeature.h.
float Moses::SoftSourceSyntacticConstraintsFeature::m_unseenLHSSmoothingFactorForUnknowns [protected] |
Definition at line 93 of file SoftSourceSyntacticConstraintsFeature.h.
bool Moses::SoftSourceSyntacticConstraintsFeature::m_useCoreSourceLabels [protected] |
Definition at line 71 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), SetParameter(), and SoftSourceSyntacticConstraintsFeature().
bool Moses::SoftSourceSyntacticConstraintsFeature::m_useLogprobs [protected] |
Definition at line 72 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), SetParameter(), and SoftSourceSyntacticConstraintsFeature().
bool Moses::SoftSourceSyntacticConstraintsFeature::m_useSparse [protected] |
Definition at line 73 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), SetParameter(), and SoftSourceSyntacticConstraintsFeature().
bool Moses::SoftSourceSyntacticConstraintsFeature::m_useSparseLabelPairs [protected] |
Definition at line 74 of file SoftSourceSyntacticConstraintsFeature.h.
Referenced by EvaluateWithSourceContext(), SetParameter(), and SoftSourceSyntacticConstraintsFeature().