@Test void testValid() throws Exception { List<Document> documents = new ArrayList<>(); documents.add(Document.builder(new NeologdJapaneseTokenizer()) .addSection(1) .addParagraph() .addSentence(new Sentence("PDF形式の文書を見られない環境がある。", 1)) .build()); Configuration config = Configuration.builder("ja") .addValidatorConfig(new ValidatorConfiguration("JapaneseBrokenExpression")) .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) { final List<TokenElement> tokens = sentence.getTokens(); for (int i = 0; i < (tokens.size() - 1); ++i) { final TokenElement p = tokens.get(i); final List<String> ptags = p.getTags(); if (ptags.get(0).equals("動詞") && ptags.get(1).equals("自立") && ptags.get(2).equals("一段") && ptags.get(3).equals("未然形")) { final TokenElement q = tokens.get(i+1); final List<String> qtags = q.getTags(); if (qtags.get(0).equals("動詞") && qtags.get(1).equals("接尾") && qtags.get(2).equals("一段") && qtags.get(3).equals("未然形") && q.getSurface().equals("られ")) { } else { addLocalizedError(sentence, p.getSurface()); } } } }
JapaneseBrokenExpressionValidator extends Validator { @Override public void validate(Sentence sentence) { final List<TokenElement> tokens = sentence.getTokens(); for (int i = 0; i < (tokens.size() - 1); ++i) { final TokenElement p = tokens.get(i); final List<String> ptags = p.getTags(); if (ptags.get(0).equals("動詞") && ptags.get(1).equals("自立") && ptags.get(2).equals("一段") && ptags.get(3).equals("未然形")) { final TokenElement q = tokens.get(i+1); final List<String> qtags = q.getTags(); if (qtags.get(0).equals("動詞") && qtags.get(1).equals("接尾") && qtags.get(2).equals("一段") && qtags.get(3).equals("未然形") && q.getSurface().equals("られ")) { } else { addLocalizedError(sentence, p.getSurface()); } } } } }
JapaneseBrokenExpressionValidator extends Validator { @Override public void validate(Sentence sentence) { final List<TokenElement> tokens = sentence.getTokens(); for (int i = 0; i < (tokens.size() - 1); ++i) { final TokenElement p = tokens.get(i); final List<String> ptags = p.getTags(); if (ptags.get(0).equals("動詞") && ptags.get(1).equals("自立") && ptags.get(2).equals("一段") && ptags.get(3).equals("未然形")) { final TokenElement q = tokens.get(i+1); final List<String> qtags = q.getTags(); if (qtags.get(0).equals("動詞") && qtags.get(1).equals("接尾") && qtags.get(2).equals("一段") && qtags.get(3).equals("未然形") && q.getSurface().equals("られ")) { } else { addLocalizedError(sentence, p.getSurface()); } } } }  }
JapaneseBrokenExpressionValidator extends Validator { @Override public void validate(Sentence sentence) { final List<TokenElement> tokens = sentence.getTokens(); for (int i = 0; i < (tokens.size() - 1); ++i) { final TokenElement p = tokens.get(i); final List<String> ptags = p.getTags(); if (ptags.get(0).equals("動詞") && ptags.get(1).equals("自立") && ptags.get(2).equals("一段") && ptags.get(3).equals("未然形")) { final TokenElement q = tokens.get(i+1); final List<String> qtags = q.getTags(); if (qtags.get(0).equals("動詞") && qtags.get(1).equals("接尾") && qtags.get(2).equals("一段") && qtags.get(3).equals("未然形") && q.getSurface().equals("られ")) { } else { addLocalizedError(sentence, p.getSurface()); } } } }  @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages(); }
JapaneseBrokenExpressionValidator extends Validator { @Override public void validate(Sentence sentence) { final List<TokenElement> tokens = sentence.getTokens(); for (int i = 0; i < (tokens.size() - 1); ++i) { final TokenElement p = tokens.get(i); final List<String> ptags = p.getTags(); if (ptags.get(0).equals("動詞") && ptags.get(1).equals("自立") && ptags.get(2).equals("一段") && ptags.get(3).equals("未然形")) { final TokenElement q = tokens.get(i+1); final List<String> qtags = q.getTags(); if (qtags.get(0).equals("動詞") && qtags.get(1).equals("接尾") && qtags.get(2).equals("一段") && qtags.get(3).equals("未然形") && q.getSurface().equals("られ")) { } else { addLocalizedError(sentence, p.getSurface()); } } } }  @Override void validate(Sentence sentence); @Override List<String> getSupportedLanguages();  }