load dependent on search algo

This commit is contained in:
Hieu Hoang 2016-02-26 00:25:52 +00:00
parent 82c108b801
commit 3c35d733db
2 changed files with 34 additions and 9 deletions

View File

@ -16,6 +16,9 @@
#include "../InputPaths.h"
#include "../legacy/InputFileStream.h"
#include "../SCFG/PhraseImpl.h"
#include "../SCFG/TargetPhraseImpl.h"
using namespace std;
namespace Moses2
@ -30,12 +33,12 @@ PhraseTableMemory::Node::~Node()
{
}
void PhraseTableMemory::Node::AddRule(PhraseImpl &source, TargetPhrase *target)
void PhraseTableMemory::Node::AddRule(Phrase &source, TargetPhrase *target)
{
AddRule(source, target, 0);
}
PhraseTableMemory::Node &PhraseTableMemory::Node::AddRule(PhraseImpl &source, TargetPhrase *target, size_t pos)
PhraseTableMemory::Node &PhraseTableMemory::Node::AddRule(Phrase &source, TargetPhrase *target, size_t pos)
{
if (pos == source.GetSize()) {
if (m_unsortedTPS == NULL) {
@ -127,10 +130,32 @@ void PhraseTableMemory::Load(System &system)
assert(toks.size() >= 3);
//cerr << "line=" << line << endl;
PhraseImpl *source = PhraseImpl::CreateFromString(tmpSourcePool, vocab, system, toks[0]);
//cerr << "created soure" << endl;
TargetPhrase *target = TargetPhraseImpl::CreateFromString(systemPool, *this, system, toks[1]);
//cerr << "created target" << endl;
Phrase *source;
TargetPhrase *target;
switch (system.searchAlgorithm) {
case Normal:
case CubePruning:
case CubePruningPerMiniStack:
case CubePruningPerBitmap:
case CubePruningCardinalStack:
case CubePruningBitmapStack:
case CubePruningMiniStack:
source = PhraseImpl::CreateFromString(tmpSourcePool, vocab, system, toks[0]);
//cerr << "created soure" << endl;
target = TargetPhraseImpl::CreateFromString(systemPool, *this, system, toks[1]);
//cerr << "created target" << endl;
break;
case CYKPlus:
source = SCFG::PhraseImpl::CreateFromString(tmpSourcePool, vocab, system, toks[0]);
//cerr << "created soure" << endl;
target = SCFG::TargetPhraseImpl::CreateFromString(systemPool, *this, system, toks[1]);
//cerr << "created target" << endl;
break;
default:
abort();
}
target->GetScores().CreateFromString(toks[2], *this, system, true);
//cerr << "created scores" << endl;

View File

@ -20,7 +20,7 @@ class PhraseTableMemory : public PhraseTable
public:
Node();
~Node();
void AddRule(PhraseImpl &source, TargetPhrase *target);
void AddRule(Phrase &source, TargetPhrase *target);
TargetPhrases *Find(const Phrase &source, size_t pos = 0) const;
void SortAndPrune(size_t tableLimit, MemPool &pool, System &system);
@ -29,10 +29,10 @@ class PhraseTableMemory : public PhraseTable
typedef boost::unordered_map<Word, Node, UnorderedComparer<Word>, UnorderedComparer<Word> > Children;
Children m_children;
TargetPhrases *m_targetPhrases;
PhraseImpl *m_source;
Phrase *m_source;
std::vector<TargetPhrase*> *m_unsortedTPS;
Node &AddRule(PhraseImpl &source, TargetPhrase *target, size_t pos);
Node &AddRule(Phrase &source, TargetPhrase *target, size_t pos);
};
//////////////////////////////////////