mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-08 04:27:53 +03:00
separate out InputPath
This commit is contained in:
parent
2c0290e9e0
commit
ff17678195
52
contrib/other-builds/moses2/PhraseBased/InputPath.cpp
Normal file
52
contrib/other-builds/moses2/PhraseBased/InputPath.cpp
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* InputPath.cpp
|
||||||
|
*
|
||||||
|
* Created on: 23 Oct 2015
|
||||||
|
* Author: hieu
|
||||||
|
*/
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
#include "InputPath.h"
|
||||||
|
#include "../TranslationModel/PhraseTable.h"
|
||||||
|
|
||||||
|
namespace Moses2
|
||||||
|
{
|
||||||
|
InputPath::InputPath(MemPool &pool,
|
||||||
|
const SubPhrase &subPhrase,
|
||||||
|
const Range &range,
|
||||||
|
size_t numPt,
|
||||||
|
const InputPath *prefixPath)
|
||||||
|
:InputPathBase(pool, subPhrase, range, numPt, prefixPath)
|
||||||
|
,m_isUsed(false)
|
||||||
|
{
|
||||||
|
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 && tps->GetSize()) {
|
||||||
|
m_isUsed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const TargetPhrases *InputPath::GetTargetPhrases(const PhraseTable &pt) const
|
||||||
|
{
|
||||||
|
size_t ptInd = pt.GetPtInd();
|
||||||
|
return targetPhrases[ptInd];
|
||||||
|
}
|
||||||
|
|
||||||
|
std::ostream& operator<<(std::ostream &out, const InputPath &obj)
|
||||||
|
{
|
||||||
|
out << obj.range << " " << obj.subPhrase;
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
38
contrib/other-builds/moses2/PhraseBased/InputPath.h
Normal file
38
contrib/other-builds/moses2/PhraseBased/InputPath.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* InputPath.h
|
||||||
|
*
|
||||||
|
* Created on: 23 Oct 2015
|
||||||
|
* Author: hieu
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INPUTPATH_H_
|
||||||
|
#define INPUTPATH_H_
|
||||||
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
#include "../InputPathBase.h"
|
||||||
|
|
||||||
|
namespace Moses2
|
||||||
|
{
|
||||||
|
|
||||||
|
class InputPath : public InputPathBase
|
||||||
|
{
|
||||||
|
friend std::ostream& operator<<(std::ostream &, const InputPath &);
|
||||||
|
public:
|
||||||
|
const TargetPhrases** targetPhrases;
|
||||||
|
|
||||||
|
InputPath(MemPool &pool, const SubPhrase &subPhrase, const Range &range, size_t numPt, const InputPath *prefixPath);
|
||||||
|
virtual ~InputPath();
|
||||||
|
|
||||||
|
void AddTargetPhrases(const PhraseTable &pt, const TargetPhrases *tps);
|
||||||
|
const TargetPhrases *GetTargetPhrases(const PhraseTable &pt) const;
|
||||||
|
|
||||||
|
inline bool IsUsed() const
|
||||||
|
{ return m_isUsed; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
bool m_isUsed;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* INPUTPATH_H_ */
|
Loading…
Reference in New Issue
Block a user