@Test void testDocument() throws RedPenException { List<Document> documents = new ArrayList<>(); documents.add(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("Now we know what SOC stands for but there is no mention of TTP.", 2)) .addSentence(new Sentence("The acronym CPU stands for Central Processing Unit (CPU).", 3)) .addSentence(new Sentence("The acronym AAAS is the American Association for the Advancement of Science.", 4)) .addSentence(new Sentence("ABC can stand form the Australian Broadcasting Commission, but HELLO is just a capitalized word.", 5)) .build()); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("UnexpandedAcronym")) .build(); RedPen redPen = new RedPen(config); List<ValidationError> errors = redPen.validate(documents).get(documents.get(0)); assertEquals(1, errors.size()); assertEquals(2, errors.get(0).getLineNumber()); }
@Override public void validate(Document document) { for (String acronym : contractedAcronyms.keySet()) { if (!expandedAcronyms.contains(acronym)) { addLocalizedError("UnexpandedAcronym", contractedAcronyms.get(acronym), acronym); } } }
UnexpandedAcronymValidator extends SpellingDictionaryValidator { @Override public void validate(Document document) { for (String acronym : contractedAcronyms.keySet()) { if (!expandedAcronyms.contains(acronym)) { addLocalizedError("UnexpandedAcronym", contractedAcronyms.get(acronym), acronym); } } } }
UnexpandedAcronymValidator extends SpellingDictionaryValidator { @Override public void validate(Document document) { for (String acronym : contractedAcronyms.keySet()) { if (!expandedAcronyms.contains(acronym)) { addLocalizedError("UnexpandedAcronym", contractedAcronyms.get(acronym), acronym); } } } UnexpandedAcronymValidator(); }
UnexpandedAcronymValidator extends SpellingDictionaryValidator { @Override public void validate(Document document) { for (String acronym : contractedAcronyms.keySet()) { if (!expandedAcronyms.contains(acronym)) { addLocalizedError("UnexpandedAcronym", contractedAcronyms.get(acronym), acronym); } } } UnexpandedAcronymValidator(); @Override List<String> getSupportedLanguages(); @Override void validate(Document document); @Override void preValidate(Document document); }
UnexpandedAcronymValidator extends SpellingDictionaryValidator { @Override public void validate(Document document) { for (String acronym : contractedAcronyms.keySet()) { if (!expandedAcronyms.contains(acronym)) { addLocalizedError("UnexpandedAcronym", contractedAcronyms.get(acronym), acronym); } } } UnexpandedAcronymValidator(); @Override List<String> getSupportedLanguages(); @Override void validate(Document document); @Override void preValidate(Document document);  }