Program: 24958
Project: 24958
Buggy source:
/** 
 * Allows generating "breakdowns" of a provenanced confusion matrix according to some criteria. For example, a confusion matrix for an event detection task could be further broken down into separate confusion matrices for each event type. To do this, you specify a signature function mapping from each provenance to some signature (e.g. to event types, to genres, etc.).  The output will be an   {@link com.google.common.collect.ImmutableMap}from all observed signatures to   {@link com.bbn.bue.common.diff.ProvenancedConfusionMatrix}es consisting of only those provenances with the corresponding signature under the provided function. The signature function may never return a signature of   {@code null}. No guarantee is made about the iteration order of the resulting map.
 */
public <SignatureType>ImmutableMap<SignatureType,ProvenancedConfusionMatrix<CellFiller>> breakdown(Function<? super CellFiller,SignatureType> signatureFunction){
  final Map<SignatureType,Builder<CellFiller>> ret=Maps.newHashMap();
  for (  final Symbol leftLabel : leftLabels()) {
    for (    final Symbol rightLabel : rightLabels()) {
      for (      final CellFiller provenance : cell(leftLabel,rightLabel)) {
        final SignatureType signature=signatureFunction.apply(provenance);
        checkNotNull(signature,"String_Node_Str");
        if (!ret.containsKey(signature)) {
          ret.put(signature,ProvenancedConfusionMatrix.<CellFiller>builder());
        }
        ret.get(signature).record(leftLabel,rightLabel,provenance);
      }
    }
  }
  final ImmutableMap.Builder<SignatureType,ProvenancedConfusionMatrix<CellFiller>> trueRet=ImmutableMap.builder();
  for (  final Map.Entry<SignatureType,Builder<CellFiller>> entry : ret.entrySet()) {
    trueRet.put(entry.getKey(),entry.getValue().build());
  }
  return trueRet.build();
}

Fixed version (ground truth):
/** 
 * Allows generating "breakdowns" of a provenanced confusion matrix according to some criteria. For example, a confusion matrix for an event detection task could be further broken down into separate confusion matrices for each event type. To do this, you specify a signature function mapping from each provenance to some signature (e.g. to event types, to genres, etc.).  The output will be an   {@link com.google.common.collect.ImmutableMap}from all observed signatures to   {@link com.bbn.bue.common.diff.ProvenancedConfusionMatrix}es consisting of only those provenances with the corresponding signature under the provided function. The signature function may never return a signature of   {@code null}. No guarantee is made about the iteration order of the resulting map.  {@code keyOrder} is the order the keys should be in the iteration order of the resulting map.
 */
public <SignatureType>ImmutableMap<SignatureType,ProvenancedConfusionMatrix<CellFiller>> breakdown(Function<? super CellFiller,SignatureType> signatureFunction,Ordering<SignatureType> keyOrdering){
  final Map<SignatureType,Builder<CellFiller>> ret=Maps.newHashMap();
  for (  final Symbol leftLabel : leftLabels()) {
    for (    final Symbol rightLabel : rightLabels()) {
      for (      final CellFiller provenance : cell(leftLabel,rightLabel)) {
        final SignatureType signature=signatureFunction.apply(provenance);
        checkNotNull(signature,"String_Node_Str");
        if (!ret.containsKey(signature)) {
          ret.put(signature,ProvenancedConfusionMatrix.<CellFiller>builder());
        }
        ret.get(signature).record(leftLabel,rightLabel,provenance);
      }
    }
  }
  final ImmutableMap.Builder<SignatureType,ProvenancedConfusionMatrix<CellFiller>> trueRet=ImmutableMap.builder();
  for (  final Map.Entry<SignatureType,Builder<CellFiller>> entry : MapUtils.<SignatureType,Builder<CellFiller>>byKeyOrdering(keyOrdering).sortedCopy(ret.entrySet())) {
    trueRet.put(entry.getKey(),entry.getValue().build());
  }
  return trueRet.build();
}