This commit is contained in:
Hieu Hoang 2016-03-22 17:51:39 +00:00
parent cc599e7149
commit 3fe5574a95
3 changed files with 4 additions and 71 deletions

View File

@ -195,50 +195,6 @@ void LexicalReordering::EvaluateWhenApplied(const ManagerBase &mgr,
prevStateCast.Expand(mgr.system, *this, hypo, m_PhraseTableInd, scores, state);
}
void LexicalReordering::EvaluateWhenAppliedPB(const ManagerBase &mgr,
const Hypothesis &hypo,
const FFState &prevState,
Scores &scores,
FFState &state) const
{
const PhraseBasedReorderingState &prevStateCast = static_cast<const PhraseBasedReorderingState&>(prevState);
PhraseBasedReorderingState &stateCast = static_cast<PhraseBasedReorderingState&>(state);
const Range &currRange = hypo.GetInputPath().range;
stateCast.path = &hypo.GetInputPath();
stateCast.targetPhrase = &hypo.GetTargetPhrase();
// calc orientation
size_t orientation;
const Range *prevRange = &prevStateCast.path->range;
assert(prevRange);
if (prevRange->GetStartPos() == NOT_FOUND) {
orientation = GetOrientation(currRange);
}
else {
orientation = GetOrientation(*prevRange, currRange);
}
// backwards
const TargetPhrase &target = hypo.GetTargetPhrase();
const SCORE *values = (const SCORE *) target.ffData[m_PhraseTableInd];
if (values) {
scores.PlusEquals(mgr.system, *this, values[orientation], orientation);
}
// forwards
if (prevRange->GetStartPos() != NOT_FOUND) {
const TargetPhrase &prevTarget = *prevStateCast.targetPhrase;
const SCORE *prevValues = (const SCORE *) prevTarget.ffData[m_PhraseTableInd];
if (prevValues) {
scores.PlusEquals(mgr.system, *this, prevValues[orientation + 3], orientation + 3);
}
}
}
const LexicalReordering::Values *LexicalReordering::GetValues(const Phrase &source, const Phrase &target) const
{
Key key(&source, &target);
@ -252,14 +208,4 @@ const LexicalReordering::Values *LexicalReordering::GetValues(const Phrase &sour
}
}
// hiero type //////////////////////////////
void LexicalReordering::EvaluateWhenAppliedHier(const ManagerBase &mgr,
const Hypothesis &hypo,
const FFState &prevState,
Scores &scores,
FFState &state) const
{
}
} /* namespace Moses2 */

View File

@ -102,23 +102,6 @@ protected:
Coll *m_coll;
const Values *GetValues(const Phrase &source, const Phrase &target) const;
// phrase-based model
void EvaluateWhenAppliedPB(const ManagerBase &mgr,
const Hypothesis &hypo,
const FFState &prevState,
Scores &scores,
FFState &state) const;
size_t GetOrientation(Range const& cur) const;
size_t GetOrientation(Range const& prev, Range const& cur) const;
// hier model
void EvaluateWhenAppliedHier(const ManagerBase &mgr,
const Hypothesis &hypo,
const FFState &prevState,
Scores &scores,
FFState &state) const;
};
} /* namespace Moses2 */

View File

@ -422,6 +422,8 @@ HReorderingBackwardState::
Expand(const TranslationOption& topt, const InputType& input,
ScoreComponentCollection* scores) const
{
std::cerr << "HReorderingBackwardState" << std::endl;
HReorderingBackwardState* nextState;
nextState = new HReorderingBackwardState(this, topt, m_reoStack);
Range swrange = topt.GetSourceWordsRange();
@ -492,6 +494,8 @@ HReorderingForwardState::
Expand(TranslationOption const& topt, InputType const& input,
ScoreComponentCollection* scores) const
{
std::cerr << "HReorderingForwardState" << std::endl;
const Range cur = topt.GetSourceWordsRange();
// keep track of the current coverage ourselves so we don't need the hypothesis
Bitmap cov(m_coverage, cur);