File size: 1,260 Bytes
158b61b |
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 54 55 56 57 58 59 60 |
/*
* InputPath.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
#include <sstream>
#include <boost/foreach.hpp>
#include "InputPath.h"
#include "TargetPhrases.h"
#include "../TranslationModel/PhraseTable.h"
using namespace std;
namespace Moses2
{
InputPath::InputPath(MemPool &pool, const SubPhrase<Moses2::Word> &subPhrase,
const Range &range, size_t numPt, const InputPath *prefixPath)
:InputPathBase(pool, range, numPt, prefixPath)
,m_numRules(0)
,subPhrase(subPhrase)
{
targetPhrases = pool.Allocate<const TargetPhrases*>(numPt);
Init<const TargetPhrases*>(targetPhrases, numPt, NULL);
}
InputPath::~InputPath()
{
// TODO Auto-generated destructor stub
}
void InputPath::AddTargetPhrases(const PhraseTable &pt,
const TargetPhrases *tps)
{
size_t ptInd = pt.GetPtInd();
targetPhrases[ptInd] = tps;
if (tps) {
m_numRules += tps->GetSize();
}
}
const TargetPhrases *InputPath::GetTargetPhrases(const PhraseTable &pt) const
{
size_t ptInd = pt.GetPtInd();
return targetPhrases[ptInd];
}
std::string InputPath::Debug(const System &system) const
{
stringstream out;
out << range << " " << flush;
out << subPhrase.Debug(system);
return out.str();
}
}
|