mosesdecoder/contrib/other-builds/moses2/Phrase.cpp

52 lines
837 B
C++
Raw Normal View History

2015-10-23 22:53:36 +03:00
/*
* Phrase.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
2015-10-24 01:19:31 +03:00
#include <vector>
2015-10-23 22:53:36 +03:00
#include "Phrase.h"
#include "Word.h"
2015-10-24 01:19:31 +03:00
#include "moses/Util.h"
using namespace std;
Phrase *Phrase::CreateFromString(const std::string &str)
{
vector<string> toks = Moses::Tokenize(str);
size_t size = toks.size();
Phrase *ret = new Phrase(size);
for (size_t i = 0; i < size; ++i) {
Word &word = (*ret)[i];
}
return ret;
}
2015-10-23 22:53:36 +03:00
Phrase::Phrase(size_t size)
{
m_words = new Word[size];
}
Phrase::~Phrase() {
delete m_words;
}
2015-10-24 01:19:31 +03:00
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)
{
}