@Test void testSimpleRun() throws RedPenException { List<Document> documents = new ArrayList<>();documents.add( Document.builder() .addSection(1) .addParagraph() .addSentence(new Sentence("He is a foolish guy.", 1)) .build()); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("InvalidWord").addProperty("list", "foolish")) .build(); Validator validator = ValidatorFactory.getInstance(config.getValidatorConfigs().get(0), config); List<ValidationError> errors = new ArrayList<>(); validator.setErrorList(errors); validator.validate(documents.get(0).getLastSection().getParagraph(0).getSentence(0)); assertEquals(1, errors.size()); }
@Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String word = token.getSurface().toLowerCase(); if (inDictionary(word)) { addLocalizedErrorFromToken(sentence, token); } } }
InvalidWordValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String word = token.getSurface().toLowerCase(); if (inDictionary(word)) { addLocalizedErrorFromToken(sentence, token); } } } }
InvalidWordValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String word = token.getSurface().toLowerCase(); if (inDictionary(word)) { addLocalizedErrorFromToken(sentence, token); } } } InvalidWordValidator(); }
InvalidWordValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String word = token.getSurface().toLowerCase(); if (inDictionary(word)) { addLocalizedErrorFromToken(sentence, token); } } } InvalidWordValidator(); @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); }
InvalidWordValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { for (TokenElement token : sentence.getTokens()) { String word = token.getSurface().toLowerCase(); if (inDictionary(word)) { addLocalizedErrorFromToken(sentence, token); } } } InvalidWordValidator(); @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence);  }