Program: 9533
Project: 9533
Buggy source:
public ArrayList<Template> createTemplates(String question){
  ArrayList<Template> resultArrayList=new ArrayList<Template>();
  Set<BasicQueryTemplate> querytemps=btemplator.buildBasicQueries(question);
  for (  BasicQueryTemplate bqt : querytemps) {
    ArrayList<ArrayList<String>> condition=new ArrayList<ArrayList<String>>();
    ArrayList<ArrayList<Hypothesis>> hypotesen=new ArrayList<ArrayList<Hypothesis>>();
    String selectTerm="String_Node_Str";
    String having="String_Node_Str";
    String filter="String_Node_Str";
    String OrderBy="String_Node_Str";
    String limit="String_Node_Str";
    String condition_String="String_Node_Str";
    boolean addTemplate=true;
    try {
      for (      SPARQL_Term terms : bqt.getSelTerms())       selectTerm=selectTerm + (terms.toString()) + "String_Node_Str";
    }
 catch (    Exception e) {
      selectTerm="String_Node_Str";
      addTemplate=false;
    }
    ArrayList<String> temp_array=new ArrayList<String>();
    try {
      for (      Path conditions1 : bqt.getConditions())       condition_String=condition_String + (conditions1.toString()) + "String_Node_Str";
      for (      Path conditions1 : bqt.getConditions()) {
        temp_array.clear();
        String[] tmp_array=conditions1.toString().split("String_Node_Str");
        for (        String s : tmp_array) {
          temp_array.add(s);
        }
        condition.add(temp_array);
      }
    }
 catch (    Exception e) {
      condition_String="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      SPARQL_Filter tmp : bqt.getFilters())       filter=filter + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      filter="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      SPARQL_Having tmp : bqt.getHavings())       having=having + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      having="String_Node_Str";
      addTemplate=false;
    }
    OrderBy="String_Node_Str";
    try {
      for (      SPARQL_Term tmp : bqt.getOrderBy()) {
        OrderBy=OrderBy + tmp + "String_Node_Str";
      }
      if ((bqt.getOrderBy()).size() == 0)       OrderBy="String_Node_Str";
    }
 catch (    Exception e) {
      OrderBy="String_Node_Str";
      addTemplate=false;
    }
    try {
      limit="String_Node_Str" + bqt.getLimit();
      if (bqt.getLimit() == 0)       limit="String_Node_Str";
    }
 catch (    Exception e) {
      limit="String_Node_Str";
      addTemplate=false;
    }
    if (addTemplate != false) {
      Template template=new Template(condition,having,filter,selectTerm,OrderBy,limit);
      ArrayList<Hypothesis> list_of_hypothesis=new ArrayList<Hypothesis>();
      for (      Slot slot : bqt.getSlots()) {
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],"String_Node_Str",0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],"String_Node_Str",0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],"String_Node_Str",0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
      }
      ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis=new ArrayList<ArrayList<Hypothesis>>();
      for (      Hypothesis x : list_of_hypothesis) {
        if (x.getType().contains("String_Node_Str")) {
          ArrayList<String> result=new ArrayList<String>();
          try {
            result=utils_new.searchIndex(x.getUri(),3,myindex);
          }
 catch (          SQLException e) {
            e.printStackTrace();
          }
          for (          String s : result) {
            ArrayList<Hypothesis> new_list=new ArrayList<Hypothesis>();
            new_list=list_of_hypothesis;
            for (            Hypothesis z : new_list) {
              if (z.getUri().equals(x.getUri())) {
                z.setUri(s);
                z.setRank(1);
              }
            }
            final_list_set_hypothesis.add(new_list);
          }
        }
      }
      for (      ArrayList<Hypothesis> x : final_list_set_hypothesis) {
        for (        Hypothesis h : x) {
          if (h.getType().contains("String_Node_Str")) {
            ArrayList<String> result=new ArrayList<String>();
            try {
              result=utils_new.searchIndex(h.getUri(),1,myindex);
              if (!result.isEmpty()) {
                h.setUri(result.get(0));
                h.setRank(1);
              }
 else {
                h.setRank(0);
              }
            }
 catch (            SQLException e) {
              e.printStackTrace();
            }
          }
        }
      }
      template.setHypothesen(final_list_set_hypothesis);
      Template template_reverse_conditions=new Template(template.getCondition(),template.getHaving(),template.getFilter(),template.getSelectTerm(),template.getOrderBy(),template.getLimit());
      ArrayList<ArrayList<String>> condition_template_reverse_conditions=template_reverse_conditions.getCondition();
      ArrayList<ArrayList<String>> condition_reverse_new=new ArrayList<ArrayList<String>>();
      for (      ArrayList<String> x : condition_template_reverse_conditions) {
        ArrayList<String> new_list=new ArrayList<String>();
        new_list.add(x.get(2));
        new_list.add(x.get(1));
        new_list.add(x.get(0));
        condition_reverse_new.add(new_list);
      }
      template_reverse_conditions.setCondition(condition_reverse_new);
      resultArrayList.add(template);
      resultArrayList.add(template_reverse_conditions);
    }
  }
  for (  Template temp : resultArrayList) {
    temp.printAll();
  }
  return resultArrayList;
}

