@Test void testLoadJapaneseInvalidList() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("InvalidExpression").addProperty("list", "うふぉ,ガチ")) .build(); List<Document> documents = new ArrayList<>();documents.add( Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("うふぉっ本当ですか？", 1)) .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) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } InvalidExpressionValidator(); }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } InvalidExpressionValidator(); @Override void validate(Sentence sentence); }
InvalidExpressionValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { streamDictionary().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } }); } InvalidExpressionValidator(); @Override void validate(Sentence sentence);  }