add hypo to stack

This commit is contained in:
Hieu Hoang 2016-04-17 14:55:08 +04:00
parent 229832231c
commit 42a0d6195e
2 changed files with 17 additions and 5 deletions

View File

@ -221,7 +221,7 @@ void PhraseTableMemory::Lookup(MemPool &pool, const System &system, SCFG::InputP
{
size_t ptInd = GetPtInd();
// terminal
// TERMINAL
const Word &lastWord = path.subPhrase.Back();
//cerr << "PhraseTableMemory lastWord=" << lastWord << endl;
//cerr << "path=" << path << endl;
@ -243,9 +243,10 @@ void PhraseTableMemory::Lookup(MemPool &pool, const System &system, SCFG::InputP
chart.entries.push_back(chartEntry);
// there are some rules
if (nextNode->m_targetPhrases) {
const TargetPhrases *tps = nextNode->GetTargetPhrases();
if (tps) {
TargetPhrases::const_iterator iter;
for (iter = nextNode->m_targetPhrases->begin(); iter != nextNode->m_targetPhrases->end(); ++iter) {
for (iter = tps->begin(); iter != tps->end(); ++iter) {
const TargetPhrase *tp = *iter;
const SCFG::TargetPhraseImpl *tpCast = static_cast<const SCFG::TargetPhraseImpl*>(tp);
path.AddTargetPhrase(*this, tpCast);
@ -254,6 +255,14 @@ void PhraseTableMemory::Lookup(MemPool &pool, const System &system, SCFG::InputP
}
}
// NON-TERMINAL
//const SCFG::InputPath *prefixPath = static_cast<const SCFG::InputPath*>(path.prefixPath);
while (prefixPath) {
prefixPath = static_cast<const SCFG::InputPath*>(prefixPath->prefixPath);
}
}
}

View File

@ -19,13 +19,15 @@ class PhraseTableMemory: public PhraseTable
class Node
{
public:
TargetPhrases *m_targetPhrases;
Node();
~Node();
void AddRule(Phrase &source, TargetPhrase *target);
TargetPhrases *Find(const Phrase &source, size_t pos = 0) const;
const PhraseTableMemory::Node *Find(const Word &word) const;
const Node *Find(const Word &word) const;
const TargetPhrases *GetTargetPhrases() const
{ return m_targetPhrases; }
void SortAndPrune(size_t tableLimit, MemPool &pool, System &system);
@ -33,6 +35,7 @@ class PhraseTableMemory: public PhraseTable
typedef boost::unordered_map<Word, Node, UnorderedComparer<Word>,
UnorderedComparer<Word> > Children;
Children m_children;
TargetPhrases *m_targetPhrases;
Phrase *m_source;
std::vector<TargetPhrase*> *m_unsortedTPS;