00001 /* 00002 * ConsistentPhrase.h 00003 * 00004 * Created on: 20 Feb 2014 00005 * Author: hieu 00006 */ 00007 00008 #pragma once 00009 00010 #include <cassert> 00011 #include <vector> 00012 #include <iostream> 00013 #include "moses/TypeDef.h" 00014 #include "NonTerm.h" 00015 00016 class ConsistentPhrase 00017 { 00018 public: 00019 typedef std::vector<NonTerm> NonTerms; 00020 00021 std::vector<int> corners; 00022 00023 ConsistentPhrase(const ConsistentPhrase ©); // do not implement 00024 ConsistentPhrase(int sourceStart, int sourceEnd, 00025 int targetStart, int targetEnd, 00026 const Parameter ¶ms); 00027 00028 virtual ~ConsistentPhrase(); 00029 00030 int GetWidth(Moses::FactorDirection direction) const { 00031 return (direction == Moses::Input) ? corners[1] - corners[0] + 1 : corners[3] - corners[2] + 1; 00032 } 00033 00034 00035 void AddNonTerms(const std::string &source, 00036 const std::string &target); 00037 const NonTerms &GetNonTerms() const { 00038 return m_nonTerms; 00039 } 00040 const NonTerm &GetHieroNonTerm() const { 00041 return m_hieroNonTerm; 00042 } 00043 00044 bool TargetOverlap(const ConsistentPhrase &other) const; 00045 00046 bool operator<(const ConsistentPhrase &other) const; 00047 00048 std::string Debug() const; 00049 00050 protected: 00051 NonTerms m_nonTerms; 00052 NonTerm m_hieroNonTerm; 00053 }; 00054