Skip to content

Commit 741b999

Browse files
committed
feat(rule): ないことは~ない
1 parent e7319cd commit 741b999

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

src/no-doubled-negative-ja.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ import {getTokenizer} from "kuromojin";
55
import NakumonaiRule from "./rules/なくは-ない";
66
import NidemoNaiRule from "./rules/ないでも-ない";
77
import NimonodehaRule from "./rules/ないものでは-ない";
8+
import NikotohanaiRule from "./rules/ないことは-ない";
89
export default function (context) {
910
const {Syntax,getSource, report,RuleError} = context;
1011
const ruleなくもない = NakumonaiRule(context);
1112
const ruleないでもない = NidemoNaiRule(context);
1213
const ruleないものではない = NimonodehaRule(context);
14+
const ruleないことはない = NikotohanaiRule(context);
1315
return {
1416
[Syntax.Str](node){
1517
const text = getSource(node);
@@ -26,6 +28,7 @@ export default function (context) {
2628
pushError(ruleなくもない(token));
2729
pushError(ruleないでもない(token));
2830
pushError(ruleないものではない(token));
31+
pushError(ruleないことはない(token));
2932
});
3033
}).then(()=> {
3134
results.forEach(error => {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// LICENSE : MIT
2+
"use strict";
3+
/*
4+
(d)「~ないことは / もない」
5+
~ない(否定助動詞 / 否定形容詞の連体形) + 形式名詞「こと」+ とりたて助詞「は / も」+ 形容詞「ない」
6+
*/
7+
import matchTokenStream from "./../matchTokenStream";
8+
export default function (context) {
9+
const {RuleError} = context;
10+
const matchPatternないことはない = matchTokenStream([
11+
{
12+
"basic_form": "ない"
13+
},
14+
{
15+
"surface_form": "こと",
16+
"pos": "名詞"
17+
},
18+
{
19+
"surface_form": "は",
20+
"pos": "助詞"
21+
},
22+
{
23+
"basic_form": "ない"
24+
//"pos": "形容詞" || "助動詞"
25+
}
26+
]);
27+
const matchPatternないこともない = matchTokenStream([
28+
{
29+
"basic_form": "ない"
30+
},
31+
{
32+
"surface_form": "こと",
33+
"pos": "名詞"
34+
},
35+
{
36+
"surface_form": "も",
37+
"pos": "助詞"
38+
},
39+
{
40+
"basic_form": "ない",
41+
"pos": "形容詞"
42+
}
43+
]);
44+
return (token) => {
45+
if (matchPatternないことはない(token)) {
46+
return new RuleError("二重否定: 〜ないことはない", {
47+
column: token.word_position - 1
48+
});
49+
}
50+
if (matchPatternないこともない(token)) {
51+
return new RuleError("二重否定: 〜ないこともない", {
52+
column: token.word_position - 1
53+
});
54+
}
55+
};
56+
}

test/no-doubled-negative-ja-test.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,35 @@ tester.run("no-doubled-negative", rule, {
6060
column: 21
6161
}
6262
]
63+
},
64+
// d
65+
{
66+
text: "確かにそういった懸念はないことはない。",
67+
errors: [
68+
{
69+
message: "二重否定: 〜ないことはない",
70+
column: 17
71+
}
72+
]
73+
},
74+
{
75+
text: "憂鬱でないこともない。",
76+
errors: [
77+
{
78+
message: "二重否定: 〜ないこともない",
79+
column: 9
80+
}
81+
]
82+
},
83+
{
84+
text: "そういえないこともないですが......",
85+
errors: [
86+
{
87+
message: "二重否定: 〜ないこともない",
88+
column: 10
89+
}
90+
]
6391
}
92+
6493
]
6594
});

0 commit comments

Comments
 (0)