output rules

This commit is contained in:
Hieu Hoang 2014-02-19 21:56:08 +00:00
parent a31003a953
commit 7e3c8db565
4 changed files with 14 additions and 4 deletions

View File

@ -13,13 +13,16 @@ public:
Parameter()
:maxSpan(10)
,maxNonTerm(2)
,sourceSyntax(false)
,targetSyntax(false)
{}
virtual ~Parameter();
int maxSpan;
int maxNonTerm;
bool sourceSyntax, targetSyntax;
};

View File

@ -49,7 +49,8 @@ bool Rule::CanExtend(const Parameter &params) const
}
void Rule::Fillout(const ConsistentPhrases &consistentPhrases,
const AlignedSentence &alignedSentence)
const AlignedSentence &alignedSentence,
const Parameter &params)
{
// if last word is a non-term, check to see if it overlaps with any other non-terms
if (m_arcs.back()->IsNonTerm()) {
@ -108,6 +109,11 @@ void Rule::Fillout(const ConsistentPhrases &consistentPhrases,
}
}
if (targetNonTerms.size() > params.maxNonTerm) {
m_isValid = false;
return;
}
// targetNonTerms will be deleted element-by-element as it is used
CreateTargetPhrase(alignedSentence.GetPhrase(Moses::Output),
targetStart,

View File

@ -27,7 +27,8 @@ public:
bool IsValid(const Parameter &params) const;
bool CanExtend(const Parameter &params) const;
void Fillout(const ConsistentPhrases &consistentPhrases,
const AlignedSentence &alignedSentence);
const AlignedSentence &alignedSentence,
const Parameter &params);
const LatticeArc &GetLastArc() const
{ return *m_arcs.back(); }

View File

@ -44,7 +44,7 @@ void Rules::CreateRules(const Parameter &params, const ConsistentPhrases &consis
for (iterRules = todoRules.begin(); iterRules != todoRules.end(); ++iterRules) {
Rule *rule = *iterRules;
rule->Fillout(consistentPhrases, m_alignedSentence);
rule->Fillout(consistentPhrases, m_alignedSentence, params);
Extend(*rule, params);
if (rule->IsValid(params)) {