nus-yam/ex-repair huggingface dataset:
Program: 33208
Project: 33208
Buggy source:
public AbstractDatasetConfiguration(String datasetName,boolean couldBeCached,ExperimentType applicableForExperiment){
  super(datasetName,couldBeCached,applicableForExperiment);
}

Fixed version (ground truth):
public AbstractDatasetConfiguration(String datasetName,boolean couldBeCached,ExperimentType applicableForExperiment,EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  super(datasetName,couldBeCached,applicableForExperiment);
  this.entityCheckerManager=entityCheckerManager;
  this.globalRetriever=globalRetriever;
}
Program: 33209
Project: 33209
Buggy source:
protected Dataset loadDataset() throws Exception {
  Dataset instance=constructor.newInstance(constructorArgs);
  instance.setName(this.getName());
  if (instance instanceof InitializableDataset) {
    ((InitializableDataset)instance).init();
  }
  SameAsRetriever retriever=DatasetBasedSameAsRetriever.create(instance);
  if (retriever != null) {
    if (globalRetriever != null) {
      retriever=new MultipleSameAsRetriever(retriever,globalRetriever);
    }
  }
 else {
    retriever=globalRetriever;
  }
  for (  Document document : instance.getInstances()) {
    if (retriever != null) {
      SameAsRetrieverUtils.addSameURIsToMarkings(retriever,document.getMarkings());
    }
    if (entityCheckerManager != null) {
      entityCheckerManager.checkMarkings(document.getMarkings());
    }
  }
  return instance;
}

Fixed version (ground truth):
protected Dataset loadDataset() throws Exception {
  Dataset instance=constructor.newInstance(constructorArgs);
  instance.setName(this.getName());
  return instance;
}
Program: 33210
Project: 33210
Buggy source:
public DatasetConfigurationImpl(String datasetName,boolean couldBeCached,Constructor<? extends Dataset> constructor,Object constructorArgs[],ExperimentType applicableForExperiment,EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  super(datasetName,couldBeCached,applicableForExperiment);
  this.constructor=constructor;
  this.constructorArgs=constructorArgs;
  this.entityCheckerManager=entityCheckerManager;
  this.globalRetriever=globalRetriever;
}

Fixed version (ground truth):
public DatasetConfigurationImpl(String datasetName,boolean couldBeCached,Constructor<? extends Dataset> constructor,Object constructorArgs[],ExperimentType applicableForExperiment,EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  super(datasetName,couldBeCached,applicableForExperiment,entityCheckerManager,globalRetriever);
  this.constructor=constructor;
  this.constructorArgs=constructorArgs;
}
Program: 33211
Project: 33211
Buggy source:
public DatahubNIFConfig(String datasetName,String datasetUrl,boolean couldBeCached){
  super(datasetName,couldBeCached,ExperimentType.A2KB);
  this.datasetUrl=datasetUrl;
  rt=new RestTemplate();
}

Fixed version (ground truth):
public DatahubNIFConfig(String datasetName,String datasetUrl,boolean couldBeCached,EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  super(datasetName,couldBeCached,ExperimentType.A2KB,entityCheckerManager,globalRetriever);
  this.datasetUrl=datasetUrl;
  rt=new RestTemplate();
}
Program: 33212
Project: 33212
Buggy source:
public NIFFileDatasetConfig(String name,String file,boolean couldBeCached,ExperimentType applicableForExperiment){
  super(name,couldBeCached,applicableForExperiment);
  this.file=file;
}

Fixed version (ground truth):
public NIFFileDatasetConfig(String name,String file,boolean couldBeCached,ExperimentType applicableForExperiment,EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  super(name,couldBeCached,applicableForExperiment,entityCheckerManager,globalRetriever);
  this.file=file;
}
Program: 33213
Project: 33213
Buggy source:
public DatasetConfiguration getDatasetConfig(String name,ExperimentType type){
  List<DatasetConfiguration> configs=datasets.getAdaptersForName(name);
  if (configs != null) {
    for (    DatasetConfiguration config : configs) {
      if (config.isApplicableForExperiment(type)) {
        return config;
      }
    }
  }
 else {
    if (name.startsWith(UPLOADED_DATASET_PREFIX)) {
      String uploadedFilesPath=GerbilConfiguration.getInstance().getString(UPLOADED_FILES_PATH_PROPERTY_KEY);
      if (uploadedFilesPath == null) {
        LOGGER.error("String_Node_Str",UPLOADED_FILES_PATH_PROPERTY_KEY);
        return null;
      }
      int pos=name.lastIndexOf('(');
      if (pos < 0) {
        LOGGER.error("String_Node_Str" + name + "String_Node_Str");
        return null;
      }
      String uri=uploadedFilesPath + name.substring(pos + 1,name.length() - 1);
      name=name.substring(UPLOADED_DATASET_PREFIX.length(),pos) + UPLOADED_DATASET_SUFFIX;
      return new NIFFileDatasetConfig(name,uri,false,type);
    }
    LOGGER.error("String_Node_Str" + name + "String_Node_Str");
    return null;
  }
  return null;
}

Fixed version (ground truth):
public DatasetConfiguration getDatasetConfig(String name,ExperimentType type){
  List<DatasetConfiguration> configs=datasets.getAdaptersForName(name);
  if (configs != null) {
    for (    DatasetConfiguration config : configs) {
      if (config.isApplicableForExperiment(type)) {
        return config;
      }
    }
  }
 else {
    if (name.startsWith(UPLOADED_DATASET_PREFIX)) {
      String uploadedFilesPath=GerbilConfiguration.getInstance().getString(UPLOADED_FILES_PATH_PROPERTY_KEY);
      if (uploadedFilesPath == null) {
        LOGGER.error("String_Node_Str",UPLOADED_FILES_PATH_PROPERTY_KEY);
        return null;
      }
      int pos=name.lastIndexOf('(');
      if (pos < 0) {
        LOGGER.error("String_Node_Str" + name + "String_Node_Str");
        return null;
      }
      String uri=uploadedFilesPath + name.substring(pos + 1,name.length() - 1);
      name=name.substring(UPLOADED_DATASET_PREFIX.length(),pos) + UPLOADED_DATASET_SUFFIX;
      return new NIFFileDatasetConfig(name,uri,false,type,entityCheckerManager,globalRetriever);
    }
    LOGGER.error("String_Node_Str" + name + "String_Node_Str");
    return null;
  }
  return null;
}
Program: 33214
Project: 33214
Buggy source:
@Bean public static AdapterList<DatasetConfiguration> datasets(EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  List<DatasetConfiguration> datasetConfigurations=new ArrayList<DatasetConfiguration>();
  Set<String> datasetKeys=getDatasetKeys();
  DatasetConfiguration configuration;
  for (  String datasetKey : datasetKeys) {
    try {
      configuration=getConfiguration(datasetKey,entityCheckerManager,globalRetriever);
      if (configuration != null) {
        datasetConfigurations.add(configuration);
        LOGGER.info("String_Node_Str" + configuration.toString());
      }
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str" + datasetKey + "String_Node_Str"+ e.toString());
    }
  }
  DatahubNIFLoader datahub=new DatahubNIFLoader();
  Map<String,String> datasets=datahub.getDataSets();
  for (  String datasetName : datasets.keySet()) {
    datasetConfigurations.add(new DatahubNIFConfig(datasetName,datasets.get(datasetName),true));
  }
  LOGGER.info("String_Node_Str",datasetConfigurations.size());
  return new AdapterList<DatasetConfiguration>(datasetConfigurations);
}

