docs: public static boolean countResults(List<? extends CoreMap> doc,
                                       Counter<String> entityTP,
                                       Counter<String> entityFP,
                                       Counter<String> entityFN) {
      int index = 0;
      int goldIndex = 0, guessIndex = 0;
      String lastGold = "O", lastGuess = "O";
  
      // As we go through the document, there are two events we might be
      // interested in.  One is when a gold entity ends, and the other
      // is when a guessed entity ends.  If the gold and guessed
      // entities end at the same time, started at the same time, and
      // match entity type, we have a true positive.  Otherwise we
      // either have a false positive or a false negative.
      for (CoreMap line : doc) {
        String gold = line.get(GoldAnswerAnnotation.class);
        String guess = line.get(AnswerAnnotation.class);
  
        if (gold == null || guess == null)
          return false;
  
        if (!lastGold.equals(gold) && !lastGold.equals("O")) {
          if (lastGuess.equals(lastGold) && !lastGuess.equals(guess) &&
              goldIndex == guessIndex) {
            entityTP.incrementCount(lastGold, 1.0);
          } else {
            entityFN.incrementCount(lastGold, 1.0);
          }
        }
  
        if (!lastGuess.equals(guess) && !lastGuess.equals("O")) {
          if (lastGuess.equals(lastGold) && !lastGuess.equals(guess) &&
              goldIndex == guessIndex && !lastGold.equals(gold)) {
            // correct guesses already tallied
            // only need to tally false positives
          } else {
            entityFP.incrementCount(lastGuess, 1.0);
          }
        }
  
        if (!lastGold.equals(gold)) {
          lastGold = gold;
          goldIndex = index;
        }
  
        if (!lastGuess.equals(guess)) {
          lastGuess = guess;
          guessIndex = index;
        }
        ++index;
      }
  
      // We also have to account for entities at the very end of the
      // document, since the above logic only occurs when we see
      // something that tells us an entity has ended
      if (!lastGold.equals("O")) {
        if (lastGold.equals(lastGuess) && goldIndex == guessIndex) {
          entityTP.incrementCount(lastGold, 1.0);
        } else {
          entityFN.incrementCount(lastGold, 1.0);
        }
      }
      if (!lastGuess.equals("O")) {
        if (lastGold.equals(lastGuess) && goldIndex == guessIndex) {
          // correct guesses already tallied
        } else {
          entityFP.incrementCount(lastGuess, 1.0);
        }
      }
      return true;
    }