00001 00002 #pragma once 00003 00004 #include "moses/PP/PhraseProperty.h" 00005 #include "util/exception.hh" 00006 #include <string> 00007 #include <list> 00008 00009 namespace Moses 00010 { 00011 00012 class TargetPreferencesPhrasePropertyItem 00013 { 00014 friend class TargetPreferencesPhraseProperty; 00015 00016 public: 00017 TargetPreferencesPhrasePropertyItem() {}; 00018 00019 float GetTargetPreferencesRHSCount() const { 00020 return m_labelsRHSCount; 00021 }; 00022 00023 const std::list<size_t> &GetTargetPreferencesRHS() const { 00024 return m_labelsRHS; 00025 }; 00026 00027 const std::list< std::pair<size_t,float> > &GetTargetPreferencesLHSList() const { 00028 return m_labelsLHSList; 00029 }; 00030 00031 private: 00032 float m_labelsRHSCount; 00033 std::list<size_t> m_labelsRHS; // should be of size nNTs-1 (empty if initial rule, i.e. no right-hand side non-terminals) 00034 std::list< std::pair<size_t,float> > m_labelsLHSList; // list of left-hand sides for this right-hand side, with counts 00035 }; 00036 00037 00038 class TargetPreferencesPhraseProperty : public PhraseProperty 00039 { 00040 public: 00041 TargetPreferencesPhraseProperty() {}; 00042 00043 virtual void ProcessValue(const std::string &value); 00044 00045 size_t GetNumberOfNonTerminals() const { 00046 return m_nNTs; 00047 } 00048 00049 float GetTotalCount() const { 00050 return m_totalCount; 00051 } 00052 00053 const std::list<TargetPreferencesPhrasePropertyItem> &GetTargetPreferencesItems() const { 00054 return m_labelItems; 00055 }; 00056 00057 virtual const std::string *GetValueString() const { 00058 UTIL_THROW2("TargetPreferencesPhraseProperty: value string not available in this phrase property"); 00059 return NULL; 00060 }; 00061 00062 protected: 00063 00064 size_t m_nNTs; 00065 float m_totalCount; 00066 00067 std::list<TargetPreferencesPhrasePropertyItem> m_labelItems; 00068 }; 00069 00070 } // namespace Moses 00071