Fixed version (ground truth):
@Bean public static AdapterList<DatasetConfiguration> datasets(EntityCheckerManager entityCheckerManager,SameAsRetriever globalRetriever){
  List<DatasetConfiguration> datasetConfigurations=new ArrayList<DatasetConfiguration>();
  Set<String> datasetKeys=getDatasetKeys();
  DatasetConfiguration configuration;
  for (  String datasetKey : datasetKeys) {
    try {
      configuration=getConfiguration(datasetKey,entityCheckerManager,globalRetriever);
      if (configuration != null) {
        datasetConfigurations.add(configuration);
        LOGGER.info("String_Node_Str" + configuration.toString());
      }
    }
 catch (    Exception e) {
      LOGGER.error("String_Node_Str" + datasetKey + "String_Node_Str"+ e.toString());
    }
  }
  DatahubNIFLoader datahub=new DatahubNIFLoader();
  Map<String,String> datasets=datahub.getDataSets();
  for (  String datasetName : datasets.keySet()) {
    datasetConfigurations.add(new DatahubNIFConfig(datasetName,datasets.get(datasetName),true,entityCheckerManager,globalRetriever));
  }
  LOGGER.info("String_Node_Str",datasetConfigurations.size());
  return new AdapterList<DatasetConfiguration>(datasetConfigurations);
}
Program: 33215
Project: 33215
Buggy source:
public SimpleTestDatasetConfig(int size){
  super("String_Node_Str",false,ExperimentType.ERec);
  this.size=size;
}

Fixed version (ground truth):
public SimpleTestDatasetConfig(int size){
  super("String_Node_Str",false,ExperimentType.ERec,null,null);
  this.size=size;
}
Program: 33216
Project: 33216
Buggy source:
public TestDataset(String name,List<Document> instances,ExperimentType applicableForExperiment){
  super(name,false,applicableForExperiment);
  this.instances=instances;
}

Fixed version (ground truth):
public TestDataset(String name,List<Document> instances,ExperimentType applicableForExperiment){
  super(name,false,applicableForExperiment,null,null);
  this.instances=instances;
}
Program: 33217
Project: 33217
Buggy source:
@Test public void test() throws GerbilException {
  DatasetConfiguration datasetConfig=new NIFFileDatasetConfig("String_Node_Str",TASK1_FILE,false,ExperimentType.A2KB);
  Dataset dataset=datasetConfig.getDataset(ExperimentType.A2KB);
  Map<String,Document> uriInstanceMapping=new HashMap<String,Document>(EXPECTED_DOCUMENTS.length);
  for (  Document document : EXPECTED_DOCUMENTS) {
    uriInstanceMapping.put(document.getDocumentURI(),document);
  }
  Document expectedDoc;
  Set<Marking> expectedMarkings;
  for (  Document document : dataset.getInstances()) {
    Assert.assertTrue(uriInstanceMapping.containsKey(document.getDocumentURI()));
    expectedDoc=uriInstanceMapping.get(document.getDocumentURI());
    Assert.assertEquals(expectedDoc.getText(),document.getText());
    Assert.assertEquals("String_Node_Str" + expectedDoc.getMarkings().toString() + "String_Node_Str"+ document.getMarkings().toString()+ "String_Node_Str",expectedDoc.getMarkings().size(),document.getMarkings().size());
    expectedMarkings=new HashSet<Marking>(expectedDoc.getMarkings());
    for (    Marking marking : document.getMarkings()) {
      Assert.assertTrue("String_Node_Str" + marking + "String_Node_Str"+ expectedMarkings.toString()+ "String_Node_Str",expectedMarkings.contains(marking));
    }
  }
}

Fixed version (ground truth):
@Test public void test() throws GerbilException {
  DatasetConfiguration datasetConfig=new NIFFileDatasetConfig("String_Node_Str",TASK1_FILE,false,ExperimentType.A2KB,null,null);
  Dataset dataset=datasetConfig.getDataset(ExperimentType.A2KB);
  Map<String,Document> uriInstanceMapping=new HashMap<String,Document>(EXPECTED_DOCUMENTS.length);
  for (  Document document : EXPECTED_DOCUMENTS) {
    uriInstanceMapping.put(document.getDocumentURI(),document);
  }
  Document expectedDoc;
  Set<Marking> expectedMarkings;
  for (  Document document : dataset.getInstances()) {
    Assert.assertTrue(uriInstanceMapping.containsKey(document.getDocumentURI()));
    expectedDoc=uriInstanceMapping.get(document.getDocumentURI());
    Assert.assertEquals(expectedDoc.getText(),document.getText());
    Assert.assertEquals("String_Node_Str" + expectedDoc.getMarkings().toString() + "String_Node_Str"+ document.getMarkings().toString()+ "String_Node_Str",expectedDoc.getMarkings().size(),document.getMarkings().size());
    expectedMarkings=new HashSet<Marking>(expectedDoc.getMarkings());
    for (    Marking marking : document.getMarkings()) {
      Assert.assertTrue("String_Node_Str" + marking + "String_Node_Str"+ expectedMarkings.toString()+ "String_Node_Str",expectedMarkings.contains(marking));
    }
  }
}
Program: 33219
Project: 33219
Buggy source:
protected Dataset loadDataset() throws Exception {
  Dataset instance=constructor.newInstance(constructorArgs);
  instance.setName(this.getName());
  if (instance instanceof InitializableDataset) {
    ((InitializableDataset)instance).init();
  }
  SameAsRetriever retriever=DatasetBasedSameAsRetriever.create(instance);
  if (retriever != null) {
    if (globalRetriever != null) {
      retriever=new MultipleSameAsRetriever(retriever,globalRetriever);
    }
  }
 else {
    retriever=globalRetriever;
  }
  List<Meaning> meanings;
  for (  Document document : instance.getInstances()) {
    SameAsRetrieverUtils.addSameURIsToMarkings(retriever,document.getMarkings());
    meanings=document.getMarkings(Meaning.class);
    if (retriever != null) {
      for (      Meaning meaning : document.getMarkings(Meaning.class)) {
        retriever.addSameURIs(meaning.getUris());
      }
    }
    if (entityCheckerManager != null) {
      entityCheckerManager.checkMeanings(meanings);
    }
  }
  return instance;
}

