File size: 1,322 Bytes
fd49381 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
/*
* TargetPhraseImpl.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
#include <sstream>
#include <stdlib.h>
#include "TargetPhraseImpl.h"
#include "../Scores.h"
#include "../System.h"
#include "../MemPool.h"
#include "Manager.h"
using namespace std;
namespace Moses2
{
TargetPhraseImpl *TargetPhraseImpl::CreateFromString(MemPool &pool,
const PhraseTable &pt, const System &system, const std::string &str)
{
FactorCollection &vocab = system.GetVocab();
vector<string> toks = Tokenize(str);
size_t size = toks.size();
TargetPhraseImpl *ret =
new (pool.Allocate<TargetPhraseImpl>()) TargetPhraseImpl(pool, pt, system,
size);
ret->PhraseImplTemplate<Word>::CreateFromString(vocab, system, toks);
return ret;
}
TargetPhraseImpl::TargetPhraseImpl(MemPool &pool, const PhraseTable &pt,
const System &system, size_t size)
:Moses2::TargetPhrase<Moses2::Word>(pool, pt, system, size)
{
m_scores = new (pool.Allocate<Scores>()) Scores(system, pool,
system.featureFunctions.GetNumScores());
size_t numWithPtData = system.featureFunctions.GetWithPhraseTableInd().size();
ffData = new (pool.Allocate<void *>(numWithPtData)) void *[numWithPtData];
}
TargetPhraseImpl::~TargetPhraseImpl()
{
// TODO Auto-generated destructor stub
}
}
|