Program: 9554
Project: 9554
Buggy source:
@Override public OWLOntology getCoherentOntology(OWLOntology ontology){
  this.ontology=ontology;
  ontology.getOWLOntologyManager().removeAxioms(ontology,ontology.getAxioms(AxiomType.TRANSITIVE_OBJECT_PROPERTY));
  this.incoherentOntology=getOntologyWithoutAnnotations(ontology);
  reasoner=new IncrementalClassifier(incoherentOntology);
  reasoner.classify();
  OWLOntologyManager man=incoherentOntology.getOWLOntologyManager();
  StructureBasedRootClassFinder rootFinder=new StructureBasedRootClassFinder(reasoner);
  rootFinder.computeRootDerivedClasses();
  Set<OWLClass> unsatClasses=rootFinder.getRootUnsatisfiableClasses();
  int cnt=unsatClasses.size();
  if (unsatClasses.isEmpty()) {
    return incoherentOntology;
  }
  cls2ModuleMap=extractModules(unsatClasses);
  Map<OWLClass,Set<Set<OWLAxiom>>> cls2Explanations=getInitialExplanationsForUnsatClasses(unsatClasses);
  while (!unsatClasses.isEmpty()) {
    Map<OWLAxiom,Integer> axiom2CountMap=getAxiomFrequency(cls2Explanations);
    List<Entry<OWLAxiom,Integer>> sortedEntries=MapUtils.sortByValues(axiom2CountMap);
    for (    Entry<OWLAxiom,Integer> entry : sortedEntries) {
      System.out.println(entry.getKey() + "String_Node_Str" + entry.getValue());
    }
    OWLAxiom toRemove=sortedEntries.get(0).getKey();
    System.out.println("String_Node_Str" + toRemove);
    man.removeAxiom(incoherentOntology,toRemove);
    man.applyChange(new RemoveAxiom(incoherentOntology,toRemove));
    removeFromExplanations(cls2Explanations,toRemove);
    removeFromModules(toRemove);
    reasoner.classify();
    rootFinder=new StructureBasedRootClassFinder(reasoner);
    rootFinder.computeRootDerivedClasses();
    unsatClasses=rootFinder.getRootUnsatisfiableClasses();
    System.out.println("String_Node_Str" + unsatClasses.size());
    if (cnt - unsatClasses.size() >= 10) {
      OWLOntology toSave=getOntologyWithAnnotations(incoherentOntology);
      try {
        toSave.getOWLOntologyManager().saveOntology(incoherentOntology,new RDFXMLOntologyFormat(),new BufferedOutputStream(new FileOutputStream("String_Node_Str" + unsatClasses.size() + "String_Node_Str")));
      }
 catch (      OWLOntologyStorageException e) {
        e.printStackTrace();
      }
catch (      FileNotFoundException e) {
        e.printStackTrace();
      }
      cnt=unsatClasses.size();
    }
    refillExplanations(unsatClasses,cls2Explanations);
    System.gc();
  }
  try {
    incoherentOntology.getOWLOntologyManager().saveOntology(incoherentOntology,new RDFXMLOntologyFormat(),new BufferedOutputStream(new FileOutputStream("String_Node_Str")));
  }
 catch (  OWLOntologyStorageException e) {
    e.printStackTrace();
  }
catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
  System.out.println(incoherentOntology.getLogicalAxiomCount());
  return getOntologyWithAnnotations(incoherentOntology);
}

Fixed version (ground truth):
@Override public OWLOntology getCoherentOntology(OWLOntology ontology){
  this.ontology=ontology;
  ontology.getOWLOntologyManager().removeAxioms(ontology,ontology.getAxioms(AxiomType.TRANSITIVE_OBJECT_PROPERTY));
  this.incoherentOntology=getOntologyWithoutAnnotations(ontology);
  reasoner=new IncrementalClassifier(incoherentOntology);
  reasoner.classify();
  OWLOntologyManager man=incoherentOntology.getOWLOntologyManager();
  StructureBasedRootClassFinder rootFinder=new StructureBasedRootClassFinder(reasoner);
  rootFinder.computeRootDerivedClasses();
  Set<OWLClass> unsatClasses=rootFinder.getRootUnsatisfiableClasses();
  Set<OWLClass> derivedUnsatClasses=rootFinder.getDerivedUnsatisfiableClasses();
  int rootCnt=unsatClasses.size();
  int derivedCnt=derivedUnsatClasses.size();
  int cnt=rootCnt + derivedCnt;
  logger.info("String_Node_Str" + cnt + "String_Node_Str"+ rootCnt+ "String_Node_Str");
  if (unsatClasses.isEmpty()) {
    return incoherentOntology;
  }
  logger.info("String_Node_Str");
  cls2ModuleMap=extractModules(unsatClasses);
  logger.info("String_Node_Str");
  logger.info("String_Node_Str");
  Map<OWLClass,Set<Set<OWLAxiom>>> cls2Explanations=getInitialExplanationsForUnsatClasses(unsatClasses);
  logger.info("String_Node_Str");
  while (!unsatClasses.isEmpty()) {
    Map<OWLAxiom,Integer> axiom2CountMap=getAxiomFrequency(cls2Explanations);
    List<Entry<OWLAxiom,Integer>> sortedEntries=MapUtils.sortByValues(axiom2CountMap);
    for (    Entry<OWLAxiom,Integer> entry : sortedEntries) {
      System.out.println(entry.getKey() + "String_Node_Str" + entry.getValue());
    }
    OWLAxiom toRemove=sortedEntries.get(0).getKey();
    logger.info("String_Node_Str" + toRemove + "String_Node_Str");
    man.removeAxiom(incoherentOntology,toRemove);
    man.applyChange(new RemoveAxiom(incoherentOntology,toRemove));
    removeFromExplanations(cls2Explanations,toRemove);
    removeFromModules(toRemove);
    reasoner.classify();
    rootFinder=new StructureBasedRootClassFinder(reasoner);
    rootFinder.computeRootDerivedClasses();
    unsatClasses=rootFinder.getRootUnsatisfiableClasses();
    rootCnt=unsatClasses.size();
    derivedUnsatClasses=rootFinder.getDerivedUnsatisfiableClasses();
    derivedCnt=derivedUnsatClasses.size();
    logger.info("String_Node_Str" + (rootCnt + derivedCnt) + "String_Node_Str"+ rootCnt+ "String_Node_Str");
    if (cnt - (rootCnt + derivedCnt) >= 10) {
      cnt=rootCnt + derivedCnt;
      OWLOntology toSave=getOntologyWithAnnotations(incoherentOntology);
      try {
        toSave.getOWLOntologyManager().saveOntology(incoherentOntology,new RDFXMLOntologyFormat(),new BufferedOutputStream(new FileOutputStream("String_Node_Str" + cnt + "String_Node_Str")));
      }
 catch (      OWLOntologyStorageException e) {
        e.printStackTrace();
      }
catch (      FileNotFoundException e) {
        e.printStackTrace();
      }
      cnt=rootCnt + derivedCnt;
    }
    logger.info("String_Node_Str");
    refillExplanations(unsatClasses,cls2Explanations);
    logger.info("String_Node_Str");
    System.gc();
  }
  try {
    incoherentOntology.getOWLOntologyManager().saveOntology(incoherentOntology,new RDFXMLOntologyFormat(),new BufferedOutputStream(new FileOutputStream("String_Node_Str")));
  }
 catch (  OWLOntologyStorageException e) {
    e.printStackTrace();
  }
catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
  System.out.println(incoherentOntology.getLogicalAxiomCount());
  return getOntologyWithAnnotations(incoherentOntology);
}