@Test void testUpperCaseContraction() throws RedPenException { Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("Contraction")) .build(); List<Document> documents = new ArrayList<>(); documents.add( Document.builder() .addSection(1) .addParagraph() .addSentence(new Sentence("He is a super man.", 1)) .addSentence(new Sentence("He is not a bat man.", 2)) .addSentence(new Sentence("He's also a business man.", 3)) .build()); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(documents); assertEquals(1, errors.get(documents.get(0)).size()); }
@Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (foundNonContractionNum >= foundContractionNum && contractions.contains(surface)) { addLocalizedErrorFromToken(sentence, token); } } }
ContractionValidator extends Validator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (foundNonContractionNum >= foundContractionNum && contractions.contains(surface)) { addLocalizedErrorFromToken(sentence, token); } } } }
ContractionValidator extends Validator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (foundNonContractionNum >= foundContractionNum && contractions.contains(surface)) { addLocalizedErrorFromToken(sentence, token); } } }  }
ContractionValidator extends Validator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (foundNonContractionNum >= foundContractionNum && contractions.contains(surface)) { addLocalizedErrorFromToken(sentence, token); } } }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); @Override void preValidate(Sentence sentence); }
ContractionValidator extends Validator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String surface = token.getSurface().toLowerCase(); if (foundNonContractionNum >= foundContractionNum && contractions.contains(surface)) { addLocalizedErrorFromToken(sentence, token); } } }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); @Override void preValidate(Sentence sentence);  }