@Test void testSimpleRun() throws RedPenException { List<Document> documents = new ArrayList<>();documents.add( Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("圧倒的な当事者意識を一身に浴びている。", 1)) .build()); Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("LongKanjiChain").addProperty("max_len", 3)) .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) { final Matcher m = pat.matcher(sentence.getContent()); while (m.find()) { final String word = m.group(0); if (!inDictionary(word)) { addLocalizedError(sentence, word, word.length()); } } }
LongKanjiChainValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { final Matcher m = pat.matcher(sentence.getContent()); while (m.find()) { final String word = m.group(0); if (!inDictionary(word)) { addLocalizedError(sentence, word, word.length()); } } } }
LongKanjiChainValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { final Matcher m = pat.matcher(sentence.getContent()); while (m.find()) { final String word = m.group(0); if (!inDictionary(word)) { addLocalizedError(sentence, word, word.length()); } } } LongKanjiChainValidator(); }
LongKanjiChainValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { final Matcher m = pat.matcher(sentence.getContent()); while (m.find()) { final String word = m.group(0); if (!inDictionary(word)) { addLocalizedError(sentence, word, word.length()); } } } LongKanjiChainValidator(); @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages(); }
LongKanjiChainValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { final Matcher m = pat.matcher(sentence.getContent()); while (m.find()) { final String word = m.group(0); if (!inDictionary(word)) { addLocalizedError(sentence, word, word.length()); } } } LongKanjiChainValidator(); @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages();  }