Program: 30706
Project: 30706
Buggy source:
public void findQuotations(Book book){
  setQuotes(book);
  for (  Token token : book.tokens) {
    if (token.pos.startsWith("String_Node_Str") && (token.lemma.equals("String_Node_Str"))) {
      PronounAntecedent pronoun=new PronounAntecedent(token.tokenId,0);
      book.animateEntities.put(token.tokenId,pronoun);
    }
  }
  TreeMap<Integer,Quotation> quotations;
  int start=0;
  int end=0;
  quotations=Maps.newTreeMap();
  for (  Token token : book.tokens) {
    if (token.lemma.equals("String_Node_Str")) {
      start=token.tokenId;
    }
 else     if (token.lemma.equals("String_Node_Str")) {
      end=token.tokenId;
      if (start > -1) {
        Quotation quote=new Quotation(start,end,token.sentenceID);
        quotations.put(start,quote);
      }
      start=-1;
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    int quoteSentence=book.tokens.get(quote.start).sentenceID;
    int i=quote.start;
    int currentSentence=quoteSentence;
    while (quoteSentence == currentSentence && i >= 0) {
      Token token=book.tokens.get(i);
      currentSentence=token.sentenceID;
      if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
        quote.attributionId=i;
        break;
      }
      i--;
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    int quoteSentence=book.tokens.get(quote.end).sentenceID;
    int i=quote.end;
    int currentSentence=quoteSentence;
    while (quoteSentence == currentSentence && i < book.tokens.size()) {
      Token token=book.tokens.get(i);
      currentSentence=token.sentenceID;
      if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
        quote.attributionId=i;
        break;
      }
      i++;
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    Map.Entry<Integer,Quotation> map=quotations.floorEntry(quote.start - 1);
    if (map != null) {
      Quotation previous=map.getValue();
      for (int i=quote.start; i > previous.end && i >= 0; i--) {
        Token token=book.tokens.get(i);
        if (token.word.matches("String_Node_Str")) {
          break;
        }
        if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
          quote.attributionId=i;
          break;
        }
      }
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    Map.Entry<Integer,Quotation> map=quotations.ceilingEntry(quote.start + 1);
    if (map != null) {
      Quotation next=map.getValue();
      for (int i=quote.end; i < next.start && i < book.tokens.size(); i++) {
        Token token=book.tokens.get(i);
        if (token.word.matches("String_Node_Str")) {
          break;
        }
        if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
          quote.attributionId=i;
          break;
        }
      }
    }
  }
  book.quotations=Lists.newArrayList();
  for (  Quotation quote : quotations.values()) {
    book.quotations.add(quote);
  }
}

Fixed version (ground truth):
public void findQuotations(Book book){
  for (  Token token : book.tokens) {
    if (token.pos.startsWith("String_Node_Str") && (token.lemma.equals("String_Node_Str"))) {
      PronounAntecedent pronoun=new PronounAntecedent(token.tokenId,0);
      book.animateEntities.put(token.tokenId,pronoun);
    }
  }
  TreeMap<Integer,Quotation> quotations;
  int start=0;
  int end=0;
  quotations=Maps.newTreeMap();
  int doubleQuotes=0;
  int singleQuotes=0;
  for (  Token token : book.tokens) {
    if (token.lemma.equals("String_Node_Str")) {
      doubleQuotes++;
    }
 else     if (token.lemma.equals("String_Node_Str")) {
      singleQuotes++;
    }
  }
  boolean usesSingleQuotes=false;
  if (singleQuotes > doubleQuotes) {
    usesSingleQuotes=true;
  }
  boolean open=false;
  if (usesSingleQuotes) {
    Token previousToken=null;
    for (int i=0; i < book.tokens.size(); i++) {
      Token token=book.tokens.get(i);
      if (token.original.equals("String_Node_Str")) {
        if (!previousToken.whitespaceAfter.equals("String_Node_Str")) {
          token.lemma="String_Node_Str";
          token.word="String_Node_Str";
          token.pos="String_Node_Str";
        }
      }
      previousToken=token;
    }
    previousToken=null;
    for (int i=0; i < book.tokens.size(); i++) {
      Token token=book.tokens.get(i);
      if (token.lemma.equals("String_Node_Str")) {
        if (!previousToken.whitespaceAfter.equals("String_Node_Str")) {
          open=true;
          start=token.tokenId;
        }
      }
 else       if (token.lemma.equals("String_Node_Str")) {
        end=token.tokenId;
        if (start > -1 && open) {
          Quotation quote=new Quotation(start,end,token.sentenceID);
          quotations.put(start,quote);
        }
        start=-1;
        open=false;
      }
      previousToken=token;
    }
  }
 else {
    for (    Token token : book.tokens) {
      if (token.lemma.equals("String_Node_Str")) {
        open=true;
        start=token.tokenId;
      }
 else       if (token.lemma.equals("String_Node_Str")) {
        end=token.tokenId;
        if (start > -1 && open) {
          Quotation quote=new Quotation(start,end,token.sentenceID);
          quotations.put(start,quote);
        }
        start=-1;
        open=false;
      }
    }
  }
  for (  Token token : book.tokens) {
    token.quotation=false;
  }
  for (  int qstart : quotations.keySet()) {
    Quotation quotation=quotations.get(qstart);
    for (int s=quotation.start; s <= quotation.end; s++) {
      book.tokens.get(s).quotation=true;
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    int quoteSentence=book.tokens.get(quote.start).sentenceID;
    int i=quote.start;
    int currentSentence=quoteSentence;
    while (quoteSentence == currentSentence && i >= 0) {
      Token token=book.tokens.get(i);
      currentSentence=token.sentenceID;
      if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
        quote.attributionId=i;
        break;
      }
      i--;
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    int quoteSentence=book.tokens.get(quote.end).sentenceID;
    int i=quote.end;
    int currentSentence=quoteSentence;
    while (quoteSentence == currentSentence && i < book.tokens.size()) {
      Token token=book.tokens.get(i);
      currentSentence=token.sentenceID;
      if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
        quote.attributionId=i;
        break;
      }
      i++;
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    Map.Entry<Integer,Quotation> map=quotations.floorEntry(quote.start - 1);
    if (map != null) {
      Quotation previous=map.getValue();
      for (int i=quote.start; i > previous.end && i >= 0; i--) {
        Token token=book.tokens.get(i);
        if (token.word.matches("String_Node_Str")) {
          break;
        }
        if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
          quote.attributionId=i;
          break;
        }
      }
    }
  }
  for (  Quotation quote : quotations.values()) {
    if (quote.attributionId != 0) {
      continue;
    }
    Map.Entry<Integer,Quotation> map=quotations.ceilingEntry(quote.start + 1);
    if (map != null) {
      Quotation next=map.getValue();
      for (int i=quote.end; i < next.start && i < book.tokens.size(); i++) {
        Token token=book.tokens.get(i);
        if (token.word.matches("String_Node_Str")) {
          break;
        }
        if (book.animateEntities.containsKey(i) && token.quotation == false && !token.pos.equals("String_Node_Str")) {
          quote.attributionId=i;
          break;
        }
      }
    }
  }
  book.quotations=Lists.newArrayList();
  for (  Quotation quote : quotations.values()) {
    book.quotations.add(quote);
  }
}