Fixed version (ground truth):
protected Dataset loadDataset() throws Exception {
  Dataset instance=constructor.newInstance(constructorArgs);
  instance.setName(this.getName());
  if (instance instanceof InitializableDataset) {
    ((InitializableDataset)instance).init();
  }
  SameAsRetriever retriever=DatasetBasedSameAsRetriever.create(instance);
  if (retriever != null) {
    if (globalRetriever != null) {
      retriever=new MultipleSameAsRetriever(retriever,globalRetriever);
    }
  }
 else {
    retriever=globalRetriever;
  }
  for (  Document document : instance.getInstances()) {
    if (retriever != null) {
      SameAsRetrieverUtils.addSameURIsToMarkings(retriever,document.getMarkings());
    }
    if (entityCheckerManager != null) {
      entityCheckerManager.checkMarkings(document.getMarkings());
    }
  }
  return instance;
}
Program: 33220
Project: 33220
Buggy source:
protected static void addDBpediaUris(Set<String> uris){
  List<String> dbpediaUris=new ArrayList<String>(uris.size());
  for (  String uri : uris) {
    dbpediaUris.add(uri.replace("String_Node_Str","String_Node_Str"));
    dbpediaUris.add(uri.replace("String_Node_Str","String_Node_Str"));
  }
  uris.addAll(dbpediaUris);
}

Fixed version (ground truth):
/** 
 * Adds DBpedia URIs by transforming Wikipeda URIs.
 * @param uris
 */
protected static void addDBpediaUris(Set<String> uris){
  List<String> dbpediaUris=new ArrayList<String>(uris.size());
  for (  String uri : uris) {
    if (uri.contains("String_Node_Str")) {
      dbpediaUris.add(uri.replace("String_Node_Str","String_Node_Str"));
    }
 else {
      dbpediaUris.add(uri.replace("String_Node_Str","String_Node_Str"));
    }
  }
  uris.addAll(dbpediaUris);
}
Program: 33222
Project: 33222
Buggy source:
@Override public void addSameURIs(Set<String> uris){
  Queue<String> queue=new LinkedList<String>();
  queue.addAll(uris);
  String uri;
  Set<String> newUris;
  while (queue.size() > 0) {
    uri=queue.poll();
    newUris=decoratedRetriever.retrieveSameURIs(uri);
    if (newUris != null) {
      for (      String newUri : newUris) {
        if (!uris.contains(newUri)) {
          queue.add(newUri);
          uris.add(newUri);
        }
      }
    }
  }
}

Fixed version (ground truth):
@Override public void addSameURIs(Set<String> uris){
  Queue<String> queue=new LinkedList<String>();
  queue.addAll(uris);
  String uri;
  Set<String> newUris;
  while (queue.size() > 0) {
    uri=queue.poll();
    newUris=decoratedRetriever.retrieveSameURIs(uri);
    if (newUris != null) {
      for (      String newUri : newUris) {
        if (!uris.contains(newUri)) {
          if (debugCrawling && LOGGER.isDebugEnabled()) {
            LOGGER.debug(uri + "String_Node_Str" + newUri);
          }
          queue.add(newUri);
          uris.add(newUri);
        }
      }
    }
  }
}
Program: 33224
Project: 33224
Buggy source:
protected Dataset loadDataset() throws Exception {
  Dataset instance=constructor.newInstance(constructorArgs);
  instance.setName(this.getName());
  if (instance instanceof InitializableDataset) {
    ((InitializableDataset)instance).init();
  }
  SameAsRetriever retriever=DatasetBasedSameAsRetriever.create(instance);
  if (retriever != null) {
    if (globalRetriever != null) {
      retriever=new MultipleSameAsRetriever(retriever,globalRetriever);
    }
  }
 else {
    retriever=globalRetriever;
  }
  List<Meaning> meanings;
  for (  Document document : instance.getInstances()) {
    meanings=document.getMarkings(Meaning.class);
    if (retriever != null) {
      for (      Meaning meaning : document.getMarkings(Meaning.class)) {
        retriever.addSameURIs(meaning.getUris());
      }
    }
    entityCheckerManager.checkMeanings(meanings);
  }
  return instance;
}

Fixed version (ground truth):
protected Dataset loadDataset() throws Exception {
  Dataset instance=constructor.newInstance(constructorArgs);
  instance.setName(this.getName());
  if (instance instanceof InitializableDataset) {
    ((InitializableDataset)instance).init();
  }
  SameAsRetriever retriever=DatasetBasedSameAsRetriever.create(instance);
  if (retriever != null) {
    if (globalRetriever != null) {
      retriever=new MultipleSameAsRetriever(retriever,globalRetriever);
    }
  }
 else {
    retriever=globalRetriever;
  }
  List<Meaning> meanings;
  for (  Document document : instance.getInstances()) {
    meanings=document.getMarkings(Meaning.class);
    if (retriever != null) {
      for (      Meaning meaning : document.getMarkings(Meaning.class)) {
        retriever.addSameURIs(meaning.getUris());
      }
    }
    if (entityCheckerManager != null) {
      entityCheckerManager.checkMeanings(meanings);
    }
  }
  return instance;
}
Program: 33225
Project: 33225
Buggy source:
@Override public int compareTo(AdapterConfiguration o){
  int result=(new ExperimentTypeComparator()).compare(this.applicableForExperiment,o.getExperimentType());
  if (result == 0) {
    return this.getName().compareTo(o.getName());
  }
 else {
    return result;
  }
}

Fixed version (ground truth):
@Override public int compareTo(AdapterConfiguration o){
  int result=EXP_TYPE_COMPARATOR.compare(this.applicableForExperiment,o.getExperimentType());
  if (result == 0) {
    return this.getName().compareTo(o.getName());
  }
 else {
    return result;
  }
}
Program: 33226
Project: 33226
Buggy source:
@Override public int compare(ExperimentType type1,ExperimentType type2){
  if (type1.equalsOrContainsType(type2)) {
    if (type2.equalsOrContainsType(type1)) {
      return type1.name().compareTo(type2.name());
    }
 else {
      return 1;
    }
  }
 else {
    if (type2.equalsOrContainsType(type1)) {
      return type1.name().compareTo(type2.name());
    }
 else {
      return -1;
    }
  }
}

