Program: 36084
Project: 36084
Buggy source:
/** 
 * Test each sieve's precision independently. Runs each sieve and evaluates its proposed links against the input -info file. You must have loaded an -info file that has gold TLinks in it.
 */
public void runPrecisionGauntlet(){
  if (thedocs == null) {
    System.out.println("String_Node_Str");
    System.exit(1);
  }
  thedocs.removeAllTLinks();
  Sieve sieves[]=createAllSieves(sieveClasses);
  SieveDocuments docs=Evaluate.getDevSet(thedocs);
  if (runOnTrain)   docs=Evaluate.getTrainSet(thedocs);
 else   if (runOnAll)   docs=thedocs;
  List<TLink> currentTLinks=new ArrayList<TLink>();
  Counter<String> numCorrect=new ClassicCounter<String>();
  Counter<String> numIncorrect=new ClassicCounter<String>();
  Counter<String> numIncorrectNonVague=new ClassicCounter<String>();
  Map<String,Counter<TLink.Type>> goldLabelCounts=new HashMap<String,Counter<TLink.Type>>();
  for (  String sc : sieveClasses)   goldLabelCounts.put(sc,new ClassicCounter<TLink.Type>());
  Map<String,Counter<String>> guessCounts=new HashMap<String,Counter<String>>();
  for (  String sc : sieveClasses)   guessCounts.put(sc,new ClassicCounter<String>());
  for (  SieveDocument doc : docs.getDocuments()) {
    System.out.println("String_Node_Str" + doc.getDocname());
    List<SieveSentence> sents=doc.getSentences();
    List<TLink> goldLinks=doc.getTlinks(true);
    Map<String,TLink> goldOrderedIdPairs=new HashMap<String,TLink>();
    for (    TLink tlink : goldLinks) {
      goldOrderedIdPairs.put(TLink.orderedIdPair(tlink),tlink);
    }
    for (int xx=0; xx < sieveClasses.length; xx++) {
      String sieveName=sieveClasses[xx];
      Sieve sieve=sieves[xx];
      if (sieve != null) {
        List<TLink> proposed=sieve.annotate(doc,currentTLinks);
        for (        TLink pp : proposed) {
          String orderedIdPair=TLink.orderedIdPair(pp);
          TLink goldLink=goldOrderedIdPairs.get(orderedIdPair);
          if (goldLink != null) {
            guessCounts.get(sieveName).incrementCount(goldLink.getOrderedRelation() + "String_Node_Str" + pp.getOrderedRelation());
            goldLabelCounts.get(sieveName).incrementCount(goldLink.getRelation());
          }
          if (Evaluate.isLinkCorrect(pp,goldLinks)) {
            numCorrect.incrementCount(sieveClasses[xx]);
          }
 else           if (goldLink != null) {
            if (!goldLink.getRelation().equals(TLink.Type.VAGUE)) {
              numIncorrectNonVague.incrementCount(sieveClasses[xx]);
            }
            numIncorrect.incrementCount(sieveClasses[xx]);
            if (debug) {
              System.out.printf("String_Node_Str",sieveClasses[xx],doc.getDocname(),goldOrderedIdPairs.get(orderedIdPair),pp,getLinkDebugInfo(pp,sents,doc));
            }
          }
 else {
            System.out.println("String_Node_Str" + sieveName + "String_Node_Str"+ pp);
          }
        }
      }
    }
  }
  Counter<String> precision=new ClassicCounter<String>();
  Counter<String> precisionNonVague=new ClassicCounter<String>();
  for (  String sieveClass : sieveClasses) {
    double correct=numCorrect.getCount(sieveClass);
    double incorrect=numIncorrect.getCount(sieveClass);
    double incorrectNonVague=numIncorrectNonVague.getCount(sieveClass);
    double total=correct + incorrect;
    precision.incrementCount(sieveClass,total > 0 ? correct / total : 0.0);
    double totalNonVague=correct + incorrectNonVague;
    precisionNonVague.incrementCount(sieveClass,totalNonVague > 0 ? correct / totalNonVague : 0.0);
  }
  List<String> sortedKeys=Util.sortCounterKeys(precision);
  for (  String key : sortedKeys) {
    double correct=numCorrect.getCount(key);
    int numtabs=Math.max(1,4 - key.length() / 8);
    System.out.print(key);
    for (int tt=0; tt < numtabs; tt++)     System.out.print("String_Node_Str");
    System.out.printf("String_Node_Str",precision.getCount(key),correct,correct + numIncorrect.getCount(key),precisionNonVague.getCount(key),correct,correct + numIncorrectNonVague.getCount(key));
  }
  for (  String key : sortedKeys) {
    System.out.println("String_Node_Str" + key + "String_Node_Str");
    Evaluate.printBaseline(goldLabelCounts.get(key));
    Evaluate.confusionMatrix(guessCounts.get(key));
  }
}

