00001 /* 00002 * NonTerm.cpp 00003 * 00004 * Created on: 22 Feb 2014 00005 * Author: hieu 00006 */ 00007 00008 #include <sstream> 00009 #include "NonTerm.h" 00010 #include "Word.h" 00011 #include "ConsistentPhrase.h" 00012 #include "Parameter.h" 00013 00014 using namespace std; 00015 00016 NonTerm::NonTerm(const ConsistentPhrase &consistentPhrase, 00017 const std::string &source, 00018 const std::string &target) 00019 :m_consistentPhrase(&consistentPhrase) 00020 ,m_source(source) 00021 ,m_target(target) 00022 { 00023 // TODO Auto-generated constructor stub 00024 00025 } 00026 00027 NonTerm::~NonTerm() 00028 { 00029 // TODO Auto-generated destructor stub 00030 } 00031 00032 std::string NonTerm::Debug() const 00033 { 00034 stringstream out; 00035 out << m_source << m_target; 00036 out << m_consistentPhrase->Debug(); 00037 return out.str(); 00038 } 00039 00040 void NonTerm::Output(std::ostream &out) const 00041 { 00042 out << m_source << m_target; 00043 } 00044 00045 void NonTerm::Output(std::ostream &out, Moses::FactorDirection direction) const 00046 { 00047 out << GetLabel(direction); 00048 } 00049 00050 const std::string &NonTerm::GetLabel(Moses::FactorDirection direction) const 00051 { 00052 return (direction == Moses::Input) ? m_source : m_target; 00053 } 00054 00055 bool NonTerm::IsHiero(Moses::FactorDirection direction, const Parameter ¶ms) const 00056 { 00057 const std::string &label = NonTerm::GetLabel(direction); 00058 return label == params.hieroNonTerm; 00059 } 00060 00061 bool NonTerm::IsHiero(const Parameter ¶ms) const 00062 { 00063 return IsHiero(Moses::Input, params) && IsHiero(Moses::Output, params); 00064 } 00065 00066 int NonTerm::GetWidth(Moses::FactorDirection direction) const 00067 { 00068 return GetConsistentPhrase().GetWidth(direction); 00069 }