### Question:
FrequentSentenceStartValidator extends Validator { @Override public void validate(Document document) { Sentence lastSentence = null; int sentenceCount = 0; for (int i = 0; i < document.size(); i++) { for (Paragraph para : document.getSection(i).getParagraphs()) { for (Sentence sentence : para.getSentences()) { processSentence(sentence); sentenceCount++; lastSentence = sentence; } } } if (sentenceCount >= getInt("min_sentence_count")) { for (String start : sentenceStartHistogram.keySet()) { int count = sentenceStartHistogram.get(start); int percentage = (int) ((100.0 * (float) count / (float) sentenceStartHistogram.size())); if (percentage > getInt("percentage_threshold")) { addLocalizedError("SentenceStartTooFrequent", lastSentence, percentage, start); } } } } FrequentSentenceStartValidator(); @Override void validate(Document document);  }### Answer:
@Test void testDocument() throws RedPenException { FrequentSentenceStartValidator validator = (FrequentSentenceStartValidator) ValidatorFactory.getInstance("FrequentSentenceStart"); Document document = Document.builder(new WhiteSpaceTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("When it comes to the Subject Of Cake (the sweet and delicious baked delicacy), one should" + " always remember (or at least consider) this foodstuff's effect on one's ever-expanding waistline.", 1)) .addSentence(new Sentence("When it comes to fish, tuna is pretty nice.", 2)) .addSentence(new Sentence("When it comes to celery, the thing to consider is the crunch.", 3)) .addSentence(new Sentence("When it comes to how to start a sentence, variety is the key.", 4)) .addSentence(new Sentence("The acronym CPU stands for Central Processing Unit (CPU).", 5)) .addSentence(new Sentence("The acronym AAAS is the American Association for the Advancement of Science.", 6)) .build(); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(document); assertEquals(5, errors.size()); }