@Test void testLoadUserDictionary() throws RedPenException { Configuration config = Configuration.builder() .addValidatorConfig(new ValidatorConfiguration("LongKanjiChain").addProperty("list", "特殊相対性理論")) .build(); List<Document> documents = new ArrayList<>();documents.add( Document.builder() .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) { 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();  }