@Test void testSetMinimumRatio() throws RedPenException { Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("KatakanaSpellCheck").addProperty("min_ratio", "0.001")) .build(); List<Document> documents = new ArrayList<>(); documents.add( Document.builder(new NeologdJapaneseTokenizer()) .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)) { katakana.append(c); } else { this.checkKatakanaSpell(sentence, katakana.toString()); katakana.delete(0, katakana.length()); } } checkKatakanaSpell(sentence, katakana.toString()); }
KatakanaSpellCheckValidator 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)) { katakana.append(c); } else { this.checkKatakanaSpell(sentence, katakana.toString()); katakana.delete(0, katakana.length()); } } checkKatakanaSpell(sentence, katakana.toString()); } }
KatakanaSpellCheckValidator 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)) { katakana.append(c); } else { this.checkKatakanaSpell(sentence, katakana.toString()); katakana.delete(0, katakana.length()); } } checkKatakanaSpell(sentence, katakana.toString()); } KatakanaSpellCheckValidator(); }
KatakanaSpellCheckValidator 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)) { katakana.append(c); } else { this.checkKatakanaSpell(sentence, katakana.toString()); katakana.delete(0, katakana.length()); } } checkKatakanaSpell(sentence, katakana.toString()); } KatakanaSpellCheckValidator(); @Override List<String> getSupportedLanguages(); @Override void preValidate(Sentence sentence); @Override void validate(Sentence sentence); }
KatakanaSpellCheckValidator 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)) { katakana.append(c); } else { this.checkKatakanaSpell(sentence, katakana.toString()); katakana.delete(0, katakana.length()); } } checkKatakanaSpell(sentence, katakana.toString()); } KatakanaSpellCheckValidator(); @Override List<String> getSupportedLanguages(); @Override void preValidate(Sentence sentence); @Override void validate(Sentence sentence);  }