File size: 1,345 Bytes
158b61b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
#include "HReorderingBackwardState.h"
namespace Moses
{
///////////////////////////
//HierarchicalReorderingBackwardState
HReorderingBackwardState::
HReorderingBackwardState(const HReorderingBackwardState *prev,
const TranslationOption &topt,
ReorderingStack reoStack)
: LRState(prev, topt), m_reoStack(reoStack)
{ }
HReorderingBackwardState::
HReorderingBackwardState(const LRModel &config, size_t offset)
: LRState(config, LRModel::Backward, offset)
{ }
size_t HReorderingBackwardState::hash() const
{
size_t ret = m_reoStack.hash();
return ret;
}
bool HReorderingBackwardState::operator==(const FFState& o) const
{
const HReorderingBackwardState& other
= static_cast<const HReorderingBackwardState&>(o);
bool ret = m_reoStack == other.m_reoStack;
return ret;
}
LRState*
HReorderingBackwardState::
Expand(const TranslationOption& topt, const InputType& input,
ScoreComponentCollection* scores) const
{
HReorderingBackwardState* nextState;
nextState = new HReorderingBackwardState(this, topt, m_reoStack);
Range swrange = topt.GetSourceWordsRange();
int reoDistance = nextState->m_reoStack.ShiftReduce(swrange);
ReorderingType reoType = m_configuration.GetOrientation(reoDistance);
CopyScores(scores, topt, input, reoType);
return nextState;
}
}
|