mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 05:55:02 +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
|
||||
map<std::string, map< std::string, map< std::string, float> > > consolidatedCount;
|
||||
for(R rule = m_extractedRules.begin(); rule != m_extractedRules.end(); rule++ ) {
|
||||
if (rule->count == 0)
|
||||
continue;
|
||||
for(R r2 = rule+1; r2 != m_extractedRules.end(); r2++ ) {
|
||||
if (rule->source.compare( r2->source ) == 0 &&
|
||||
rule->target.compare( r2->target ) == 0 &&
|
||||
rule->alignment.compare( r2->alignment ) == 0) {
|
||||
rule->count += r2->count;
|
||||
r2->count = 0;
|
||||
}
|
||||
}
|
||||
consolidatedCount[ rule->source ][ rule->target][ rule->alignment ] += rule->count;
|
||||
}
|
||||
|
||||
for(R rule = m_extractedRules.begin(); rule != m_extractedRules.end(); rule++ ) {
|
||||
float count = consolidatedCount[ rule->source ][ rule->target][ rule->alignment ];
|
||||
rule->count = count;
|
||||
consolidatedCount[ rule->source ][ rule->target][ rule->alignment ] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user