Fixed version (ground truth):
public ArrayList<Template> createTemplates(String question){
  ArrayList<Template> resultArrayList=new ArrayList<Template>();
  Set<BasicQueryTemplate> querytemps=btemplator.buildBasicQueries(question);
  for (  BasicQueryTemplate bqt : querytemps) {
    ArrayList<ArrayList<String>> condition=new ArrayList<ArrayList<String>>();
    String selectTerm="String_Node_Str";
    String having="String_Node_Str";
    String filter="String_Node_Str";
    String OrderBy="String_Node_Str";
    String limit="String_Node_Str";
    boolean addTemplate=true;
    try {
      for (      SPARQL_Term terms : bqt.getSelTerms())       selectTerm=selectTerm + (terms.toString()) + "String_Node_Str";
    }
 catch (    Exception e) {
      selectTerm="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      Path conditions1 : bqt.getConditions()) {
        ArrayList<String> temp_array=new ArrayList<String>();
        String[] tmp_array=conditions1.toString().split("String_Node_Str");
        for (        String s : tmp_array) {
          temp_array.add(s);
        }
        condition.add(temp_array);
      }
    }
 catch (    Exception e) {
      addTemplate=false;
    }
    try {
      for (      SPARQL_Filter tmp : bqt.getFilters())       filter=filter + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      filter="String_Node_Str";
      addTemplate=false;
    }
    try {
      for (      SPARQL_Having tmp : bqt.getHavings())       having=having + tmp + "String_Node_Str";
    }
 catch (    Exception e) {
      having="String_Node_Str";
      addTemplate=false;
    }
    OrderBy="String_Node_Str";
    try {
      for (      SPARQL_Term tmp : bqt.getOrderBy()) {
        OrderBy=OrderBy + tmp + "String_Node_Str";
      }
      if ((bqt.getOrderBy()).size() == 0)       OrderBy="String_Node_Str";
    }
 catch (    Exception e) {
      OrderBy="String_Node_Str";
      addTemplate=false;
    }
    try {
      limit="String_Node_Str" + bqt.getLimit();
      if (bqt.getLimit() == 0)       limit="String_Node_Str";
    }
 catch (    Exception e) {
      limit="String_Node_Str";
      addTemplate=false;
    }
    if (addTemplate != false) {
      Template template=new Template(condition,having,filter,selectTerm,OrderBy,limit);
      ArrayList<Hypothesis> list_of_hypothesis=new ArrayList<Hypothesis>();
      for (      Slot slot : bqt.getSlots()) {
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],"String_Node_Str",0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],"String_Node_Str",0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
        if (slot.toString().contains("String_Node_Str")) {
          String tmp=slot.toString().replace("String_Node_Str","String_Node_Str");
          tmp=tmp.replace("String_Node_Str","String_Node_Str");
          String[] tmp_array=tmp.split("String_Node_Str");
          Hypothesis tmp_hypothesis=new Hypothesis("String_Node_Str" + tmp_array[0],tmp_array[1],"String_Node_Str",0);
          list_of_hypothesis.add(tmp_hypothesis);
        }
      }
      ArrayList<ArrayList<Hypothesis>> final_list_set_hypothesis=new ArrayList<ArrayList<Hypothesis>>();
      for (      Hypothesis x : list_of_hypothesis) {
        if (x.getType().contains("String_Node_Str")) {
          ArrayList<String> result=new ArrayList<String>();
          try {
            result=utils_new.searchIndex(x.getUri(),3,myindex);
          }
 catch (          SQLException e) {
            e.printStackTrace();
          }
          for (          String s : result) {
            ArrayList<Hypothesis> new_list=new ArrayList<Hypothesis>();
            for (            Hypothesis h : list_of_hypothesis) {
              if (h.getUri().equals(x.getUri())) {
                Hypothesis new_h=new Hypothesis(h.getVariable(),s,h.getType(),1);
                new_list.add(new_h);
              }
 else {
                Hypothesis new_h=new Hypothesis(h.getVariable(),h.getUri(),h.getType(),h.getRank());
                new_list.add(new_h);
              }
            }
            final_list_set_hypothesis.add(new_list);
          }
        }
      }
      for (      ArrayList<Hypothesis> x : final_list_set_hypothesis) {
        for (        Hypothesis h : x) {
          if (h.getType().contains("String_Node_Str") || h.getType().contains("String_Node_Str")) {
            ArrayList<String> result=new ArrayList<String>();
            try {
              result=utils_new.searchIndex(h.getUri(),1,myindex);
              if (!result.isEmpty()) {
                h.setUri(result.get(0));
                h.setRank(1);
              }
 else {
                String tmp="String_Node_Str" + h.getUri().toLowerCase();
                h.setUri(tmp);
                h.setRank(0);
              }
            }
 catch (            SQLException e) {
              e.printStackTrace();
            }
          }
        }
      }
      template.setHypothesen(final_list_set_hypothesis);
      Template template_reverse_conditions=new Template(template.getCondition(),template.getHaving(),template.getFilter(),template.getSelectTerm(),template.getOrderBy(),template.getLimit());
      ArrayList<ArrayList<String>> condition_template_reverse_conditions=template_reverse_conditions.getCondition();
      ArrayList<ArrayList<String>> condition_reverse_new=new ArrayList<ArrayList<String>>();
      for (      ArrayList<String> x : condition_template_reverse_conditions) {
        ArrayList<String> new_list=new ArrayList<String>();
        new_list.add(x.get(2));
        new_list.add(x.get(1));
        new_list.add(x.get(0));
        condition_reverse_new.add(new_list);
      }
      template_reverse_conditions.setCondition(condition_reverse_new);
      resultArrayList.add(template);
      resultArrayList.add(template_reverse_conditions);
    }
  }
  return resultArrayList;
}