Fixed version (ground truth):
@Override public int compare(ExperimentType type1,ExperimentType type2){
  if (type1.equalsOrContainsType(type2)) {
    if (type2.equalsOrContainsType(type1)) {
      return type1.name().compareTo(type2.name());
    }
 else {
      return 1;
    }
  }
 else {
    if (type2.equalsOrContainsType(type1)) {
      return -1;
    }
 else {
      return type1.name().compareTo(type2.name());
    }
  }
}
Program: 33227
Project: 33227
Buggy source:
@Override public final void close() throws IOException {
  if (granter.givePermissionToClose()) {
    performClose();
  }
}

Fixed version (ground truth):
@Override public final void close() throws IOException {
  if ((granter == null) || (granter.givePermissionToClose())) {
    performClose();
  }
}
Program: 33228
Project: 33228
Buggy source:
protected Document createDocument(String fileName,String text,MSNBC_Result parsedResult){
  String documentUri=generateDocumentUri(fileName);
  List<Marking> markings=new ArrayList<Marking>(parsedResult.getMarkings().size());
  String retrievedSurfaceForm;
  for (  MSNBC_NamedEntity ne : parsedResult.getMarkings()) {
    retrievedSurfaceForm=text.substring(ne.getStartPosition(),ne.getStartPosition() + ne.getLength());
    if (!retrievedSurfaceForm.equals(ne.getSurfaceForm())) {
      LOGGER.warn("String_Node_Str" + documentUri + "String_Node_Str"+ ne+ "String_Node_Str"+ retrievedSurfaceForm+ "String_Node_Str");
    }
    addDBpediaUris(ne.getUris());
    markings.add(ne.toNamedEntity());
  }
  return new DocumentImpl(text,documentUri,markings);
}

Fixed version (ground truth):
protected Document createDocument(String fileName,String text,MSNBC_Result parsedResult){
  String documentUri=generateDocumentUri(fileName);
  List<Marking> markings=new ArrayList<Marking>(parsedResult.getMarkings().size());
  String retrievedSurfaceForm;
  for (  MSNBC_NamedEntity ne : parsedResult.getMarkings()) {
    retrievedSurfaceForm=text.substring(ne.getStartPosition(),ne.getStartPosition() + ne.getLength());
    if (!retrievedSurfaceForm.equals(ne.getSurfaceForm())) {
      LOGGER.warn("String_Node_Str" + documentUri + "String_Node_Str"+ ne+ "String_Node_Str"+ retrievedSurfaceForm+ "String_Node_Str");
    }
    addDBpediaUris(ne.getUris());
    markings.add(ne.toNamedEntity());
  }
  Document document=new DocumentImpl(text,documentUri,markings);
  mergeSubNamedEntity(document);
  return document;
}
Program: 33231
Project: 33231
Buggy source:
public static MatchingsSearcher<? extends Span> createSpanMatchingsSearcher(Matching matching){
switch (matching) {
case STRONG_ENTITY_MATCH:
case WEAK_ANNOTATION_MATCH:
{
      return new WeakSpanMatchingsCounter<>();
    }
case STRONG_ANNOTATION_MATCH:
{
    return new StrongSpanMatchingsCounter<>();
  }
default :
{
  throw new IllegalArgumentException("String_Node_Str" + matching.toString() + "String_Node_Str");
}
}
}

Fixed version (ground truth):
public static MatchingsSearcher<? extends Span> createSpanMatchingsSearcher(Matching matching){
switch (matching) {
case WEAK_ANNOTATION_MATCH:
{
      return new WeakSpanMatchingsCounter<>();
    }
case STRONG_ENTITY_MATCH:
case STRONG_ANNOTATION_MATCH:
{
    return new StrongSpanMatchingsCounter<>();
  }
default :
{
  throw new IllegalArgumentException("String_Node_Str" + matching.toString() + "String_Node_Str");
}
}
}
Program: 33232
Project: 33232
Buggy source:
public List<TypedNamedEntity> disambiguate(Document document) throws GerbilException {
  String text=document.getText();
  StringBuilder requestBuilder=new StringBuilder();
  requestBuilder.append("String_Node_Str");
  try {
    requestBuilder.append(URLEncoder.encode(document.getText(),"String_Node_Str"));
  }
 catch (  UnsupportedEncodingException e) {
    LOGGER.error("String_Node_Str",e);
    throw new GerbilException("String_Node_Str",e,ErrorTypes.UNEXPECTED_EXCEPTION);
  }
  requestBuilder.append("String_Node_Str");
  List<Span> spans=document.getMarkings(Span.class);
  int start;
  for (  Span span : spans) {
    start=span.getStartPosition();
    requestBuilder.append("String_Node_Str");
    requestBuilder.append(text.substring(start,start + span.getLength()));
    requestBuilder.append("String_Node_Str");
    requestBuilder.append(start);
    requestBuilder.append("String_Node_Str");
  }
  requestBuilder.append("String_Node_Str");
  String response=request(requestBuilder.toString(),serviceURL + DISAMBIGUATE_RESOURCE);
  return parseAnnotationResponse(response);
}

Fixed version (ground truth):
public List<TypedNamedEntity> disambiguate(Document document) throws GerbilException {
  String text=document.getText();
  StringBuilder requestBuilder=new StringBuilder();
  requestBuilder.append("String_Node_Str");
  try {
    requestBuilder.append(URLEncoder.encode(document.getText(),"String_Node_Str"));
  }
 catch (  UnsupportedEncodingException e) {
    LOGGER.error("String_Node_Str",e);
    throw new GerbilException("String_Node_Str",e,ErrorTypes.UNEXPECTED_EXCEPTION);
  }
  requestBuilder.append("String_Node_Str");
  List<Span> spans=document.getMarkings(Span.class);
  int start;
  for (  Span span : spans) {
    start=span.getStartPosition();
    requestBuilder.append("String_Node_Str");
    try {
      requestBuilder.append(URLEncoder.encode(text.substring(start,start + span.getLength()),"String_Node_Str"));
    }
 catch (    UnsupportedEncodingException e) {
      LOGGER.error("String_Node_Str",e);
      throw new GerbilException("String_Node_Str",e,ErrorTypes.UNEXPECTED_EXCEPTION);
    }
    requestBuilder.append("String_Node_Str");
    requestBuilder.append(start);
    requestBuilder.append("String_Node_Str");
  }
  requestBuilder.append("String_Node_Str");
  String response=request(requestBuilder.toString(),serviceURL + DISAMBIGUATE_RESOURCE);
  return parseAnnotationResponse(response);
}
Program: 33233
Project: 33233
Buggy source:
public void run() throws Exception {
  AdapterManager adapterManager=new AdapterManager();
  adapterManager.setAnnotators(AnnotatorsConfig.annotators());
  adapterManager.setDatasets(DatasetsConfig.datasets());
  AnnotatorConfiguration annotatorConfig=adapterManager.getAnnotatorConfig(ANNOTATOR_NAME,EXPERIMENT_TYPE);
  Assert.assertNotNull(annotatorConfig);
  DatasetConfiguration datasetConfig=adapterManager.getDatasetConfig(DATASET_NAME,EXPERIMENT_TYPE);
  Assert.assertNotNull(datasetConfig);
  DefeatableOverseer overseer=RootConfig.createOverseer();
  overseer.addObserver(this);
  ExperimentTaskConfiguration taskConfigs[]=new ExperimentTaskConfiguration[]{new ExperimentTaskConfiguration(annotatorConfig,datasetConfig,EXPERIMENT_TYPE,MATCHING)};
  Experimenter experimenter=new Experimenter(overseer,new SimpleLoggingDAO4Debugging(),RootConfig.createSameAsRetriever(),new EvaluatorFactory(),taskConfigs,"String_Node_Str");
  experimenter.run();
  mutex.acquire();
  overseer.shutdown();
}

