@Test void mixedtStyles() throws RedPenException { String sampleText = "今日はいい天気です。\n" + "昨日は雨だったが、持ち直しました。\n" + "明日もいい天気だといいですね。"; Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("JapaneseStyle")) .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(2, errors.get(documents.get(0)).get(0).getLineNumber()); assertEquals(4, errors.get(documents.get(0)).get(0).getStartPosition().get().offset); assertEquals(7, 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();  }