00001 /* 00002 * Word.cpp 00003 * 00004 * Created on: 18 Feb 2014 00005 * Author: s0565741 00006 */ 00007 #include <limits> 00008 #include "Word.h" 00009 #include "moses/Util.h" 00010 00011 using namespace std; 00012 00013 Word::Word(int pos, const std::string &str) 00014 :m_pos(pos) 00015 ,m_str(str) 00016 { 00017 // TODO Auto-generated constructor stub 00018 00019 } 00020 00021 Word::~Word() 00022 { 00023 // TODO Auto-generated destructor stub 00024 } 00025 00026 void Word::AddAlignment(const Word *other) 00027 { 00028 m_alignment.insert(other); 00029 } 00030 00031 std::set<int> Word::GetAlignmentIndex() const 00032 { 00033 std::set<int> ret; 00034 00035 std::set<const Word *>::const_iterator iter; 00036 for (iter = m_alignment.begin(); iter != m_alignment.end(); ++iter) { 00037 const Word &otherWord = **iter; 00038 int otherPos = otherWord.GetPos(); 00039 ret.insert(otherPos); 00040 } 00041 00042 return ret; 00043 } 00044 00045 void Word::Output(std::ostream &out) const 00046 { 00047 out << m_str; 00048 } 00049 00050 std::string Word::Debug() const 00051 { 00052 return m_str; 00053 } 00054 00055 int Word::CompareString(const Word &other) const 00056 { 00057 return m_str.compare(other.m_str); 00058 } 00059 00060 std::string Word::GetString(int factor) const 00061 { 00062 vector<string> toks; 00063 Moses::Tokenize(toks, m_str, "|"); 00064 00065 assert(factor < toks.size()); 00066 return toks[factor]; 00067 } 00068 00069