This commit is contained in:
Hieu Hoang 2014-02-22 20:05:44 +00:00
parent ede6ff7585
commit 63f0f1b348
8 changed files with 33 additions and 7 deletions

View File

@ -38,3 +38,9 @@ std::string ConsistentPhrase::Debug() const
return out.str();
}
void ConsistentPhrase::Output(std::ostream &out) const
{
out << "[X][X]";
}

View File

@ -28,6 +28,7 @@ public:
bool operator<(const ConsistentPhrase &other) const;
std::string Debug() const;
void Output(std::ostream &out) const;
};

View File

@ -64,6 +64,7 @@ int main(int argc, char** argv)
rules.CreateRules();
cerr << rules.Debug();
rules.Output(cout);
}

View File

@ -28,14 +28,8 @@ Rule::Rule(const Rule &copy, const ConsistentPhrase &cp)
,m_canRecurse(true)
,m_nonterms(copy.m_nonterms)
{
cerr << &copy << "-->" << this << " ";
cerr << "Extending " << m_consistentPhrase.Debug();
cerr << " with " << cp.Debug();
m_nonterms.push_back(&cp);
CreateSource();
cerr << " rule:" << Debug() << endl;
}
Rule::~Rule() {
@ -121,3 +115,14 @@ std::string Rule::Debug() const
return out.str();
}
void Rule::Output(std::ostream &out) const
{
// source
for (size_t i = 0; i < m_source.size(); ++i) {
const RuleSymbol &symbol = *m_source[i];
symbol.Output(out);
out << " ";
}
}

View File

@ -38,6 +38,7 @@ public:
int GetNextSourcePosForNonTerm() const;
std::string Debug() const;
void Output(std::ostream &out) const;
protected:
const ConsistentPhrase &m_consistentPhrase;

View File

@ -17,6 +17,7 @@ public:
virtual ~RuleSymbol();
virtual std::string Debug() const = 0;
virtual void Output(std::ostream &out) const = 0;
};

View File

@ -66,7 +66,7 @@ void Rules::Extend(const Rule &rule)
continue;
}
const ConsistentPhrases::Coll cps = allCPS.GetColl(sourceStart, sourceEnd);
const ConsistentPhrases::Coll &cps = allCPS.GetColl(sourceStart, sourceEnd);
Extend(rule, cps);
}
}
@ -109,3 +109,13 @@ std::string Rules::Debug() const
return out.str();
}
void Rules::Output(std::ostream &out) const
{
std::set<Rule*>::const_iterator iter;
for (iter = m_keepRules.begin(); iter != m_keepRules.end(); ++iter) {
const Rule &rule = **iter;
rule.Output(out);
out << endl;
}
}

View File

@ -21,6 +21,7 @@ public:
void CreateRules();
std::string Debug() const;
void Output(std::ostream &out) const;
protected:
const AlignedSentence &m_alignedSentence;