00001 #pragma once 00002 00003 #include <ostream> 00004 00005 #include "moses/FF/FFState.h" 00006 #include "moses/Phrase.h" 00007 #include "moses/Hypothesis.h" 00008 00009 namespace Moses 00010 { 00011 00015 class VWState : public FFState 00016 { 00017 public: 00018 // empty state, used only when VWState is ignored 00019 VWState(); 00020 00021 // used for construction of the initial VW state 00022 VWState(const Phrase &phrase); 00023 00024 // continue from previous VW state with a new hypothesis 00025 VWState(const VWState &prevState, const Hypothesis &curHypo); 00026 00027 virtual bool operator==(const FFState& o) const; 00028 00029 inline virtual size_t hash() const { 00030 return m_hash; 00031 } 00032 00033 inline const Phrase &GetPhrase() const { 00034 return m_phrase; 00035 } 00036 00037 inline size_t GetSpanStart() const { 00038 return m_spanStart; 00039 } 00040 00041 inline size_t GetSpanEnd() const { 00042 return m_spanEnd; 00043 } 00044 00045 private: 00046 void ComputeHash(); 00047 00048 Phrase m_phrase; 00049 size_t m_spanStart, m_spanEnd; 00050 size_t m_hash; 00051 }; 00052 00053 // how to print a VW state 00054 std::ostream &operator<<(std::ostream &out, const VWState &state); 00055 00056 }