Program: 9603
Project: 9603
Buggy source:
private Query convertCondition(DRS_Condition condition,Query query){
  if (condition.isComplexCondition()) {
    if (!isSilent()) {
      System.out.print("String_Node_Str" + condition.toString());
    }
    Complex_DRS_Condition complex=(Complex_DRS_Condition)condition;
    DRS restrictor=complex.getRestrictor();
    DRS_Quantifier quant=complex.getQuantifier();
    DRS scope=complex.getScope();
    for (    DRS_Condition cond : restrictor.getConditions()) {
      query=convertCondition(cond,query);
    }
    for (    DRS_Condition cond : scope.getConditions()) {
      query=convertCondition(cond,query);
    }
    DiscourseReferent ref=complex.getReferent();
    String sref=ref.getValue();
    String fresh;
    if (!isSilent()) {
      System.out.print("String_Node_Str" + quant);
    }
switch (quant) {
case HOWMANY:
      query.addSelTerm(new SPARQL_Term(sref,SPARQL_Aggregate.COUNT));
    break;
case EVERY:
  break;
case NO:
SPARQL_Filter f=new SPARQL_Filter();
f.addNotBound(new SPARQL_Term(sref));
query.addFilter(f);
break;
case FEW:
break;
case MANY:
break;
case MOST:
break;
case SOME:
break;
case THELEAST:
fresh="String_Node_Str" + createFresh();
query.addSelTerm(new SPARQL_Term(sref,SPARQL_Aggregate.COUNT,fresh));
query.addOrderBy(new SPARQL_Term(fresh,SPARQL_OrderBy.ASC));
query.setLimit(1);
break;
case THEMOST:
fresh="String_Node_Str" + createFresh();
query.addSelTerm(new SPARQL_Term(sref,SPARQL_Aggregate.COUNT,fresh));
query.addOrderBy(new SPARQL_Term(fresh,SPARQL_OrderBy.DESC));
query.setLimit(1);
break;
}
}
 else if (condition.isNegatedCondition()) {
if (!isSilent()) {
System.out.print("String_Node_Str" + condition.toString());
}
Negated_DRS neg=(Negated_DRS)condition;
query=convert(neg.getDRS(),query,true);
}
 else {
Simple_DRS_Condition simple=(Simple_DRS_Condition)condition;
if (!isSilent()) {
System.out.print(isSilent() + "String_Node_Str" + condition.toString());
}
int arity=simple.getArguments().size();
String predicate=simple.getPredicate();
if (predicate.startsWith("String_Node_Str")) {
for (Slot s : slots) {
if (s.getAnchor().equals(predicate)) {
s.setToken(predicate);
predicate="String_Node_Str" + createFresh();
s.setAnchor(predicate);
template.addSlot(s);
break;
}
 else if (s.getToken().equals(predicate)) {
predicate=s.getAnchor();
}
}
}
SPARQL_Property prop=new SPARQL_Property(predicate);
prop.setIsVariable(true);
boolean literal=false;
if (simple.getArguments().size() > 1 && simple.getArguments().get(1).getValue().matches("String_Node_Str")) {
literal=true;
}
if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),SPARQL_Aggregate.COUNT,simple.getArguments().get(1).getValue()));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(1).getValue(),SPARQL_Aggregate.SUM));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.GT)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.GTEQ)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.LT)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.LTEQ)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),true));
query.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(),SPARQL_OrderBy.DESC));
query.setLimit(1);
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),true));
query.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(),SPARQL_OrderBy.ASC));
query.setLimit(1);
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.EQ)));
return query;
}
if (arity == 1) {
SPARQL_Term term=new SPARQL_Term(simple.getArguments().get(0).getValue(),false);
query.addCondition(new SPARQL_Triple(term,new SPARQL_Property("String_Node_Str",new SPARQL_Prefix("String_Node_Str","String_Node_Str")),prop));
}
 else if (arity == 2) {
String arg1=simple.getArguments().get(0).getValue();
String arg2=simple.getArguments().get(1).getValue();
query.addCondition(new SPARQL_Triple(new SPARQL_Term(arg1,false),prop,new SPARQL_Term(arg2,false)));
}
 else if (arity > 2) {
}
}
return query;
}