Fixed version (ground truth):
public void run() throws Exception {
  AdapterManager adapterManager=new AdapterManager();
  adapterManager.setAnnotators(AnnotatorsConfig.annotators());
  adapterManager.setDatasets(DatasetsConfig.datasets());
  AnnotatorConfiguration annotatorConfig=adapterManager.getAnnotatorConfig(ANNOTATOR_NAME,EXPERIMENT_TYPE);
  Assert.assertNotNull(annotatorConfig);
  DatasetConfiguration datasetConfig=adapterManager.getDatasetConfig(DATASET_NAME,EXPERIMENT_TYPE);
  Assert.assertNotNull(datasetConfig);
  DefeatableOverseer overseer=RootConfig.createOverseer();
  overseer.addObserver(this);
  ExperimentTaskConfiguration taskConfigs[]=new ExperimentTaskConfiguration[]{new ExperimentTaskConfiguration(annotatorConfig,datasetConfig,EXPERIMENT_TYPE,MATCHING)};
  SameAsRetriever retriever=RootConfig.createSameAsRetriever();
  Experimenter experimenter=new Experimenter(overseer,new SimpleLoggingDAO4Debugging(),retriever,new EvaluatorFactory(),taskConfigs,"String_Node_Str");
  experimenter.run();
  mutex.acquire();
  closeHttpRetriever(retriever);
  overseer.shutdown();
}
Program: 33234
Project: 33234
Buggy source:
@Override public final void close() throws IOException {
  if (granter.givePermissionToClose()) {
    performClose();
  }
}

Fixed version (ground truth):
@Override public final void close() throws IOException {
  if ((granter == null) || (granter.givePermissionToClose())) {
    performClose();
  }
}
Program: 33236
Project: 33236
Buggy source:
private double[] calculateMeasures(int[] counts){
  double precision, recall, F1_score;
  if (counts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] == 0) {
    if ((counts[MatchingsCounter.FALSE_POSITIVE_COUNT_ID] == 0) && (counts[MatchingsCounter.FALSE_NEGATIVE_COUNT_ID] == 0)) {
      precision=1.0;
      recall=1.0;
      F1_score=1.0;
    }
 else {
      precision=0.0;
      recall=0.0;
      F1_score=0.0;
    }
  }
 else {
    precision=(double)counts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] / (double)(counts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] + counts[MatchingsCounter.FALSE_POSITIVE_COUNT_ID]);
    recall=(double)counts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] / (double)(counts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] + counts[MatchingsCounter.FALSE_NEGATIVE_COUNT_ID]);
    F1_score=(2 * precision * recall) / (precision + recall);
  }
  return new double[]{precision,recall,F1_score};
}

Fixed version (ground truth):
private double[] calculateMeasures(EvaluationCounts counts){
  double precision, recall, F1_score;
  if (counts.truePositives == 0) {
    if ((counts.falsePositives == 0) && (counts.falseNegatives == 0)) {
      precision=1.0;
      recall=1.0;
      F1_score=1.0;
    }
 else {
      precision=0.0;
      recall=0.0;
      F1_score=0.0;
    }
  }
 else {
    precision=(double)counts.truePositives / (double)(counts.truePositives + counts.falsePositives);
    recall=(double)counts.truePositives / (double)(counts.truePositives + counts.falseNegatives);
    F1_score=(2 * precision * recall) / (precision + recall);
  }
  return new double[]{precision,recall,F1_score};
}
Program: 33237
Project: 33237
Buggy source:
protected EvaluationResult[] calculateMicroFMeasure(List<int[]> matchingCounts,String precisionName,String recallName,String f1ScoreName){
  int sums[]=new int[3];
  for (  int[] counts : matchingCounts) {
    sums[MatchingsCounter.TRUE_POSITIVE_COUNT_ID]+=counts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID];
    sums[MatchingsCounter.FALSE_POSITIVE_COUNT_ID]+=counts[MatchingsCounter.FALSE_POSITIVE_COUNT_ID];
    sums[MatchingsCounter.FALSE_NEGATIVE_COUNT_ID]+=counts[MatchingsCounter.FALSE_NEGATIVE_COUNT_ID];
  }
  double measures[]=calculateMeasures(sums);
  return new EvaluationResult[]{new DoubleEvaluationResult(precisionName,measures[0]),new DoubleEvaluationResult(recallName,measures[1]),new DoubleEvaluationResult(f1ScoreName,measures[2])};
}

Fixed version (ground truth):
protected EvaluationResult[] calculateMicroFMeasure(EvaluationCounts counts[],String precisionName,String recallName,String f1ScoreName){
  EvaluationCounts sums=new EvaluationCounts();
  for (int i=0; i < counts.length; ++i) {
    sums.add(counts[i]);
  }
  double measures[]=calculateMeasures(sums);
  return new EvaluationResult[]{new DoubleEvaluationResult(precisionName,measures[0]),new DoubleEvaluationResult(recallName,measures[1]),new DoubleEvaluationResult(f1ScoreName,measures[2])};
}
Program: 33238
Project: 33238
Buggy source:
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  for (int i=0; i < annotatorResults.size(); ++i) {
    matchingsCounter.countMatchings(annotatorResults.get(i),goldStandard.get(i));
  }
  List<int[]> matchingCounts=matchingsCounter.getCounts();
  results.addResults(calculateMicroFMeasure(matchingCounts));
  results.addResults(calculateMacroFMeasure(matchingCounts));
}

Fixed version (ground truth):
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  EvaluationCounts counts[]=generateMatchingCounts(annotatorResults,goldStandard);
  results.addResults(calculateMicroFMeasure(counts));
  results.addResults(calculateMacroFMeasure(counts));
}
Program: 33239
Project: 33239
Buggy source:
protected EvaluationResult[] calculateMacroFMeasure(List<int[]> matchingCounts,String precisionName,String recallName,String f1ScoreName){
  double avgs[]=new double[3];
  double measures[];
  for (  int[] counts : matchingCounts) {
    measures=calculateMeasures(counts);
    avgs[0]+=measures[0];
    avgs[1]+=measures[1];
    avgs[2]+=measures[2];
  }
  avgs[0]/=matchingCounts.size();
  avgs[1]/=matchingCounts.size();
  avgs[2]/=matchingCounts.size();
  return new EvaluationResult[]{new DoubleEvaluationResult(precisionName,avgs[0]),new DoubleEvaluationResult(recallName,avgs[1]),new DoubleEvaluationResult(f1ScoreName,avgs[2])};
}

