This commit is contained in:
Hieu Hoang 2016-04-14 18:55:13 +04:00
parent 59dcf48db4
commit 4abdf4fef3
5 changed files with 33 additions and 18 deletions

View File

@ -25,14 +25,24 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
size_t size = input.GetSize();
size_t maxLength = min(size, mgr.system.options.search.max_phrase_length);
m_matrix = new (pool.Allocate<Matrix<InputPath*> >()) Matrix<InputPath*>(pool,
m_matrix = new (pool.Allocate< Matrix<SCFG::InputPath*> >()) Matrix<SCFG::InputPath*>(pool,
size, maxLength);
m_matrix->Init(NULL);
// create normal paths of subphrases through the sentence
for (size_t startPos = 0; startPos < size; ++startPos) {
const InputPath *prefixPath = NULL;
// create path for 0 length string
Range range(startPos, startPos - 1);
SubPhrase subPhrase = input.GetSubPhrase(startPos, 0);
SCFG::InputPath *path = new (pool.Allocate<SCFG::InputPath>()) SCFG::InputPath(pool,
subPhrase, range, numPt, NULL);
cerr << startPos << " "
<< " path=" << *path << endl;
m_inputPaths.push_back(path);
m_matrix->SetValue(startPos, 0, path);
// create normal paths of subphrases through the sentence
const SCFG::InputPath *prefixPath = path;
for (size_t phaseSize = 1; phaseSize <= maxLength; ++phaseSize) {
size_t endPos = startPos + phaseSize - 1;
@ -43,13 +53,15 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
SubPhrase subPhrase = input.GetSubPhrase(startPos, phaseSize);
Range range(startPos, endPos);
InputPath *path = new (pool.Allocate<InputPath>()) InputPath(pool,
SCFG::InputPath *path = new (pool.Allocate<SCFG::InputPath>()) SCFG::InputPath(pool,
subPhrase, range, numPt, prefixPath);
cerr << startPos << " " << (phaseSize - 1)
<< " path=" << *path << endl;
m_inputPaths.push_back(path);
prefixPath = path;
m_matrix->SetValue(startPos, phaseSize - 1, path);
m_matrix->SetValue(startPos, phaseSize, path);
}
}

View File

@ -49,7 +49,7 @@ void Manager::Decode()
m_stacks.Init(*this, size);
cerr << "CREATED m_stacks" << endl;
for (int startPos = size; startPos >= 0; --startPos) {
for (int startPos = size - 1; startPos >= 0; --startPos) {
InitActiveChart(startPos);
for (int endPos = startPos + 1; endPos < size + 1; ++endPos) {
@ -62,17 +62,19 @@ void Manager::Decode()
void Manager::InitActiveChart(size_t pos)
{
/*
InputPath &path = static_cast<InputPath&>(m_inputPaths.GetInputPath(pos, pos));
InputPath &path = static_cast<InputPath&>(*m_inputPaths.GetMatrix().GetValue(pos, 0));
cerr << "pos=" << pos << " path=" << path << endl;
size_t numPt = system.mappings.size();
cerr << "numPt=" << numPt << endl;
for (size_t i = 0; i < numPt; ++i) {
const PhraseTable &pt = *system.mappings[i];
cerr << "START InitActiveChart" << endl;
pt.InitActiveChart(path);
cerr << "FINISHED InitActiveChart" << endl;
const PhraseTable &pt = *system.mappings[i];
cerr << "START InitActiveChart" << endl;
pt.InitActiveChart(path);
cerr << "FINISHED InitActiveChart" << endl;
}
*/
}
}

View File

@ -196,15 +196,10 @@ TargetPhrases* PhraseTableMemory::Lookup(const Manager &mgr, MemPool &pool,
void PhraseTableMemory::InitActiveChart(SCFG::InputPath &path) const
{
size_t ptInd = GetPtInd();
cerr << "BEFORE GetActiveChart" << endl;
SCFG::ActiveChart &chart = path.GetActiveChart(ptInd);
cerr << "AFTER GetActiveChart" << endl;
SCFG::ActiveChartEntry *chartEntry = new SCFG::ActiveChartEntry(&m_root);
cerr << "BEFORE push_back" << endl;
chart.entries.push_back(chartEntry);
cerr << "AFTER push_back" << endl;
}
}

View File

@ -99,5 +99,9 @@ void UnknownWordPenalty::EvaluateInIsolation(const System &system,
}
void UnknownWordPenalty::InitActiveChart(SCFG::InputPath &path) const
{
}
}

View File

@ -27,6 +27,8 @@ public:
const TargetPhrase &targetPhrase, Scores &scores,
SCORE *estimatedScore) const;
virtual void InitActiveChart(SCFG::InputPath &path) const;
};
}