don't allow rules with only non-terms on either source or target

This commit is contained in:
Hieu Hoang 2014-02-17 16:54:04 +00:00
parent 73b14cee57
commit 32e6a72d5d
2 changed files with 23 additions and 1 deletions

View File

@ -172,6 +172,27 @@ void Rule::CreateSymbols(const Global &global, bool &isValid, const SentenceAlig
//cerr << "m_target=" << m_target.GetSize() << ":" << m_target << endl;
}
}
if (isValid) {
isValid = false;
for (size_t i = 0; i < m_source.GetSize(); ++i) {
const Symbol &symbol = m_source.GetSymbol(i);
if (symbol.IsTerminal()) {
isValid = true;
}
}
}
if (isValid) {
isValid = false;
for (size_t i = 0; i < m_target.GetSize(); ++i) {
const Symbol &symbol = m_target.GetSymbol(i);
if (symbol.IsTerminal()) {
isValid = true;
}
}
}
}
bool Rule::MoreDefaultNonTermThanTerm() const

View File

@ -32,5 +32,6 @@ public:
, bool isSourceSyntax, bool isTargetSyntax);
int Compare(const Symbol &other) const;
bool IsTerminal() const
{ return m_isTerminal; }
};