mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-10-06 00:08:52 +03:00
use InputPathBase
This commit is contained in:
parent
00ada25b73
commit
0e86993425
@ -8,7 +8,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include "PhraseBased/InputPath.h"
|
||||
#include "MemPool.h"
|
||||
#include "legacy/Matrix.h"
|
||||
|
||||
@ -18,10 +17,11 @@ namespace Moses2
|
||||
class Sentence;
|
||||
class System;
|
||||
class ManagerBase;
|
||||
class InputPathBase;
|
||||
|
||||
class InputPathsBase
|
||||
{
|
||||
typedef std::vector<InputPath*> Coll;
|
||||
typedef std::vector<InputPathBase*> Coll;
|
||||
public:
|
||||
InputPathsBase() {}
|
||||
virtual ~InputPathsBase();
|
||||
@ -46,12 +46,12 @@ public:
|
||||
|
||||
virtual void Init(const Sentence &input, const ManagerBase &mgr) = 0;
|
||||
|
||||
const Matrix<InputPath*> &GetMatrix() const
|
||||
const Matrix<InputPathBase*> &GetMatrix() const
|
||||
{ return *m_matrix; }
|
||||
|
||||
protected:
|
||||
Coll m_inputPaths;
|
||||
Matrix<InputPath*> *m_matrix;
|
||||
Matrix<InputPathBase*> *m_matrix;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ void Search::PostDecode(size_t stackInd)
|
||||
MemPool &pool = mgr.GetPool();
|
||||
|
||||
const InputPaths &paths = mgr.GetInputPaths();
|
||||
const Matrix<InputPath*> &pathMatrix = paths.GetMatrix();
|
||||
const Matrix<InputPathBase*> &pathMatrix = paths.GetMatrix();
|
||||
size_t inputSize = pathMatrix.GetRows();
|
||||
size_t numPaths = pathMatrix.GetCols();
|
||||
|
||||
@ -168,7 +168,7 @@ void Search::PostDecode(size_t stackInd)
|
||||
// create edges to next hypos from existing hypos
|
||||
for (size_t startPos = firstGap; startPos < inputSize; ++startPos) {
|
||||
for (size_t pathInd = 0; pathInd < numPaths; ++pathInd) {
|
||||
const InputPath *path = pathMatrix.GetValue(startPos, pathInd);
|
||||
const InputPath *path = static_cast<const InputPath*>(pathMatrix.GetValue(startPos, pathInd));
|
||||
|
||||
if (path == NULL) {
|
||||
break;
|
||||
|
@ -14,7 +14,7 @@ InputPath::InputPath(MemPool &pool,
|
||||
const SubPhrase &subPhrase,
|
||||
const Range &range,
|
||||
size_t numPt,
|
||||
const InputPath *prefixPath)
|
||||
const InputPathBase *prefixPath)
|
||||
:InputPathBase(pool, subPhrase, range, numPt, prefixPath)
|
||||
,m_isUsed(false)
|
||||
{
|
||||
|
@ -20,7 +20,7 @@ class InputPath : public InputPathBase
|
||||
public:
|
||||
const TargetPhrases** targetPhrases;
|
||||
|
||||
InputPath(MemPool &pool, const SubPhrase &subPhrase, const Range &range, size_t numPt, const InputPath *prefixPath);
|
||||
InputPath(MemPool &pool, const SubPhrase &subPhrase, const Range &range, size_t numPt, const InputPathBase *prefixPath);
|
||||
virtual ~InputPath();
|
||||
|
||||
void AddTargetPhrases(const PhraseTable &pt, const TargetPhrases *tps);
|
||||
|
@ -23,7 +23,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
|
||||
size_t size = input.GetSize();
|
||||
size_t maxLength = min(size, mgr.system.maxPhraseLength);
|
||||
|
||||
m_matrix = new (pool.Allocate< Matrix<InputPath*> >()) Matrix<InputPath*>(pool, size, maxLength);
|
||||
m_matrix = new (pool.Allocate< Matrix<InputPathBase*> >()) Matrix<InputPathBase*>(pool, size, maxLength);
|
||||
m_matrix->Init(NULL);
|
||||
|
||||
// create blank path for initial hypo
|
||||
@ -33,7 +33,7 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
|
||||
|
||||
// create normal paths of subphrases through the sentence
|
||||
for (size_t startPos = 0; startPos < size; ++startPos) {
|
||||
const InputPath *prefixPath = NULL;
|
||||
const InputPathBase *prefixPath = NULL;
|
||||
|
||||
for (size_t phaseSize = 1; phaseSize <= maxLength; ++phaseSize) {
|
||||
size_t endPos = startPos + phaseSize - 1;
|
||||
|
@ -68,9 +68,9 @@ void SearchNormal::Decode(size_t stackInd)
|
||||
|
||||
const InputPaths &paths = mgr.GetInputPaths();
|
||||
|
||||
BOOST_FOREACH(const InputPath *path, paths) {
|
||||
BOOST_FOREACH(const InputPathBase *path, paths) {
|
||||
BOOST_FOREACH(const HypothesisBase *hypo, hypos) {
|
||||
Extend(*static_cast<const Hypothesis*>(hypo), *path);
|
||||
Extend(*static_cast<const Hypothesis*>(hypo), *static_cast<const InputPath*>(path));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,9 @@ void PhraseTable::SetParameter(const std::string& key, const std::string& value)
|
||||
|
||||
void PhraseTable::Lookup(const Manager &mgr, InputPaths &inputPaths) const
|
||||
{
|
||||
BOOST_FOREACH(InputPath *path, inputPaths) {
|
||||
BOOST_FOREACH(InputPathBase *pathBase, inputPaths) {
|
||||
InputPath *path = static_cast<InputPath*>(pathBase);
|
||||
|
||||
const SubPhrase &phrase = path->subPhrase;
|
||||
|
||||
TargetPhrases *tpsPtr = tpsPtr = Lookup(mgr, mgr.GetPool(), *path);
|
||||
|
@ -91,7 +91,8 @@ void ProbingPT::Load(System &system)
|
||||
|
||||
void ProbingPT::Lookup(const Manager &mgr, InputPaths &inputPaths) const
|
||||
{
|
||||
BOOST_FOREACH(InputPath *path, inputPaths) {
|
||||
BOOST_FOREACH(InputPathBase *pathBase, inputPaths) {
|
||||
InputPath *path = static_cast<InputPath*>(pathBase);
|
||||
TargetPhrases *tpsPtr;
|
||||
tpsPtr = Lookup(mgr, mgr.GetPool(), *path);
|
||||
path->AddTargetPhrases(*this, tpsPtr);
|
||||
|
@ -27,7 +27,8 @@ UnknownWordPenalty::~UnknownWordPenalty() {
|
||||
|
||||
void UnknownWordPenalty::Lookup(const Manager &mgr, InputPaths &inputPaths) const
|
||||
{
|
||||
BOOST_FOREACH(InputPath *path, inputPaths) {
|
||||
BOOST_FOREACH(InputPathBase *pathBase, inputPaths) {
|
||||
InputPath *path = static_cast<InputPath*>(pathBase);
|
||||
const SubPhrase &phrase = path->subPhrase;
|
||||
|
||||
TargetPhrases *tpsPtr;
|
||||
|
Loading…
Reference in New Issue
Block a user