@Test void mixedStyleWithDesuError() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("JapaneseStyle")) .build(); List<Document> documents = new ArrayList<>(); documents.add( Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("彼の今日のお昼の弁当はのり弁とのり弁とのり弁です。", 1)) .addSentence(new Sentence("それは贅沢である。", 2)) .addSentence(new Sentence("しかし彼には選択肢がなかったのである。", 3)) .build()); 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(22, errors.get(documents.get(0)).get(0).getStartPosition().get().offset); assertEquals(24, errors.get(documents.get(0)).get(0).getEndPosition().get().offset); assertEquals("JapaneseStyle", errors.get(documents.get(0)).get(0).getValidatorName()); }
@Override public void validate(Sentence sentence) { boolean forceDearu = getBoolean("ForceDearu"); if (dearuCount > desumasuCount || forceDearu ) { detectPattern(sentence, DESUMASU_PATTERN); } else { detectPattern(sentence, DEARU_PATTERN); } }
JapaneseStyleValidator extends Validator { @Override public void validate(Sentence sentence) { boolean forceDearu = getBoolean("ForceDearu"); if (dearuCount > desumasuCount || forceDearu ) { detectPattern(sentence, DESUMASU_PATTERN); } else { detectPattern(sentence, DEARU_PATTERN); } } }
JapaneseStyleValidator extends Validator { @Override public void validate(Sentence sentence) { boolean forceDearu = getBoolean("ForceDearu"); if (dearuCount > desumasuCount || forceDearu ) { detectPattern(sentence, DESUMASU_PATTERN); } else { detectPattern(sentence, DEARU_PATTERN); } } JapaneseStyleValidator(); }
JapaneseStyleValidator extends Validator { @Override public void validate(Sentence sentence) { boolean forceDearu = getBoolean("ForceDearu"); if (dearuCount > desumasuCount || forceDearu ) { detectPattern(sentence, DESUMASU_PATTERN); } else { detectPattern(sentence, DEARU_PATTERN); } } JapaneseStyleValidator(); @Override void preValidate(Sentence sentence); @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages(); }
JapaneseStyleValidator extends Validator { @Override public void validate(Sentence sentence) { boolean forceDearu = getBoolean("ForceDearu"); if (dearuCount > desumasuCount || forceDearu ) { detectPattern(sentence, DESUMASU_PATTERN); } else { detectPattern(sentence, DEARU_PATTERN); } } JapaneseStyleValidator(); @Override void preValidate(Sentence sentence); @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages();  }