Fixed version (ground truth):
private Query convertCondition(DRS_Condition condition,Query query){
  if (condition.isComplexCondition()) {
    if (!isSilent()) {
      System.out.print("String_Node_Str" + condition.toString());
    }
    Complex_DRS_Condition complex=(Complex_DRS_Condition)condition;
    DRS restrictor=complex.getRestrictor();
    DRS_Quantifier quant=complex.getQuantifier();
    DRS scope=complex.getScope();
    for (    DRS_Condition cond : restrictor.getConditions()) {
      query=convertCondition(cond,query);
    }
    for (    DRS_Condition cond : scope.getConditions()) {
      query=convertCondition(cond,query);
    }
    DiscourseReferent ref=complex.getReferent();
    String sref=ref.getValue();
    String fresh;
    if (!isSilent()) {
      System.out.print("String_Node_Str" + quant);
    }
switch (quant) {
case HOWMANY:
      query.addSelTerm(new SPARQL_Term(sref,SPARQL_Aggregate.COUNT));
    break;
case EVERY:
  break;
case NO:
SPARQL_Filter f=new SPARQL_Filter();
f.addNotBound(new SPARQL_Term(sref));
query.addFilter(f);
break;
case FEW:
break;
case MANY:
break;
case MOST:
break;
case SOME:
break;
case THELEAST:
fresh="String_Node_Str" + createFresh();
query.addSelTerm(new SPARQL_Term(sref,SPARQL_Aggregate.COUNT,fresh));
query.addOrderBy(new SPARQL_Term(fresh,SPARQL_OrderBy.ASC));
query.setLimit(1);
break;
case THEMOST:
fresh="String_Node_Str" + createFresh();
query.addSelTerm(new SPARQL_Term(sref,SPARQL_Aggregate.COUNT,fresh));
query.addOrderBy(new SPARQL_Term(fresh,SPARQL_OrderBy.DESC));
query.setLimit(1);
break;
}
}
 else if (condition.isNegatedCondition()) {
if (!isSilent()) {
System.out.print("String_Node_Str" + condition.toString());
}
Negated_DRS neg=(Negated_DRS)condition;
query=convert(neg.getDRS(),query,true);
}
 else {
Simple_DRS_Condition simple=(Simple_DRS_Condition)condition;
if (!isSilent()) {
System.out.print(isSilent() + "String_Node_Str" + condition.toString());
}
int arity=simple.getArguments().size();
String predicate=simple.getPredicate();
if (predicate.startsWith("String_Node_Str")) {
for (Slot s : slots) {
if (s.getAnchor().equals(predicate)) {
s.setToken(predicate);
predicate="String_Node_Str" + createFresh();
s.setAnchor(predicate);
template.addSlot(s);
break;
}
 else if (s.getToken().equals(predicate)) {
predicate=s.getAnchor();
}
}
}
SPARQL_Property prop=new SPARQL_Property(predicate);
prop.setIsVariable(true);
boolean literal=false;
if (simple.getArguments().size() > 1 && simple.getArguments().get(1).getValue().matches("String_Node_Str")) {
literal=true;
}
if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),SPARQL_Aggregate.COUNT,simple.getArguments().get(1).getValue()));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(1).getValue(),SPARQL_Aggregate.SUM));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.GT)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.GTEQ)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.LT)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.LTEQ)));
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),true));
query.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(),SPARQL_OrderBy.DESC));
query.setLimit(1);
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addSelTerm(new SPARQL_Term(simple.getArguments().get(0).getValue(),true));
query.addOrderBy(new SPARQL_Term(simple.getArguments().get(0).getValue(),SPARQL_OrderBy.ASC));
query.setLimit(1);
return query;
}
 else if (predicate.equals("String_Node_Str")) {
query.addFilter(new SPARQL_Filter(new SPARQL_Pair(new SPARQL_Term(simple.getArguments().get(0).getValue(),true),new SPARQL_Term(simple.getArguments().get(1).getValue(),literal),SPARQL_PairType.EQ)));
return query;
}
if (arity == 1) {
SPARQL_Term term=new SPARQL_Term(simple.getArguments().get(0).getValue(),false);
term.setIsVariable(true);
query.addCondition(new SPARQL_Triple(term,new SPARQL_Property("String_Node_Str",new SPARQL_Prefix("String_Node_Str","String_Node_Str")),prop));
}
 else if (arity == 2) {
String arg1=simple.getArguments().get(0).getValue();
SPARQL_Term term1=new SPARQL_Term(arg1,false);
term1.setIsVariable(true);
String arg2=simple.getArguments().get(1).getValue();
SPARQL_Term term2=new SPARQL_Term(arg2,false);
term2.setIsVariable(true);
query.addCondition(new SPARQL_Triple(term1,prop,term2));
}
 else if (arity > 2) {
}
}
return query;
}