@Test void testInvalidValidOkuriganaWithsora6() throws Exception { String sampleText = "体を反そう。"; Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("Okurigana")) .build(); DocumentParser parser = DocumentParser.MARKDOWN; List<Document> documents = new ArrayList<>(); Document document = parser.parse(sampleText, new SentenceExtractor(config.getSymbolTable()), config.getTokenizer()); documents.add(document); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(documents); assertEquals(1, errors.get(documents.get(0)).size()); assertEquals(1, errors.get(documents.get(0)).get(0).getLineNumber()); assertEquals("Okurigana", errors.get(documents.get(0)).get(0).getValidatorName()); }
@Override public void validate(Sentence sentence) { invalidOkurigana.stream().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } } ); for (ExpressionRule rule : invalidOkuriganaTokens) { if (rule.match(sentence.getTokens())) { addLocalizedError(sentence, rule.toString()); } } }
OkuriganaValidator extends Validator { @Override public void validate(Sentence sentence) { invalidOkurigana.stream().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } } ); for (ExpressionRule rule : invalidOkuriganaTokens) { if (rule.match(sentence.getTokens())) { addLocalizedError(sentence, rule.toString()); } } } }
OkuriganaValidator extends Validator { @Override public void validate(Sentence sentence) { invalidOkurigana.stream().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } } ); for (ExpressionRule rule : invalidOkuriganaTokens) { if (rule.match(sentence.getTokens())) { addLocalizedError(sentence, rule.toString()); } } }  }
OkuriganaValidator extends Validator { @Override public void validate(Sentence sentence) { invalidOkurigana.stream().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } } ); for (ExpressionRule rule : invalidOkuriganaTokens) { if (rule.match(sentence.getTokens())) { addLocalizedError(sentence, rule.toString()); } } }  @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages(); }
OkuriganaValidator extends Validator { @Override public void validate(Sentence sentence) { invalidOkurigana.stream().forEach(value -> { int startPosition = sentence.getContent().indexOf(value); if (startPosition != -1) { addLocalizedErrorWithPosition(sentence, startPosition, startPosition + value.length(), value); } } ); for (ExpressionRule rule : invalidOkuriganaTokens) { if (rule.match(sentence.getTokens())) { addLocalizedError(sentence, rule.toString()); } } }  @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages();  }