@Test void testHonorsSkipWordList() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("KatakanaEndHyphen").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(0, errors.get(documents.get(0)).size()); }
@Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); } }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }  }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); static boolean isKatakanaEndHyphen(String katakana); }
KatakanaEndHyphenValidator extends DictionaryValidator { @Override public void validate(Sentence sentence) { StringBuilder katakana = new StringBuilder(); for (int i = 0; i < sentence.getContent().length(); i++) { char c = sentence.getContent().charAt(i); if (StringUtils.isKatakana(c) && c != KATAKANA_MIDDLE_DOT) { katakana.append(c); } else { this.checkKatakanaEndHyphen(sentence, katakana.toString(), i-1); katakana.delete(0, katakana.length()); } } this.checkKatakanaEndHyphen(sentence, katakana.toString(), sentence.getContent().length() - 1); }  @Override List<String> getSupportedLanguages(); @Override void validate(Sentence sentence); static boolean isKatakanaEndHyphen(String katakana);  }