private void initLabelsAndModels ( ArrayList < GeneratorInterface > generators , ClassLabel [ ] labels , Model [ ] models , Pattern reassign ) { int existingclusters = 0 ; if ( reassign != null ) { for ( int i = 0 ; i < labels . length ; i ++ ) { final GeneratorInterface curclus = generators . get ( i ) ; if ( ! reassign . matcher ( curclus . getName ( ) ) . find ( ) ) { labels [ i ] = new SimpleClassLabel ( curclus . getName ( ) ) ; models [ i ] = curclus . makeModel ( ) ; ++ existingclusters ; } } if ( existingclusters == 0 ) { LOG . warning ( "All clusters matched the 'reassign' pattern. Ignoring." ) ; } if ( existingclusters == 1 ) { // No need to test - only one possible answer. for ( int i = 0 ; i < labels . length ; i ++ ) { if ( labels [ i ] != null ) { Arrays . fill ( labels , labels [ i ] ) ; Arrays . fill ( models , models [ i ] ) ; break ; } } } if ( existingclusters == labels . length ) { LOG . warning ( "No clusters matched the 'reassign' pattern." ) ; } } // Default case, every cluster has a label and model. if ( existingclusters == 0 ) { for ( int i = 0 ; i < labels . length ; i ++ ) { final GeneratorInterface curclus = generators . get ( i ) ; labels [ i ] = new SimpleClassLabel ( curclus . getName ( ) ) ; models [ i ] = curclus . makeModel ( ) ; } } }
Initialize cluster labels and models .