Program: 161835
Project: 161835
Buggy source:
private void checkLabelCandidates(DirectedSparseGraph<Node,String> graph,double threshholdTrigram,HashMap<String,Node> nodes,NamedEntityInText entity,String label,boolean searchInSurfaceForms,String entities) throws IOException {
  List<Triple> candidates=new ArrayList<Triple>();
  List<Triple> acronymCandidatesTemp=new ArrayList<Triple>();
  List<Triple> acronymCandidatesTemp2=new ArrayList<Triple>();
  List<Triple> candidatesContext=new ArrayList<Triple>();
  List<Triple> candidatesContextbyLabel=new ArrayList<Triple>();
  List<Triple> linkedsbyContext=new ArrayList<Triple>();
  int countFinalCandidates=0;
  PreprocessingNLP nlp=new PreprocessingNLP();
  label=corporationAffixCleaner.cleanLabelsfromCorporationIdentifier(label);
  log.info("String_Node_Str" + label);
  label=nlp.Preprocessing(label);
  if (acronym == true) {
    if (label.equals(label.toUpperCase()) && label.length() <= 4) {
      acronymCandidatesTemp=searchbyAcronym(label,searchInSurfaceForms,entity.getType());
      for (      Triple triple : acronymCandidatesTemp) {
        acronymCandidatesTemp2=searchAcronymByLabel(triple.getSubject(),searchInSurfaceForms,entity.getType());
        for (        Triple triple2 : acronymCandidatesTemp2) {
          if (nGramDistance.getDistance(triple.getSubject(),triple2.getObject()) > threshholdTrigram) {
            if (isDisambiguationResource(triple2.getSubject())) {
              continue;
            }
            triple2.setSubject(redirect(triple2.getSubject()));
            if (commonEntities == true) {
              addNodeToGraph(graph,nodes,entity,triple2,triple2.getSubject());
              countFinalCandidates++;
            }
 else {
              if (domainWhiteLister.fitsIntoDomain(triple2.getSubject())) {
                addNodeToGraph(graph,nodes,entity,triple2,triple2.getSubject());
                countFinalCandidates++;
              }
            }
          }
        }
        acronymCandidatesTemp2.clear();
      }
      log.info("String_Node_Str" + countFinalCandidates);
    }
  }
  if (countFinalCandidates == 0) {
    candidates=searchCandidatesByLabel(label,searchInSurfaceForms,"String_Node_Str",popularity);
    if (searchInSurfaceForms) {
      log.info("String_Node_Str" + candidates.size());
    }
 else {
      log.info("String_Node_Str" + candidates.size());
    }
    if (candidates.size() == 0) {
      log.info("String_Node_Str" + label);
      if (label.endsWith("String_Node_Str")) {
        label=label.substring(0,label.lastIndexOf("String_Node_Str"));
        candidates=searchCandidatesByLabel(label,searchInSurfaceForms,"String_Node_Str",popularity);
        log.info("String_Node_Str");
      }
 else       if (label.endsWith("String_Node_Str")) {
        label=label.substring(0,label.lastIndexOf("String_Node_Str"));
        candidates=searchCandidatesByLabel(label,searchInSurfaceForms,"String_Node_Str",popularity);
        log.info("String_Node_Str");
      }
    }
    if (candidates.isEmpty()) {
      Stemming stemmer=new Stemming();
      String temp=stemmer.stemming(label);
      candidates=searchCandidatesByLabel(temp,searchInSurfaceForms,"String_Node_Str",popularity);
      log.info("String_Node_Str" + candidates.size());
    }
    boolean added=false;
    for (    Triple c : candidates) {
      log.debug("String_Node_Str" + c);
      String candidateURL=c.getSubject();
      String surfaceForm=c.getObject();
      surfaceForm=nlp.Preprocessing(surfaceForm);
      if (candidateURL.startsWith(nodeType)) {
        if (c.getPredicate().equals("String_Node_Str")) {
          if (nGramDistance.getDistance(surfaceForm,label) < 1.0) {
            continue;
          }
        }
 else         if (!c.getPredicate().equals("String_Node_Str")) {
          if (nGramDistance.getDistance(surfaceForm,label) < threshholdTrigram) {
            continue;
          }
        }
        if (isDisambiguationResource(candidateURL)) {
          continue;
        }
        candidateURL=redirect(candidateURL);
        if (commonEntities == true) {
          addNodeToGraph(graph,nodes,entity,c,candidateURL);
          added=true;
          countFinalCandidates++;
        }
 else {
          if (domainWhiteLister.fitsIntoDomain(candidateURL)) {
            addNodeToGraph(graph,nodes,entity,c,candidateURL);
            added=true;
            countFinalCandidates++;
          }
        }
      }
    }
    if (!added && !searchInSurfaceForms && context == true) {
      log.info("String_Node_Str");
      candidatesContext=searchCandidatesByContext(entities,label);
      log.info("String_Node_Str" + candidatesContext.size());
      if (candidatesContext != null) {
        for (        Triple triple : candidatesContext) {
          String url=nodeType + triple.getPredicate();
          candidatesContextbyLabel.addAll(searchCandidatesByUrl(url,searchInSurfaceForms));
        }
      }
      for (      Triple c : candidatesContextbyLabel) {
        log.debug("String_Node_Str" + c);
        String candidateURL=c.getSubject();
        String cleanCandidateURL=candidateURL.replace(nodeType,"String_Node_Str");
        cleanCandidateURL=nlp.Preprocessing(cleanCandidateURL);
        if (candidateURL.startsWith(nodeType)) {
          if (nGramDistance.getDistance(cleanCandidateURL,label) < 0.3) {
            continue;
          }
          for (          Triple temp : candidatesContext) {
            String candidateTemp=nodeType + temp.getPredicate();
            linkedsbyContext.addAll(searchbyConnections(candidateURL,candidateTemp));
          }
          if (linkedsbyContext.size() < 1) {
            continue;
          }
          if (isDisambiguationResource(candidateURL)) {
            continue;
          }
          candidateURL=redirect(candidateURL);
          if (commonEntities == true) {
            addNodeToGraph(graph,nodes,entity,c,candidateURL);
            added=true;
            countFinalCandidates++;
          }
 else {
            if (domainWhiteLister.fitsIntoDomain(candidateURL)) {
              addNodeToGraph(graph,nodes,entity,c,candidateURL);
              added=true;
              countFinalCandidates++;
            }
          }
        }
        linkedsbyContext.clear();
      }
    }
    if (!added && !searchInSurfaceForms) {
      log.info("String_Node_Str");
      checkLabelCandidates(graph,threshholdTrigram,nodes,entity,label,true,entities);
    }
  }
  log.info("String_Node_Str" + countFinalCandidates);
}