Fixed version (ground truth):
protected EvaluationResult[] calculateMacroFMeasure(EvaluationCounts counts[],String precisionName,String recallName,String f1ScoreName){
  double avgs[]=new double[3];
  double measures[];
  for (int i=0; i < counts.length; ++i) {
    measures=calculateMeasures(counts[i]);
    avgs[0]+=measures[0];
    avgs[1]+=measures[1];
    avgs[2]+=measures[2];
  }
  avgs[0]/=counts.length;
  avgs[1]/=counts.length;
  avgs[2]/=counts.length;
  return new EvaluationResult[]{new DoubleEvaluationResult(precisionName,avgs[0]),new DoubleEvaluationResult(recallName,avgs[1]),new DoubleEvaluationResult(f1ScoreName,avgs[2])};
}
Program: 33240
Project: 33240
Buggy source:
private List<List<double[]>> calculateMeasures(List<List<int[]>> matchingCounts){
  List<List<double[]>> measures=new ArrayList<List<double[]>>(matchingCounts.size());
  List<double[]> localMeasures;
  double[] singleMeasures;
  for (  List<int[]> counts : matchingCounts) {
    if (counts.size() > 0) {
      localMeasures=new ArrayList<double[]>(counts.size());
      for (      int[] singleCounts : counts) {
        singleMeasures=new double[2];
        if (singleCounts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] == 0) {
          if ((singleCounts[MatchingsCounter.FALSE_POSITIVE_COUNT_ID] == 0) && (singleCounts[MatchingsCounter.FALSE_NEGATIVE_COUNT_ID] == 0)) {
            singleMeasures[PRECISION_ID]=1.0;
            singleMeasures[RECALL_ID]=1.0;
          }
 else {
            singleMeasures[PRECISION_ID]=0.0;
            singleMeasures[RECALL_ID]=0.0;
          }
        }
 else {
          singleMeasures[PRECISION_ID]=(double)singleCounts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] / (double)(singleCounts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] + singleCounts[MatchingsCounter.FALSE_POSITIVE_COUNT_ID]);
          singleMeasures[RECALL_ID]=(double)singleCounts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] / (double)(singleCounts[MatchingsCounter.TRUE_POSITIVE_COUNT_ID] + singleCounts[MatchingsCounter.FALSE_NEGATIVE_COUNT_ID]);
        }
        localMeasures.add(singleMeasures);
      }
      measures.add(localMeasures);
    }
  }
  return measures;
}

Fixed version (ground truth):
private List<List<double[]>> calculateMeasures(List<List<EvaluationCounts>> matchingCounts){
  List<List<double[]>> measures=new ArrayList<List<double[]>>(matchingCounts.size());
  List<double[]> localMeasures;
  double[] singleMeasures;
  for (  List<EvaluationCounts> counts : matchingCounts) {
    if (counts.size() > 0) {
      localMeasures=new ArrayList<double[]>(counts.size());
      for (      EvaluationCounts singleCounts : counts) {
        singleMeasures=new double[2];
        if (singleCounts.truePositives == 0) {
          if ((singleCounts.falsePositives == 0) && (singleCounts.falseNegatives == 0)) {
            singleMeasures[PRECISION_ID]=1.0;
            singleMeasures[RECALL_ID]=1.0;
          }
 else {
            singleMeasures[PRECISION_ID]=0.0;
            singleMeasures[RECALL_ID]=0.0;
          }
        }
 else {
          singleMeasures[PRECISION_ID]=(double)singleCounts.truePositives / (double)(singleCounts.truePositives + singleCounts.falsePositives);
          singleMeasures[RECALL_ID]=(double)singleCounts.truePositives / (double)(singleCounts.truePositives + singleCounts.falseNegatives);
        }
        localMeasures.add(singleMeasures);
      }
      measures.add(localMeasures);
    }
  }
  return measures;
}
Program: 33241
Project: 33241
Buggy source:
public HierarchicalFMeasureCalculator(HierarchicalMatchingsCounter<T> matchingsCounter){
  super();
  this.matchingsCounter=matchingsCounter;
}

Fixed version (ground truth):
public HierarchicalFMeasureCalculator(HierarchicalMatchingsCounter<T> matchingsCounter){
  this.matchingsCounter=matchingsCounter;
}
Program: 33242
Project: 33242
Buggy source:
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  for (int i=0; i < annotatorResults.size(); ++i) {
    matchingsCounter.countMatchings(annotatorResults.get(i),goldStandard.get(i));
  }
  List<List<int[]>> matchingCounts=matchingsCounter.getCounts();
  List<List<double[]>> measures=calculateMeasures(matchingCounts);
  results.addResults(calculateMicroFMeasure(measures));
  results.addResults(calculateMacroFMeasure(measures));
}

Fixed version (ground truth):
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  List<List<EvaluationCounts>> matchingCounts=new ArrayList<List<EvaluationCounts>>(annotatorResults.size());
  for (int i=0; i < annotatorResults.size(); ++i) {
    matchingCounts.add(matchingsCounter.countMatchings(annotatorResults.get(i),goldStandard.get(i)));
  }
  List<List<double[]>> measures=calculateMeasures(matchingCounts);
  results.addResults(calculateMicroFMeasure(measures));
  results.addResults(calculateMacroFMeasure(measures));
}
Program: 33243
Project: 33243
Buggy source:
private EvaluationResult[] calculateAccuracies(List<int[]> matchingCounts,List<List<T>> goldStandard){
  int tp, elements, tpSum=0, elementsSum=0, docCount=0;
  double microAcc=0, macroAcc=0;
  for (int i=0; i < matchingCounts.size(); ++i) {
    elements=goldStandard.get(i).size();
    if (elements > 0) {
      tp=matchingCounts.get(i)[MatchingsCounter.TRUE_POSITIVE_COUNT_ID];
      tpSum+=tp;
      elementsSum+=elements;
      macroAcc+=(double)tp / (double)elements;
      ++docCount;
    }
  }
  macroAcc/=docCount;
  microAcc=(double)tpSum / (double)elementsSum;
  return new EvaluationResult[]{new DoubleEvaluationResult(MACRO_ACCURACY_NAME,macroAcc),new DoubleEvaluationResult(MICRO_ACCURACY_NAME,microAcc)};
}