Fixed version (ground truth):
/** 
 * Test each sieve's precision independently. Runs each sieve and evaluates its proposed links against the input -info file. You must have loaded an -info file that has gold TLinks in it.
 */
public void runPrecisionGauntlet(){
  if (thedocs == null) {
    System.out.println("String_Node_Str");
    System.exit(1);
  }
  thedocs.removeAllTLinks();
  Sieve sieves[]=createAllSieves(sieveClasses);
  SieveDocuments docs=Evaluate.getDevSet(thedocs);
  if (runOnTrain)   docs=Evaluate.getTrainSet(thedocs);
 else   if (runOnAll)   docs=thedocs;
  List<TLink> currentTLinks=new ArrayList<TLink>();
  Counter<String> numCorrect=new ClassicCounter<String>();
  Counter<String> numIncorrect=new ClassicCounter<String>();
  Counter<String> numIncorrectNonVague=new ClassicCounter<String>();
  Map<String,Counter<TLink.Type>> goldLabelCounts=new HashMap<String,Counter<TLink.Type>>();
  for (  String sc : sieveClasses)   goldLabelCounts.put(sc,new ClassicCounter<TLink.Type>());
  Map<String,Counter<String>> guessCounts=new HashMap<String,Counter<String>>();
  for (  String sc : sieveClasses)   guessCounts.put(sc,new ClassicCounter<String>());
  for (  SieveDocument doc : docs.getDocuments()) {
    System.out.println("String_Node_Str" + doc.getDocname());
    List<SieveSentence> sents=doc.getSentences();
    List<TLink> goldLinks=thedocsUnchanged.getDocument(doc.getDocname()).getTlinks(true);
    Map<String,TLink> goldOrderedIdPairs=new HashMap<String,TLink>();
    for (    TLink tlink : goldLinks) {
      goldOrderedIdPairs.put(TLink.orderedIdPair(tlink),tlink);
    }
    for (int xx=0; xx < sieveClasses.length; xx++) {
      String sieveName=sieveClasses[xx];
      Sieve sieve=sieves[xx];
      if (sieve != null) {
        List<TLink> proposed=sieve.annotate(doc,currentTLinks);
        if (proposed != null) {
          for (          TLink pp : proposed) {
            String orderedIdPair=TLink.orderedIdPair(pp);
            TLink goldLink=goldOrderedIdPairs.get(orderedIdPair);
            if (goldLink != null) {
              guessCounts.get(sieveName).incrementCount(goldLink.getOrderedRelation() + "String_Node_Str" + pp.getOrderedRelation());
              goldLabelCounts.get(sieveName).incrementCount(goldLink.getRelation());
            }
            if (Evaluate.isLinkCorrect(pp,goldLinks)) {
              numCorrect.incrementCount(sieveClasses[xx]);
            }
 else             if (goldLink != null) {
              if (!goldLink.getRelation().equals(TLink.Type.VAGUE)) {
                numIncorrectNonVague.incrementCount(sieveClasses[xx]);
              }
              numIncorrect.incrementCount(sieveClasses[xx]);
              if (debug) {
                System.out.printf("String_Node_Str",sieveClasses[xx],doc.getDocname(),goldOrderedIdPairs.get(orderedIdPair),pp,getLinkDebugInfo(pp,sents,doc));
              }
            }
 else {
              System.out.println("String_Node_Str" + sieveName + "String_Node_Str"+ pp);
            }
          }
        }
      }
    }
  }
  Counter<String> precision=new ClassicCounter<String>();
  Counter<String> precisionNonVague=new ClassicCounter<String>();
  for (  String sieveClass : sieveClasses) {
    double correct=numCorrect.getCount(sieveClass);
    double incorrect=numIncorrect.getCount(sieveClass);
    double incorrectNonVague=numIncorrectNonVague.getCount(sieveClass);
    double total=correct + incorrect;
    precision.incrementCount(sieveClass,total > 0 ? correct / total : 0.0);
    double totalNonVague=correct + incorrectNonVague;
    precisionNonVague.incrementCount(sieveClass,totalNonVague > 0 ? correct / totalNonVague : 0.0);
  }
  List<String> sortedKeys=Util.sortCounterKeys(precision);
  for (  String key : sortedKeys) {
    double correct=numCorrect.getCount(key);
    int numtabs=Math.max(1,4 - key.length() / 8);
    System.out.print(key);
    for (int tt=0; tt < numtabs; tt++)     System.out.print("String_Node_Str");
    System.out.printf("String_Node_Str",precision.getCount(key),correct,correct + numIncorrect.getCount(key),precisionNonVague.getCount(key),correct,correct + numIncorrectNonVague.getCount(key));
  }
  for (  String key : sortedKeys) {
    System.out.println("String_Node_Str" + key + "String_Node_Str");
    Evaluate.printBaseline(goldLabelCounts.get(key));
    Evaluate.confusionMatrix(guessCounts.get(key));
  }
}