Fixed version (ground truth):
private void checkLabelCandidates(DirectedSparseGraph<Node,String> graph,double threshholdTrigram,HashMap<String,Node> nodes,NamedEntityInText entity,String label,boolean searchInSurfaceForms,String entities) throws IOException {
  List<Triple> candidates=new ArrayList<Triple>();
  List<Triple> acronymCandidatesTemp=new ArrayList<Triple>();
  List<Triple> acronymCandidatesTemp2=new ArrayList<Triple>();
  List<Triple> candidatesContext=new ArrayList<Triple>();
  List<Triple> candidatesContextbyLabel=new ArrayList<Triple>();
  List<Triple> linkedsbyContext=new ArrayList<Triple>();
  int countFinalCandidates=0;
  PreprocessingNLP nlp=new PreprocessingNLP();
  label=corporationAffixCleaner.cleanLabelsfromCorporationIdentifier(label);
  log.info("String_Node_Str" + label);
  label=nlp.Preprocessing(label);
  if (acronym == true) {
    if (label.equals(label.toUpperCase()) && label.length() <= 4) {
      acronymCandidatesTemp=searchbyAcronym(label,searchInSurfaceForms,entity.getType());
      for (      Triple triple : acronymCandidatesTemp) {
        acronymCandidatesTemp2=searchAcronymByLabel(triple.getSubject(),searchInSurfaceForms,entity.getType());
        for (        Triple triple2 : acronymCandidatesTemp2) {
          if (nGramDistance.getDistance(triple.getSubject(),triple2.getObject()) > threshholdTrigram) {
            triple2.setSubject(redirect(triple2.getSubject()));
            if (isDisambiguationResource(triple2.getSubject())) {
              continue;
            }
            if (commonEntities == true) {
              addNodeToGraph(graph,nodes,entity,triple2,triple2.getSubject());
              countFinalCandidates++;
            }
 else {
              if (domainWhiteLister.fitsIntoDomain(triple2.getSubject())) {
                addNodeToGraph(graph,nodes,entity,triple2,triple2.getSubject());
                countFinalCandidates++;
              }
            }
          }
        }
        acronymCandidatesTemp2.clear();
      }
      log.info("String_Node_Str" + countFinalCandidates);
    }
  }
  if (countFinalCandidates == 0) {
    candidates=searchCandidatesByLabel(label,searchInSurfaceForms,"String_Node_Str",popularity);
    if (searchInSurfaceForms) {
      log.info("String_Node_Str" + candidates.size());
    }
 else {
      log.info("String_Node_Str" + candidates.size());
    }
    if (candidates.size() == 0) {
      log.info("String_Node_Str" + label);
      if (label.endsWith("String_Node_Str")) {
        label=label.substring(0,label.lastIndexOf("String_Node_Str"));
        candidates=searchCandidatesByLabel(label,searchInSurfaceForms,"String_Node_Str",popularity);
        log.info("String_Node_Str");
      }
 else       if (label.endsWith("String_Node_Str")) {
        label=label.substring(0,label.lastIndexOf("String_Node_Str"));
        candidates=searchCandidatesByLabel(label,searchInSurfaceForms,"String_Node_Str",popularity);
        log.info("String_Node_Str");
      }
    }
    if (candidates.isEmpty()) {
      Stemming stemmer=new Stemming();
      String temp=stemmer.stemming(label);
      candidates=searchCandidatesByLabel(temp,searchInSurfaceForms,"String_Node_Str",popularity);
      log.info("String_Node_Str" + candidates.size());
    }
    boolean added=false;
    for (    Triple c : candidates) {
      log.info("String_Node_Str" + c);
      String candidateURL=c.getSubject();
      String surfaceForm=c.getObject();
      surfaceForm=nlp.Preprocessing(surfaceForm);
      if (candidateURL.startsWith(nodeType)) {
        if (c.getPredicate().equals("String_Node_Str")) {
          if (nGramDistance.getDistance(surfaceForm,label) < 1.0) {
            continue;
          }
        }
 else         if (!c.getPredicate().equals("String_Node_Str")) {
          if (nGramDistance.getDistance(surfaceForm,label) < threshholdTrigram) {
            continue;
          }
        }
        candidateURL=redirect(candidateURL);
        if (isDisambiguationResource(candidateURL)) {
          log.info("String_Node_Str" + candidateURL);
          continue;
        }
        if (commonEntities == true) {
          addNodeToGraph(graph,nodes,entity,c,candidateURL);
          added=true;
          countFinalCandidates++;
        }
 else {
          if (domainWhiteLister.fitsIntoDomain(candidateURL)) {
            addNodeToGraph(graph,nodes,entity,c,candidateURL);
            added=true;
            countFinalCandidates++;
          }
        }
      }
    }
    if (!added && !searchInSurfaceForms && context == true) {
      log.info("String_Node_Str");
      candidatesContext=searchCandidatesByContext(entities,label);
      log.info("String_Node_Str" + candidatesContext.size());
      if (candidatesContext != null) {
        for (        Triple triple : candidatesContext) {
          String url=nodeType + triple.getPredicate();
          candidatesContextbyLabel.addAll(searchCandidatesByUrl(url,searchInSurfaceForms));
        }
      }
      for (      Triple c : candidatesContextbyLabel) {
        log.debug("String_Node_Str" + c);
        String candidateURL=c.getSubject();
        String cleanCandidateURL=candidateURL.replace(nodeType,"String_Node_Str");
        cleanCandidateURL=nlp.Preprocessing(cleanCandidateURL);
        if (candidateURL.startsWith(nodeType)) {
          if (nGramDistance.getDistance(cleanCandidateURL,label) < 0.3) {
            continue;
          }
          for (          Triple temp : candidatesContext) {
            String candidateTemp=nodeType + temp.getPredicate();
            linkedsbyContext.addAll(searchbyConnections(candidateURL,candidateTemp));
          }
          if (linkedsbyContext.size() < 1) {
            continue;
          }
          candidateURL=redirect(candidateURL);
          if (isDisambiguationResource(candidateURL)) {
            continue;
          }
          if (commonEntities == true) {
            addNodeToGraph(graph,nodes,entity,c,candidateURL);
            added=true;
            countFinalCandidates++;
          }
 else {
            if (domainWhiteLister.fitsIntoDomain(candidateURL)) {
              addNodeToGraph(graph,nodes,entity,c,candidateURL);
              added=true;
              countFinalCandidates++;
            }
          }
        }
        linkedsbyContext.clear();
      }
    }
    if (!added && !searchInSurfaceForms) {
      log.info("String_Node_Str");
      checkLabelCandidates(graph,threshholdTrigram,nodes,entity,label,true,entities);
    }
  }
  log.info("String_Node_Str" + countFinalCandidates);
}