Fixed version (ground truth):
private EvaluationResult[] calculateAccuracies(EvaluationCounts counts[],List<List<T>> goldStandard){
  int tp, elements, tpSum=0, elementsSum=0, docCount=0;
  double microAcc=0, macroAcc=0;
  for (int i=0; i < counts.length; ++i) {
    elements=goldStandard.get(i).size();
    if (elements > 0) {
      tp=counts[i].truePositives;
      tpSum+=tp;
      elementsSum+=elements;
      macroAcc+=(double)tp / (double)elements;
      ++docCount;
    }
  }
  macroAcc/=docCount;
  microAcc=(double)tpSum / (double)elementsSum;
  return new EvaluationResult[]{new DoubleEvaluationResult(MACRO_ACCURACY_NAME,macroAcc),new DoubleEvaluationResult(MICRO_ACCURACY_NAME,microAcc)};
}
Program: 33244
Project: 33244
Buggy source:
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  super.evaluate(annotatorResults,goldStandard,results);
  results.addResults(calculateAccuracies(matchingsCounter.getCounts(),goldStandard));
  results.addResults(calculateMicroFMeasure(((ClassConsideringMatchingsCounter<T>)matchingsCounter).getCounts(IN_KB_CLASS_ID),IN_KB_MICRO_PRECISION_NAME,IN_KB_MICRO_RECALL_NAME,IN_KB_MICRO_F1_SCORE_NAME));
  results.addResults(calculateMacroFMeasure(((ClassConsideringMatchingsCounter<T>)matchingsCounter).getCounts(IN_KB_CLASS_ID),IN_KB_MACRO_PRECISION_NAME,IN_KB_MACRO_RECALL_NAME,IN_KB_MACRO_F1_SCORE_NAME));
  results.addResults(calculateMicroFMeasure(((ClassConsideringMatchingsCounter<T>)matchingsCounter).getCounts(EE_CLASS_ID),EE_MICRO_PRECISION_NAME,EE_MICRO_RECALL_NAME,EE_MICRO_F1_SCORE_NAME));
  results.addResults(calculateMacroFMeasure(((ClassConsideringMatchingsCounter<T>)matchingsCounter).getCounts(EE_CLASS_ID),EE_MACRO_PRECISION_NAME,EE_MACRO_RECALL_NAME,EE_MACRO_F1_SCORE_NAME));
}

Fixed version (ground truth):
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  EvaluationCounts counts[]=generateMatchingCounts(annotatorResults,goldStandard);
  results.addResults(calculateMicroFMeasure(counts));
  results.addResults(calculateMacroFMeasure(counts));
  results.addResults(calculateAccuracies(counts,goldStandard));
  EvaluationCounts classCounts[]=new EvaluationCounts[counts.length];
  int sums=0;
  for (int i=0; i < counts.length; ++i) {
    classCounts[i]=((ClassifiedEvaluationCounts)counts[i]).classifiedCounts[IN_KB_CLASS_ID];
    sums+=classCounts[i].truePositives + classCounts[i].falseNegatives + classCounts[i].falsePositives;
  }
  if (sums > 0) {
    results.addResults(calculateMicroFMeasure(classCounts,IN_KB_MICRO_PRECISION_NAME,IN_KB_MICRO_RECALL_NAME,IN_KB_MICRO_F1_SCORE_NAME));
    results.addResults(calculateMacroFMeasure(classCounts,IN_KB_MACRO_PRECISION_NAME,IN_KB_MACRO_RECALL_NAME,IN_KB_MACRO_F1_SCORE_NAME));
  }
  sums=0;
  for (int i=0; i < counts.length; ++i) {
    classCounts[i]=((ClassifiedEvaluationCounts)counts[i]).classifiedCounts[EE_CLASS_ID];
    sums+=classCounts[i].truePositives + classCounts[i].falseNegatives + classCounts[i].falsePositives;
  }
  if (sums > 0) {
    results.addResults(calculateMicroFMeasure(classCounts,IN_KB_MICRO_PRECISION_NAME,IN_KB_MICRO_RECALL_NAME,IN_KB_MICRO_F1_SCORE_NAME));
    results.addResults(calculateMacroFMeasure(classCounts,IN_KB_MACRO_PRECISION_NAME,IN_KB_MACRO_RECALL_NAME,IN_KB_MACRO_F1_SCORE_NAME));
  }
}
Program: 33246
Project: 33246
Buggy source:
private void parseAnnotation(JSONObject entityObject,Document resultDoc){
  if (entityObject.has(ANNOTATION_TITLE_KEY) && entityObject.has(START_KEY) && entityObject.has(END_KEY)) {
    String uri=transformTitleToUri(entityObject.getString(ANNOTATION_TITLE_KEY));
    int start=entityObject.getInt(START_KEY);
    int end=entityObject.getInt(END_KEY);
    resultDoc.addMarking(new NamedEntity(start,end - start,uri));
  }
}

Fixed version (ground truth):
private void parseAnnotation(JSONObject entityObject,Document resultDoc){
  if (entityObject.has(ANNOTATION_TITLE_KEY) && entityObject.has(START_KEY) && entityObject.has(END_KEY)) {
    String uri=transformTitleToUri(entityObject.getString(ANNOTATION_TITLE_KEY));
    int start=entityObject.getInt(START_KEY);
    int end=entityObject.getInt(END_KEY);
    if (entityObject.has(ANNOTATION_GOODNESS_KEY)) {
      resultDoc.addMarking(new ScoredNamedEntity(start,end - start,uri,entityObject.getDouble(ANNOTATION_GOODNESS_KEY)));
    }
 else {
      resultDoc.addMarking(new NamedEntity(start,end - start,uri));
    }
  }
}
Program: 33247
Project: 33247
Buggy source:
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  EvaluationCounts counts[]=generateMatchingCounts(annotatorResults,goldStandard);
  results.addResults(calculateMicroFMeasure(counts));
  results.addResults(calculateMacroFMeasure(counts));
  results.addResults(calculateAccuracies(counts,goldStandard));
  EvaluationCounts classCounts[]=new EvaluationCounts[counts.length];
  int sums=0;
  for (int i=0; i < counts.length; ++i) {
    classCounts[i]=((ClassifiedEvaluationCounts)counts[i]).classifiedCounts[IN_KB_CLASS_ID];
    sums+=classCounts[i].truePositives + classCounts[i].falseNegatives + classCounts[i].falsePositives;
  }
  if (sums > 0) {
    results.addResults(calculateMicroFMeasure(classCounts,IN_KB_MICRO_PRECISION_NAME,IN_KB_MICRO_RECALL_NAME,IN_KB_MICRO_F1_SCORE_NAME));
    results.addResults(calculateMacroFMeasure(classCounts,IN_KB_MACRO_PRECISION_NAME,IN_KB_MACRO_RECALL_NAME,IN_KB_MACRO_F1_SCORE_NAME));
  }
  sums=0;
  for (int i=0; i < counts.length; ++i) {
    classCounts[i]=((ClassifiedEvaluationCounts)counts[i]).classifiedCounts[EE_CLASS_ID];
    sums+=classCounts[i].truePositives + classCounts[i].falseNegatives + classCounts[i].falsePositives;
  }
  if (sums > 0) {
    results.addResults(calculateMicroFMeasure(classCounts,IN_KB_MICRO_PRECISION_NAME,IN_KB_MICRO_RECALL_NAME,IN_KB_MICRO_F1_SCORE_NAME));
    results.addResults(calculateMacroFMeasure(classCounts,IN_KB_MACRO_PRECISION_NAME,IN_KB_MACRO_RECALL_NAME,IN_KB_MACRO_F1_SCORE_NAME));
  }
}

