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

56 lines
1.0 KiB
C++
Raw Normal View History

2015-10-24 01:19:31 +03:00
/*
* InputPath.cpp
*
* Created on: 23 Oct 2015
* Author: hieu
*/
#include <boost/foreach.hpp>
2015-10-24 01:19:31 +03:00
#include "InputPath.h"
2015-11-04 16:09:53 +03:00
#include "TranslationModel/PhraseTable.h"
2015-10-24 01:19:31 +03:00
2015-12-10 23:49:30 +03:00
namespace Moses2
{
2016-01-14 00:47:16 +03:00
InputPath::InputPath(MemPool &pool,
const SubPhrase &subPhrase,
2015-11-11 18:08:47 +03:00
const Range &range,
2015-11-06 22:06:41 +03:00
size_t numPt,
const InputPath *prefixPath)
:subPhrase(subPhrase)
,range(range)
,prefixPath(prefixPath)
2015-12-08 19:01:37 +03:00
,m_isUsed(false)
2015-10-24 01:19:31 +03:00
{
2016-01-14 00:47:16 +03:00
targetPhrases = pool.Allocate<const TargetPhrases*>(numPt);
Init<const TargetPhrases*>(targetPhrases, numPt, NULL);
2015-10-24 01:19:31 +03:00
}
InputPath::~InputPath() {
// TODO Auto-generated destructor stub
}
void InputPath::AddTargetPhrases(const PhraseTable &pt, const TargetPhrases *tps)
2015-10-26 19:14:17 +03:00
{
size_t ptInd = pt.GetPtInd();
targetPhrases[ptInd] = tps;
2015-10-26 19:32:47 +03:00
2015-12-08 19:01:37 +03:00
if (tps && tps->GetSize()) {
m_isUsed = true;
}
}
2015-12-18 01:07:19 +03:00
2016-01-13 19:46:23 +03:00
const TargetPhrases *InputPath::GetTargetPhrases(const PhraseTable &pt) const
{
size_t ptInd = pt.GetPtInd();
return targetPhrases[ptInd];
}
2015-10-26 19:32:47 +03:00
std::ostream& operator<<(std::ostream &out, const InputPath &obj)
{
2015-11-06 22:06:41 +03:00
out << obj.range << " " << obj.subPhrase;
2015-10-26 19:32:47 +03:00
return out;
}
2015-12-10 23:49:30 +03:00
}