Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed false positive for "食べられる" (potential verb) by JapaneseBrokenExpression #880

Merged
merged 3 commits into from Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
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