mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 22:14:57 +03:00
speed up rule extraction by factor 2 (by rewriting rule consolidation to have linear instead of quadratic complexity)
This commit is contained in:
parent
50a8e94a8f
commit
e3ea93acb7
@ -982,17 +982,15 @@ void ExtractTask::consolidateRules()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// consolidate counts
|
// consolidate counts
|
||||||
|
map<std::string, map< std::string, map< std::string, float> > > consolidatedCount;
|
||||||
for(R rule = m_extractedRules.begin(); rule != m_extractedRules.end(); rule++ ) {
|
for(R rule = m_extractedRules.begin(); rule != m_extractedRules.end(); rule++ ) {
|
||||||
if (rule->count == 0)
|
consolidatedCount[ rule->source ][ rule->target][ rule->alignment ] += rule->count;
|
||||||
continue;
|
}
|
||||||
for(R r2 = rule+1; r2 != m_extractedRules.end(); r2++ ) {
|
|
||||||
if (rule->source.compare( r2->source ) == 0 &&
|
for(R rule = m_extractedRules.begin(); rule != m_extractedRules.end(); rule++ ) {
|
||||||
rule->target.compare( r2->target ) == 0 &&
|
float count = consolidatedCount[ rule->source ][ rule->target][ rule->alignment ];
|
||||||
rule->alignment.compare( r2->alignment ) == 0) {
|
rule->count = count;
|
||||||
rule->count += r2->count;
|
consolidatedCount[ rule->source ][ rule->target][ rule->alignment ] = 0;
|
||||||
r2->count = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user