Program: 9714
Project: 9714
Buggy source:
@Test public void optimisedTest(){
  try {
    SimpleLayout layout=new SimpleLayout();
    ConsoleAppender consoleAppender=new ConsoleAppender(layout);
    consoleAppender.setThreshold(Level.INFO);
    FileAppender fileAppender=new FileAppender(layout,"String_Node_Str",false);
    fileAppender.setThreshold(Level.DEBUG);
    Logger logger=Logger.getRootLogger();
    logger.removeAllAppenders();
    logger.addAppender(consoleAppender);
    logger.addAppender(fileAppender);
    Logger.getLogger(ModelGenerator.class).setLevel(Level.OFF);
    Logger.getLogger(SPARQLQueryGeneratorCachedImpl.class).setLevel(Level.OFF);
    Logger.getLogger(LGGGeneratorImpl.class).setLevel(Level.OFF);
    Logger.getLogger(NBRGeneratorImpl.class).setLevel(Level.OFF);
    Logger.getLogger(Generalisation.class).setLevel(Level.OFF);
    Logger.getLogger(QueryTreeImpl.class).setLevel(Level.OFF);
    Logger.getLogger(NBR.class).setLevel(Level.INFO);
    Logger.getLogger(NBR.class).setLevel(Level.DEBUG);
    Logger.getLogger(PostLGG.class).setLevel(Level.DEBUG);
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
  HttpQuery.urlLimit=0;
  try {
    ExtractionDBCache cache=new ExtractionDBCache(CACHE_DIR);
    List<String> predicateFilters=new ArrayList<String>();
    SparqlEndpoint endpoint=new SPARQLEndpointEx(new URL("String_Node_Str"),Collections.singletonList("String_Node_Str"),Collections.<String>emptyList(),null,null,predicateFilters);
    predicateFilters.add("String_Node_Str");
    predicateFilters.add("String_Node_Str");
    ModelGenerator modelGen=new ModelGenerator(endpoint,new HashSet<String>(predicateFilters),cache);
    QueryTreeFactory<String> treeFactory=new QueryTreeFactoryImpl();
    LGGGenerator<String> lggGen=new LGGGeneratorImpl<String>();
    NBR<String> nbrGen=new NBR<String>(endpoint,cache);
    String targetQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    ResultSet rs=SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint,targetQuery));
    SortedSet<String> targetResources=new TreeSet<String>();
    QuerySolution qs;
    while (rs.hasNext()) {
      qs=rs.next();
      if (qs.get("String_Node_Str").isURIResource()) {
        targetResources.add(qs.get("String_Node_Str").asResource().getURI());
      }
    }
    List<String> posExamples=new ArrayList<String>();
    List<QueryTree<String>> posTrees=new ArrayList<QueryTree<String>>();
    List<QueryTree<String>> negTrees=new ArrayList<QueryTree<String>>();
    List<String> knownResources=new ArrayList<String>();
    String uri="String_Node_Str";
    posExamples.add(uri);
    knownResources.add(uri);
    Model model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    QueryTree<String> tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    posExamples.add(uri);
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    negTrees.add(tree);
    logger.info("String_Node_Str" + posExamples);
    QueryTree<String> lgg=lggGen.getLGG(posTrees);
    Example example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
    String learnedQuery=nbrGen.getQuery();
    while (!isEquivalentQuery(targetResources,learnedQuery,endpoint,cache)) {
      logger.info("String_Node_Str" + getResultCount(lgg.toSPARQLQueryString(),endpoint,cache));
      logger.info("String_Node_Str" + getResultCount(nbrGen.getPostLGG().toSPARQLQueryString(),endpoint,cache));
      uri=example.getURI();
      knownResources.add(uri);
      model=modelGen.createModel(uri,Strategy.CHUNKS,2);
      tree=treeFactory.getQueryTree(uri,model);
      tree=getFilteredTree(tree);
      if (targetResources.contains(uri)) {
        logger.info("String_Node_Str" + uri);
        posExamples.add(uri);
        posTrees.add(tree);
        lgg=lggGen.getLGG(posTrees);
      }
 else {
        logger.info("String_Node_Str" + uri);
        negTrees.add(tree);
      }
      logger.info("String_Node_Str" + posExamples);
      example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
      learnedQuery=nbrGen.getQuery();
    }
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Test public void optimisedTest(){
  try {
    SimpleLayout layout=new SimpleLayout();
    ConsoleAppender consoleAppender=new ConsoleAppender(layout);
    consoleAppender.setThreshold(Level.INFO);
    FileAppender fileAppender=new FileAppender(layout,"String_Node_Str",false);
    fileAppender.setThreshold(Level.DEBUG);
    Logger logger=Logger.getRootLogger();
    logger.removeAllAppenders();
    logger.addAppender(consoleAppender);
    logger.addAppender(fileAppender);
    Logger.getLogger(ModelGenerator.class).setLevel(Level.OFF);
    Logger.getLogger(SPARQLQueryGeneratorCachedImpl.class).setLevel(Level.OFF);
    Logger.getLogger(LGGGeneratorImpl.class).setLevel(Level.OFF);
    Logger.getLogger(NBRGeneratorImpl.class).setLevel(Level.OFF);
    Logger.getLogger(Generalisation.class).setLevel(Level.OFF);
    Logger.getLogger(QueryTreeImpl.class).setLevel(Level.OFF);
    Logger.getLogger(NBR.class).setLevel(Level.DEBUG);
    Logger.getLogger(PostLGG.class).setLevel(Level.DEBUG);
  }
 catch (  IOException e1) {
    e1.printStackTrace();
  }
  HttpQuery.urlLimit=0;
  try {
    ExtractionDBCache cache=new ExtractionDBCache(CACHE_DIR);
    List<String> predicateFilters=new ArrayList<String>();
    SparqlEndpoint endpoint=new SPARQLEndpointEx(new URL("String_Node_Str"),Collections.singletonList("String_Node_Str"),Collections.<String>emptyList(),null,null,predicateFilters);
    predicateFilters.add("String_Node_Str");
    predicateFilters.add("String_Node_Str");
    ModelGenerator modelGen=new ModelGenerator(endpoint,new HashSet<String>(predicateFilters),cache);
    QueryTreeFactory<String> treeFactory=new QueryTreeFactoryImpl();
    LGGGenerator<String> lggGen=new LGGGeneratorImpl<String>();
    NBR<String> nbrGen=new NBR<String>(endpoint,cache);
    String targetQuery="String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str";
    ResultSet rs=SparqlQuery.convertJSONtoResultSet(cache.executeSelectQuery(endpoint,targetQuery));
    SortedSet<String> targetResources=new TreeSet<String>();
    QuerySolution qs;
    while (rs.hasNext()) {
      qs=rs.next();
      if (qs.get("String_Node_Str").isURIResource()) {
        targetResources.add(qs.get("String_Node_Str").asResource().getURI());
      }
    }
    List<String> posExamples=new ArrayList<String>();
    List<QueryTree<String>> posTrees=new ArrayList<QueryTree<String>>();
    List<QueryTree<String>> negTrees=new ArrayList<QueryTree<String>>();
    List<String> knownResources=new ArrayList<String>();
    String uri="String_Node_Str";
    posExamples.add(uri);
    knownResources.add(uri);
    Model model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    QueryTree<String> tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    posExamples.add(uri);
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    posTrees.add(tree);
    uri="String_Node_Str";
    knownResources.add(uri);
    model=modelGen.createModel(uri,Strategy.CHUNKS,2);
    tree=treeFactory.getQueryTree(uri,model);
    tree=getFilteredTree(tree);
    negTrees.add(tree);
    logger.info("String_Node_Str" + posExamples);
    QueryTree<String> lgg=lggGen.getLGG(posTrees);
    Example example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
    String learnedQuery=nbrGen.getQuery();
    while (!isEquivalentQuery(targetResources,learnedQuery,endpoint,cache)) {
      logger.info("String_Node_Str" + getResultCount(lgg.toSPARQLQueryString(),endpoint,cache));
      logger.info("String_Node_Str" + getResultCount(nbrGen.getPostLGG().toSPARQLQueryString(),endpoint,cache));
      uri=example.getURI();
      knownResources.add(uri);
      model=modelGen.createModel(uri,Strategy.CHUNKS,2);
      tree=treeFactory.getQueryTree(uri,model);
      tree=getFilteredTree(tree);
      if (targetResources.contains(uri)) {
        logger.info("String_Node_Str" + uri);
        posExamples.add(uri);
        posTrees.add(tree);
        lgg=lggGen.getLGG(posTrees);
      }
 else {
        logger.info("String_Node_Str" + uri);
        negTrees.add(tree);
      }
      logger.info("String_Node_Str" + posExamples);
      example=nbrGen.getQuestionOptimised(lgg,negTrees,knownResources);
      learnedQuery=nbrGen.getQuery();
    }
  }
 catch (  MalformedURLException e) {
    e.printStackTrace();
  }
}