Fixed version (ground truth):
@Override public void evaluate(List<List<T>> annotatorResults,List<List<T>> goldStandard,EvaluationResultContainer results){
  EvaluationCounts counts[]=generateMatchingCounts(annotatorResults,goldStandard);
  results.addResults(calculateMicroFMeasure(counts));
  results.addResults(calculateMacroFMeasure(counts));
  results.addResults(calculateAccuracies(counts,goldStandard));
  EvaluationCounts classCounts[]=new EvaluationCounts[counts.length];
  int sums=0;
  for (int i=0; i < counts.length; ++i) {
    classCounts[i]=((ClassifiedEvaluationCounts)counts[i]).classifiedCounts[IN_KB_CLASS_ID];
    sums+=classCounts[i].truePositives + classCounts[i].falseNegatives + classCounts[i].falsePositives;
  }
  if (sums > 0) {
    results.addResults(calculateMicroFMeasure(classCounts,IN_KB_MICRO_PRECISION_NAME,IN_KB_MICRO_RECALL_NAME,IN_KB_MICRO_F1_SCORE_NAME));
    results.addResults(calculateMacroFMeasure(classCounts,IN_KB_MACRO_PRECISION_NAME,IN_KB_MACRO_RECALL_NAME,IN_KB_MACRO_F1_SCORE_NAME));
  }
  sums=0;
  for (int i=0; i < counts.length; ++i) {
    classCounts[i]=((ClassifiedEvaluationCounts)counts[i]).classifiedCounts[EE_CLASS_ID];
    sums+=classCounts[i].truePositives + classCounts[i].falseNegatives + classCounts[i].falsePositives;
  }
  if (sums > 0) {
    results.addResults(calculateMicroFMeasure(classCounts,EE_MICRO_PRECISION_NAME,EE_MICRO_RECALL_NAME,EE_MICRO_F1_SCORE_NAME));
    results.addResults(calculateMacroFMeasure(classCounts,EE_MACRO_PRECISION_NAME,EE_MACRO_RECALL_NAME,EE_MACRO_F1_SCORE_NAME));
  }
}
Program: 33248
Project: 33248
Buggy source:
public void analyzeDataset(DatasetConfiguration config) throws GerbilException {
  analyzeAsD2W(config);
  analyzeAsC2W(config);
}

Fixed version (ground truth):
public void analyzeDataset(DatasetConfiguration config) throws GerbilException {
  analyzeAsD2W(config);
}
Program: 33249
Project: 33249
Buggy source:
public static void main(String[] args){
  List<DatasetConfiguration> datasetConfigs=DatasetsConfig.datasets().getConfigurations();
  PrintStream output=null;
  try {
    output=new PrintStream("String_Node_Str");
    DatasetAnalyzer analyzer=new DatasetAnalyzer(output);
    for (    DatasetConfiguration config : datasetConfigs) {
      try {
        analyzer.analyzeDataset(config);
        SingletonWikipediaApi.getInstance().flush();
      }
 catch (      GerbilException e) {
        e.printStackTrace();
      }
catch (      IOException e) {
        e.printStackTrace();
      }
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
 finally {
    IOUtils.closeQuietly(output);
  }
}

Fixed version (ground truth):
public static void main(String[] args){
  List<DatasetConfiguration> datasetConfigs=DatasetsConfig.datasets().getConfigurations();
  PrintStream output=null;
  try {
    output=new PrintStream("String_Node_Str");
    output.println("String_Node_Str");
    DatasetAnalyzer analyzer=new DatasetAnalyzer(output);
    for (    DatasetConfiguration config : datasetConfigs) {
      try {
        analyzer.analyzeDataset(config);
      }
 catch (      GerbilException e) {
        e.printStackTrace();
      }
    }
  }
 catch (  FileNotFoundException e) {
    e.printStackTrace();
  }
 finally {
    IOUtils.closeQuietly(output);
  }
}
Program: 33250
Project: 33250
Buggy source:
private void analyzeAsD2W(DatasetConfiguration config) throws GerbilException {
  C2WDataset dataset=(C2WDataset)config.getDataset(ExperimentType.C2KB);
  if (dataset == null) {
    return;
  }
  output.print("String_Node_Str" + config.getName());
  output.print("String_Node_Str" + dataset.getSize());
  List<HashSet<Tag>> goldStandard=dataset.getC2WGoldStandardList();
  double annotationsSum=0;
  for (  HashSet<Tag> annotations : goldStandard) {
    annotationsSum+=annotations.size();
  }
  int tokensSum=0;
  for (  String text : dataset.getTextInstanceList()) {
    tokensSum+=countTokensInText(text);
  }
  output.print("String_Node_Str" + annotationsSum);
  output.print("String_Node_Str" + (annotationsSum / dataset.getSize()));
  output.print("String_Node_Str" + tokensSum);
  output.print("String_Node_Str" + ((double)tokensSum / (double)dataset.getSize()));
  output.println("String_Node_Str" + ((double)annotationsSum / (double)tokensSum));
}

Fixed version (ground truth):
private void analyzeAsD2W(DatasetConfiguration config) throws GerbilException {
  Dataset dataset=config.getDataset(ExperimentType.D2KB);
  if (dataset == null) {
    return;
  }
  output.print(config.getName());
  output.print(',');
  List<Document> documents=dataset.getInstances();
  int annotationsSum=0;
  int tokensSum=0;
  for (  Document document : documents) {
    annotationsSum+=document.getMarkings().size();
    tokensSum+=countTokensInText(document.getText());
  }
  output.print((double)annotationsSum / (double)documents.size());
  output.print(',');
  output.print(((double)annotationsSum / (double)tokensSum));
  output.print(',');
  output.print(((double)tokensSum / (double)documents.size()));
  output.print(',');
  output.print(documents.size());
  output.print(',');
  output.print(annotationsSum);
  output.print(',');
  output.println();
}