Skip to content

Commit

Permalink
Merge 4ac46d3 into 4ea76e6
Browse files Browse the repository at this point in the history
  • Loading branch information
hirokiky committed Oct 16, 2020
2 parents 4ea76e6 + 4ac46d3 commit 53dcfed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,12 @@ public void validate(Sentence sentence) {
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("未然形")) {
if (ptags.get(0).equals("動詞") && p.getSurface().equals("見れる")) {
addLocalizedError(sentence, p.getSurface());
} else 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("られ")) {
if (qtags.get(0).equals("動詞") && qtags.get(1).equals("接尾") && q.getSurface().startsWith("られ")) {
} else {
addLocalizedError(sentence, p.getSurface());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ void testInvalid() throws Exception {
.addSection(1)
.addParagraph()
.addSentence(new Sentence("PDF形式の文書を見れない環境がある。", 1))
.addSentence(new Sentence("PDF形式の文書を見れる環境だ。", 2))
.addSentence(new Sentence("熱くて寝れない", 3))
.addSentence(new Sentence("今日はぐっすり寝れる", 4))

.build());

Configuration config = Configuration.builder("ja")
Expand All @@ -48,7 +52,7 @@ void testInvalid() throws Exception {

RedPen redPen = new RedPen(config);
Map<Document, List<ValidationError>> errors = redPen.validate(documents);
assertEquals(1, errors.get(documents.get(0)).size());
assertEquals(4, errors.get(documents.get(0)).size());
}

@Test
Expand All @@ -58,6 +62,9 @@ void testValid() throws Exception {
.addSection(1)
.addParagraph()
.addSentence(new Sentence("PDF形式の文書を見られない環境がある。", 1))
.addSentence(new Sentence("PDF形式の文章を見られる環境だ。", 2))
.addSentence(new Sentence("熱くて寝られない", 3))
.addSentence(new Sentence("今日はぐっすり寝られる", 4))
.build());

Configuration config = Configuration.builder("ja")
Expand Down

0 comments on commit 53dcfed

Please sign in to comment.