00001 #include "HReorderingForwardState.h"
00002
00003 namespace Moses
00004 {
00005
00007
00008
00009 HReorderingForwardState::
00010 HReorderingForwardState(const LRModel &config,
00011 size_t size, size_t offset)
00012 : LRState(config, LRModel::Forward, offset)
00013 , m_first(true)
00014 , m_prevRange(NOT_FOUND,NOT_FOUND)
00015 , m_coverage(size)
00016 { }
00017
00018 HReorderingForwardState::
00019 HReorderingForwardState(const HReorderingForwardState *prev,
00020 const TranslationOption &topt)
00021 : LRState(prev, topt)
00022 , m_first(false)
00023 , m_prevRange(topt.GetSourceWordsRange())
00024 , m_coverage(prev->m_coverage, topt.GetSourceWordsRange())
00025 {
00026 }
00027
00028 size_t HReorderingForwardState::hash() const
00029 {
00030 size_t ret;
00031 ret = hash_value(m_prevRange);
00032 return ret;
00033 }
00034
00035 bool HReorderingForwardState::operator==(const FFState& o) const
00036 {
00037 if (&o == this) return true;
00038
00039 HReorderingForwardState const& other
00040 = static_cast<HReorderingForwardState const&>(o);
00041
00042 int compareScores = ((m_prevRange == other.m_prevRange)
00043 ? ComparePrevScores(other.m_prevOption)
00044 : (m_prevRange < other.m_prevRange) ? -1 : 1);
00045 return compareScores == 0;
00046 }
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062 LRState*
00063 HReorderingForwardState::
00064 Expand(TranslationOption const& topt, InputType const& input,
00065 ScoreComponentCollection* scores) const
00066 {
00067 const Range cur = topt.GetSourceWordsRange();
00068
00069 Bitmap cov(m_coverage, cur);
00070 if (!m_first) {
00071 LRModel::ReorderingType reoType;
00072 reoType = m_configuration.GetOrientation(m_prevRange,cur,cov);
00073 CopyScores(scores, topt, input, reoType);
00074 }
00075 return new HReorderingForwardState(this, topt);
00076 }
00077
00078 }