mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-08 04:27:53 +03:00
syntax
This commit is contained in:
parent
59dcf48db4
commit
4abdf4fef3
@ -25,14 +25,24 @@ void InputPaths::Init(const Sentence &input, const ManagerBase &mgr)
|
|||||||
size_t size = input.GetSize();
|
size_t size = input.GetSize();
|
||||||
size_t maxLength = min(size, mgr.system.options.search.max_phrase_length);
|
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);
|
size, maxLength);
|
||||||
m_matrix->Init(NULL);
|
m_matrix->Init(NULL);
|
||||||
|
|
||||||
// create normal paths of subphrases through the sentence
|
|
||||||
for (size_t startPos = 0; startPos < size; ++startPos) {
|
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) {
|
for (size_t phaseSize = 1; phaseSize <= maxLength; ++phaseSize) {
|
||||||
size_t endPos = startPos + phaseSize - 1;
|
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);
|
SubPhrase subPhrase = input.GetSubPhrase(startPos, phaseSize);
|
||||||
Range range(startPos, endPos);
|
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);
|
subPhrase, range, numPt, prefixPath);
|
||||||
|
cerr << startPos << " " << (phaseSize - 1)
|
||||||
|
<< " path=" << *path << endl;
|
||||||
m_inputPaths.push_back(path);
|
m_inputPaths.push_back(path);
|
||||||
|
|
||||||
prefixPath = path;
|
prefixPath = path;
|
||||||
|
|
||||||
m_matrix->SetValue(startPos, phaseSize - 1, path);
|
m_matrix->SetValue(startPos, phaseSize, path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ void Manager::Decode()
|
|||||||
m_stacks.Init(*this, size);
|
m_stacks.Init(*this, size);
|
||||||
cerr << "CREATED m_stacks" << endl;
|
cerr << "CREATED m_stacks" << endl;
|
||||||
|
|
||||||
for (int startPos = size; startPos >= 0; --startPos) {
|
for (int startPos = size - 1; startPos >= 0; --startPos) {
|
||||||
InitActiveChart(startPos);
|
InitActiveChart(startPos);
|
||||||
|
|
||||||
for (int endPos = startPos + 1; endPos < size + 1; ++endPos) {
|
for (int endPos = startPos + 1; endPos < size + 1; ++endPos) {
|
||||||
@ -62,17 +62,19 @@ void Manager::Decode()
|
|||||||
|
|
||||||
void Manager::InitActiveChart(size_t pos)
|
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();
|
size_t numPt = system.mappings.size();
|
||||||
|
cerr << "numPt=" << numPt << endl;
|
||||||
|
|
||||||
for (size_t i = 0; i < numPt; ++i) {
|
for (size_t i = 0; i < numPt; ++i) {
|
||||||
const PhraseTable &pt = *system.mappings[i];
|
const PhraseTable &pt = *system.mappings[i];
|
||||||
cerr << "START InitActiveChart" << endl;
|
cerr << "START InitActiveChart" << endl;
|
||||||
pt.InitActiveChart(path);
|
pt.InitActiveChart(path);
|
||||||
cerr << "FINISHED InitActiveChart" << endl;
|
cerr << "FINISHED InitActiveChart" << endl;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -196,15 +196,10 @@ TargetPhrases* PhraseTableMemory::Lookup(const Manager &mgr, MemPool &pool,
|
|||||||
void PhraseTableMemory::InitActiveChart(SCFG::InputPath &path) const
|
void PhraseTableMemory::InitActiveChart(SCFG::InputPath &path) const
|
||||||
{
|
{
|
||||||
size_t ptInd = GetPtInd();
|
size_t ptInd = GetPtInd();
|
||||||
cerr << "BEFORE GetActiveChart" << endl;
|
|
||||||
SCFG::ActiveChart &chart = path.GetActiveChart(ptInd);
|
SCFG::ActiveChart &chart = path.GetActiveChart(ptInd);
|
||||||
cerr << "AFTER GetActiveChart" << endl;
|
|
||||||
SCFG::ActiveChartEntry *chartEntry = new SCFG::ActiveChartEntry(&m_root);
|
SCFG::ActiveChartEntry *chartEntry = new SCFG::ActiveChartEntry(&m_root);
|
||||||
|
|
||||||
cerr << "BEFORE push_back" << endl;
|
|
||||||
chart.entries.push_back(chartEntry);
|
chart.entries.push_back(chartEntry);
|
||||||
cerr << "AFTER push_back" << endl;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -99,5 +99,9 @@ void UnknownWordPenalty::EvaluateInIsolation(const System &system,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UnknownWordPenalty::InitActiveChart(SCFG::InputPath &path) const
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ public:
|
|||||||
const TargetPhrase &targetPhrase, Scores &scores,
|
const TargetPhrase &targetPhrase, Scores &scores,
|
||||||
SCORE *estimatedScore) const;
|
SCORE *estimatedScore) const;
|
||||||
|
|
||||||
|
virtual void InitActiveChart(SCFG::InputPath &path) const;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user