Skip to content

Commit 2cf4a1f

Browse files
committed
feat(rule): add ないわけではない
1 parent 741b999 commit 2cf4a1f

File tree

5 files changed

+91
-11
lines changed

5 files changed

+91
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
## References
22

3-
- http://repository.kulib.kyoto-u.ac.jp/dspace/bitstream/2433/187059/1/Ronko3_043.pdf
3+
- http://repository.kulib.kyoto-u.ac.jp/dspace/bitastream/2433/187059/1/Ronko3_043.pdf

src/no-doubled-negative-ja.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ import NakumonaiRule from "./rules/なくは-ない";
66
import NidemoNaiRule from "./rules/ないでも-ない";
77
import NimonodehaRule from "./rules/ないものでは-ない";
88
import NikotohanaiRule from "./rules/ないことは-ない";
9+
import NiwakedehanaiRule from "./rules/ないわけでは-ない";
910
export default function (context) {
1011
const {Syntax,getSource, report,RuleError} = context;
1112
const ruleなくもない = NakumonaiRule(context);
1213
const ruleないでもない = NidemoNaiRule(context);
1314
const ruleないものではない = NimonodehaRule(context);
1415
const ruleないことはない = NikotohanaiRule(context);
16+
const ruleないわけではない = NiwakedehanaiRule(context);
1517
return {
1618
[Syntax.Str](node){
1719
const text = getSource(node);
@@ -29,6 +31,7 @@ export default function (context) {
2931
pushError(ruleないでもない(token));
3032
pushError(ruleないものではない(token));
3133
pushError(ruleないことはない(token));
34+
pushError(ruleないわけではない(token));
3235
});
3336
}).then(()=> {
3437
results.forEach(error => {
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// LICENSE : MIT
2+
"use strict";
3+
/*
4+
(e)「~ないわけでは / でもない」
5+
*/
6+
import matchTokenStream from "./../matchTokenStream";
7+
export default function (context) {
8+
const {RuleError} = context;
9+
const matchPatternないわけでもない = matchTokenStream([
10+
{
11+
"basic_form": "ない"
12+
},
13+
{
14+
"surface_form": "わけ",
15+
"pos": "名詞"
16+
},
17+
{
18+
"conjugated_form": "連用形",
19+
"basic_form": "だ"
20+
},
21+
{
22+
"surface_form": "も",
23+
"pos": "助詞"
24+
},
25+
{
26+
"basic_form": "ない",
27+
"pos": "形容詞"
28+
}
29+
]);
30+
const matchPatternないわけではない = matchTokenStream([
31+
{
32+
"basic_form": "ない"
33+
},
34+
{
35+
"surface_form": "わけ",
36+
"pos": "名詞"
37+
},
38+
{
39+
"conjugated_form": "連用形",
40+
"basic_form": "だ"
41+
},
42+
{
43+
"surface_form": "は",
44+
"pos": "助詞"
45+
},
46+
{
47+
"basic_form": "ない"
48+
}
49+
]);
50+
return (token) => {
51+
if (matchPatternないわけでもない(token)) {
52+
return new RuleError("二重否定: 〜ないわけでもない", {
53+
column: token.word_position - 1
54+
});
55+
}
56+
if (matchPatternないわけではない(token)) {
57+
return new RuleError("二重否定: 〜ないわけではない", {
58+
column: token.word_position - 1
59+
});
60+
}
61+
};
62+
}

src/rules/なくは-ない.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,32 @@
99
import matchTokenStream from "./../matchTokenStream";
1010
export default function (context) {
1111
const {RuleError} = context;
12-
const monaiTokens = [
12+
const matchPatternなくもない = matchTokenStream([
1313
{
1414
"basic_form": "ない"
1515
},
1616
{
17-
"surface_form": "",
17+
"surface_form": "",
1818
"pos": "助詞"
1919
},
2020
{
2121
"basic_form": "ない",
2222
"pos": "形容詞"
2323
}
24-
];
25-
26-
const nakuhaTokens = [
24+
]);
25+
const matchPatternなくはない = matchTokenStream([
2726
{
2827
"basic_form": "ない"
2928
},
3029
{
31-
"surface_form": "",
30+
"surface_form": "",
3231
"pos": "助詞"
3332
},
3433
{
3534
"basic_form": "ない",
3635
"pos": "形容詞"
3736
}
38-
];
39-
const matchPatternなくもない = matchTokenStream(nakuhaTokens);
40-
const matchPatternなくはない = matchTokenStream(monaiTokens);
37+
]);
4138
return (token) => {
4239
if (matchPatternなくもない(token)) {
4340
return new RuleError("二重否定: 〜なくもない", {

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

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,25 @@ tester.run("no-doubled-negative", rule, {
8888
column: 10
8989
}
9090
]
91+
},
92+
// e
93+
{
94+
text: "ないわけでもないですが",
95+
errors: [
96+
{
97+
message: "二重否定: 〜ないわけでもない",
98+
column: 7
99+
}
100+
]
101+
},
102+
{
103+
text: "ないわけではないですが",
104+
errors: [
105+
{
106+
message: "二重否定: 〜ないわけではない",
107+
column: 7
108+
}
109+
]
91110
}
92-
93111
]
94112
});

0 commit comments

Comments
 (0)