question: private List < ClusteredPatterns > cluster ( List < PatternReference > patterns ) { final List < ClusteredPatterns > clusters = new ArrayList < > ( ) ; for ( final PatternReference pr : patterns ) { double maxScore = Double . NEGATIVE_INFINITY ; ClusteredPatterns bestCluster = null ; for ( final ClusteredPatterns cp : clusters ) { final double score = cp . calculateSimilarity ( pr ) ; if ( score > maxScore ) { maxScore = score ; bestCluster = cp ; } } if ( maxScore > threshold && bestCluster != null ) { bestCluster . add ( pr ) ; } else { clusters . add ( new ClusteredPatterns ( pr ) ) ; } } return clusters ; }
target:  Cluster the patterns together based on similarity.