/* * Phrase.cpp * * Created on: 23 Oct 2015 * Author: hieu */ #include #include "Phrase.h" #include "Word.h" #include "Vocab.h" #include "moses/Util.h" #include "util/pool.hh" using namespace std; Phrase *Phrase::CreateFromString(util::Pool &pool, const std::string &str) { vector toks = Moses::Tokenize(str); size_t size = toks.size(); Phrase *ret; ret = new (pool.Allocate()) Phrase(pool, size); ret->CreateFromString(toks); return ret; } void Phrase::CreateFromString(const std::vector &toks) { for (size_t i = 0; i < m_size; ++i) { Word &word = (*this)[i]; } } Phrase::Phrase(util::Pool &pool, size_t size) :m_size(size) { m_words = new (pool.Allocate(size)) Word[size]; } Phrase::~Phrase() { delete[] m_words; } SubPhrase Phrase::GetSubPhrase(size_t start, size_t end) const { SubPhrase ret(*this, start, end); return ret; } //////////////////////////////////////////////////////////// SubPhrase::SubPhrase(const Phrase &origPhrase, size_t start, size_t end) :m_origPhrase(origPhrase) ,m_start(start) ,m_end(end) { }