templatize node

This commit is contained in:
Hieu Hoang 2016-04-27 21:01:22 +04:00
parent 15a02676ed
commit e076d0c3df
3 changed files with 11 additions and 5 deletions

View File

@ -18,7 +18,7 @@ class System;
namespace PtMem
{
template<class WORD>
template<class WORD, class SP, class TP>
class Node
{
public:
@ -33,7 +33,7 @@ public:
~Node()
{}
void AddRule(Phrase<WORD> &source, TargetPhrase<Moses2::Word> *target)
void AddRule(SP &source, TP *target)
{
AddRule(source, target, 0);
}
@ -105,7 +105,7 @@ protected:
Phrase<WORD> *m_source;
std::vector<TargetPhrase<WORD>*> *m_unsortedTPS;
Node &AddRule(Phrase<WORD> &source, TargetPhrase<WORD> *target, size_t pos)
Node &AddRule(SP &source, TP *target, size_t pos)
{
if (pos == source.GetSize()) {
if (m_unsortedTPS == NULL) {

View File

@ -116,11 +116,13 @@ void PhraseTableMemory::Load(System &system)
m_rootPb.SortAndPrune(m_tableLimit, systemPool, system);
cerr << "root=" << &m_rootPb << endl;
/*
BOOST_FOREACH(const PtMem::Node<Word>::Children::value_type &valPair, m_rootPb.GetChildren()) {
const Word &word = valPair.first;
cerr << word << " ";
}
cerr << endl;
*/
}
TargetPhrases* PhraseTableMemory::Lookup(const Manager &mgr, MemPool &pool,

View File

@ -10,14 +10,18 @@
#include "../../legacy/Util2.h"
#include "../../SCFG/InputPath.h"
#include "Node.h"
#include "../../PhraseBased/PhraseImpl.h"
#include "../../PhraseBased/TargetPhraseImpl.h"
#include "../../SCFG/PhraseImpl.h"
#include "../../SCFG/TargetPhraseImpl.h"
namespace Moses2
{
class PhraseTableMemory: public PhraseTable
{
typedef PtMem::Node<Word> PBNODE;
typedef PtMem::Node<SCFG::Word> SCFGNODE;
typedef PtMem::Node<Word, PhraseImpl, TargetPhraseImpl> PBNODE;
typedef PtMem::Node<SCFG::Word, SCFG::PhraseImpl, SCFG::TargetPhraseImpl> SCFGNODE;
//////////////////////////////////////
class ActiveChartEntryMem : public SCFG::ActiveChartEntry