@Test void detectNormalizedReadings() throws RedPenException { config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration(validatorName)) .build(); Document document = prepareSimpleDocument("このインデックスはあのインデクスとは違います。"); RedPen redPen = new RedPen(config); Map<Document, List<ValidationError>> errors = redPen.validate(singletonList(document)); assertEquals(1, errors.get(document).size()); }
@Override public void validate(Document document) { if (!sentenceMap.containsKey(document)) { throw new IllegalStateException("Document " + document.getFileName() + " does not have any sentence"); } for (Sentence sentence : sentenceMap.get(document)) { for (TokenElement token : sentence.getTokens()) { String reading = getReading(token); if (!this.readingMap.get(document).containsKey(reading)) { continue; } generateErrors(document, sentence, token, reading); this.readingMap.get(document).remove(reading); } } }
JapaneseExpressionVariationValidator extends KeyValueDictionaryValidator { @Override public void validate(Document document) { if (!sentenceMap.containsKey(document)) { throw new IllegalStateException("Document " + document.getFileName() + " does not have any sentence"); } for (Sentence sentence : sentenceMap.get(document)) { for (TokenElement token : sentence.getTokens()) { String reading = getReading(token); if (!this.readingMap.get(document).containsKey(reading)) { continue; } generateErrors(document, sentence, token, reading); this.readingMap.get(document).remove(reading); } } } }
JapaneseExpressionVariationValidator extends KeyValueDictionaryValidator { @Override public void validate(Document document) { if (!sentenceMap.containsKey(document)) { throw new IllegalStateException("Document " + document.getFileName() + " does not have any sentence"); } for (Sentence sentence : sentenceMap.get(document)) { for (TokenElement token : sentence.getTokens()) { String reading = getReading(token); if (!this.readingMap.get(document).containsKey(reading)) { continue; } generateErrors(document, sentence, token, reading); this.readingMap.get(document).remove(reading); } } } JapaneseExpressionVariationValidator(); }
JapaneseExpressionVariationValidator extends KeyValueDictionaryValidator { @Override public void validate(Document document) { if (!sentenceMap.containsKey(document)) { throw new IllegalStateException("Document " + document.getFileName() + " does not have any sentence"); } for (Sentence sentence : sentenceMap.get(document)) { for (TokenElement token : sentence.getTokens()) { String reading = getReading(token); if (!this.readingMap.get(document).containsKey(reading)) { continue; } generateErrors(document, sentence, token, reading); this.readingMap.get(document).remove(reading); } } } JapaneseExpressionVariationValidator(); @Override void validate(Document document); @Override void preValidate(Document document); @Override List<String> getSupportedLanguages(); }
JapaneseExpressionVariationValidator extends KeyValueDictionaryValidator { @Override public void validate(Document document) { if (!sentenceMap.containsKey(document)) { throw new IllegalStateException("Document " + document.getFileName() + " does not have any sentence"); } for (Sentence sentence : sentenceMap.get(document)) { for (TokenElement token : sentence.getTokens()) { String reading = getReading(token); if (!this.readingMap.get(document).containsKey(reading)) { continue; } generateErrors(document, sentence, token, reading); this.readingMap.get(document).remove(reading); } } } JapaneseExpressionVariationValidator(); @Override void validate(Document document); @Override void preValidate(Document document); @Override List<String> getSupportedLanguages();  }