@doujinreviewers/textlint-rule-for-creation 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +79 -0
- package/lib/dict/arrow.js +8 -0
- package/lib/dict/arrow.js.map +1 -0
- package/lib/dict/dict.js +54 -0
- package/lib/dict/dict.js.map +1 -0
- package/lib/dict/dict2.js +30 -0
- package/lib/dict/dict2.js.map +1 -0
- package/lib/dict/dictAA.js +30 -0
- package/lib/dict/dictAA.js.map +1 -0
- package/lib/dict/dict_miss.js +30 -0
- package/lib/dict/dict_miss.js.map +1 -0
- package/lib/dict/gozidatuzi.js +56 -0
- package/lib/dict/gozidatuzi.js.map +1 -0
- package/lib/dict/miss.js +30 -0
- package/lib/dict/miss.js.map +1 -0
- package/lib/dict/retasu.js +14 -0
- package/lib/dict/retasu.js.map +1 -0
- package/lib/dict/saire.js +37 -0
- package/lib/dict/saire.js.map +1 -0
- package/lib/dict/sanuki.js +15 -0
- package/lib/dict/sanuki.js.map +1 -0
- package/lib/dict/zyosi.js +170 -0
- package/lib/dict/zyosi.js.map +1 -0
- package/lib/enhanced-engine.js +79 -0
- package/lib/enhanced-engine.js.map +1 -0
- package/lib/modified-engine.js +27 -0
- package/lib/modified-engine.js.map +1 -0
- package/lib/textlint-rule-for-creation.js +95 -0
- package/lib/textlint-rule-for-creation.js.map +1 -0
- package/package.json +39 -0
- package/src/dict/arrow.js +93 -0
- package/src/dict/gozidatuzi.js +68 -0
- package/src/dict/retasu.js +16 -0
- package/src/dict/saire.js +46 -0
- package/src/dict/sanuki.js +17 -0
- package/src/dict/zyosi.js +204 -0
- package/src/enhanced-engine.js +60 -0
- package/src/textlint-rule-for-creation.js +57 -0
@@ -0,0 +1,46 @@
|
|
1
|
+
module.exports = [
|
2
|
+
{
|
3
|
+
"message": "不要な「さ」が挿入されています。",
|
4
|
+
"expected": "$2$3",
|
5
|
+
"tokens": [
|
6
|
+
{
|
7
|
+
"conjugated_form": "ガル接続",
|
8
|
+
"basic_form": ["辛い", "美味しい", "寒い"],
|
9
|
+
"_capture": "$2"
|
10
|
+
},
|
11
|
+
{
|
12
|
+
"surface_form": "さ",
|
13
|
+
"_index": true
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"basic_form": "そう",
|
17
|
+
"pos_detail_1": ["接尾", "助詞類接続"],
|
18
|
+
"_capture": "$3"
|
19
|
+
}
|
20
|
+
]
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"message": "不要な「さ」が挿入されています。",
|
24
|
+
"expected": "$1$2$3",
|
25
|
+
"tokens": [
|
26
|
+
{
|
27
|
+
"pos": "動詞",
|
28
|
+
"_capture": "$1"
|
29
|
+
},
|
30
|
+
{
|
31
|
+
"surface_form": "た",
|
32
|
+
"pos": "助動詞",
|
33
|
+
"_capture": "$2"
|
34
|
+
},
|
35
|
+
{
|
36
|
+
"surface_form": "さ",
|
37
|
+
"_index": true
|
38
|
+
},
|
39
|
+
{
|
40
|
+
"basic_form": "そう",
|
41
|
+
"pos_detail_1": ["接尾", "助詞類接続"],
|
42
|
+
"_capture": "$3"
|
43
|
+
}
|
44
|
+
]
|
45
|
+
},
|
46
|
+
];
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module.exports = [
|
2
|
+
{
|
3
|
+
"message": "「さ」が抜けています。",
|
4
|
+
"expected": "$1さ$2",
|
5
|
+
"tokens": [
|
6
|
+
{
|
7
|
+
"basic_form": ["良い", "無", "無い"],
|
8
|
+
"_capture": "$1"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"surface_form": "そう",
|
12
|
+
"pos_detail_1": ["接尾", "助詞類接続"],
|
13
|
+
"_capture": "$2"
|
14
|
+
}
|
15
|
+
]
|
16
|
+
},
|
17
|
+
];
|
@@ -0,0 +1,204 @@
|
|
1
|
+
module.exports = [
|
2
|
+
// {
|
3
|
+
// "message": "助詞の連続",
|
4
|
+
// "tokens": [
|
5
|
+
// {
|
6
|
+
// "pos": "助詞",
|
7
|
+
// },{
|
8
|
+
// "pos": "助詞",
|
9
|
+
// "pos_detail_2": ["一般", "*"]//引用や連語ならスルー
|
10
|
+
// }
|
11
|
+
// ]
|
12
|
+
// },
|
13
|
+
{
|
14
|
+
"message": "助詞の連続",
|
15
|
+
"expected": '$1',
|
16
|
+
"tokens": [
|
17
|
+
{
|
18
|
+
"pos": "助詞",
|
19
|
+
"pos_detail_1": "係助詞",
|
20
|
+
"_capture": "$1"
|
21
|
+
},{
|
22
|
+
"pos": "助詞",
|
23
|
+
"pos_detail_1": "係助詞",
|
24
|
+
"_capture": "$2"
|
25
|
+
}
|
26
|
+
]
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"message": "助詞の連続",
|
30
|
+
"expected": '$1',
|
31
|
+
"tokens": [
|
32
|
+
{
|
33
|
+
"surface_form": ["が", "を"],
|
34
|
+
"pos": "助詞",
|
35
|
+
"pos_detail_1": "格助詞",
|
36
|
+
"_capture": "$1"
|
37
|
+
},{
|
38
|
+
"pos": "助詞",
|
39
|
+
"pos_detail_1": "係助詞",
|
40
|
+
"_capture": "$2"
|
41
|
+
}
|
42
|
+
]
|
43
|
+
},
|
44
|
+
{
|
45
|
+
"message": "助詞の連続",
|
46
|
+
"expected": '$1',
|
47
|
+
"tokens": [
|
48
|
+
{
|
49
|
+
"surface_form": ["が", "を", "で", "に", "へ", "より"],
|
50
|
+
"pos": "助詞",
|
51
|
+
"pos_detail_1": "格助詞",
|
52
|
+
"_capture": "$1"
|
53
|
+
},{
|
54
|
+
"pos": "助詞",
|
55
|
+
"pos_detail_1": "助詞",
|
56
|
+
"_capture": "$2"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
},
|
60
|
+
{
|
61
|
+
"message": "助詞の連続",
|
62
|
+
"expected": '$1',
|
63
|
+
"tokens": [
|
64
|
+
{
|
65
|
+
"pos": "助詞",
|
66
|
+
"pos_detail_1": "格助詞",
|
67
|
+
"_capture": "$1"
|
68
|
+
},{
|
69
|
+
"pos": "助詞",
|
70
|
+
"pos_detail_1": "格助詞",
|
71
|
+
"_capture": "$2"
|
72
|
+
}
|
73
|
+
]
|
74
|
+
},
|
75
|
+
{
|
76
|
+
"message": "助詞の連続",
|
77
|
+
"expected": '$1',
|
78
|
+
"tokens": [
|
79
|
+
{
|
80
|
+
"surface_form": "を",
|
81
|
+
"pos": "助詞",
|
82
|
+
"pos_detail_1": "格助詞",
|
83
|
+
"_capture": "$1"
|
84
|
+
},{
|
85
|
+
"pos": "助詞",
|
86
|
+
"pos_detail_1": "副助詞",
|
87
|
+
"_capture": "$2"
|
88
|
+
}
|
89
|
+
]
|
90
|
+
},
|
91
|
+
{
|
92
|
+
"message": "助詞の連続",
|
93
|
+
"expected": '$1',
|
94
|
+
"tokens": [
|
95
|
+
{
|
96
|
+
"pos": "助詞",
|
97
|
+
"pos_detail_1": '連体化',
|
98
|
+
"_capture": "$1"
|
99
|
+
},{
|
100
|
+
"pos": "助詞",
|
101
|
+
"pos_detail_1": '連体化',
|
102
|
+
"_capture": "$2"
|
103
|
+
}
|
104
|
+
]
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"message": "助詞の連続",
|
108
|
+
"expected": '$1',
|
109
|
+
"tokens": [
|
110
|
+
{
|
111
|
+
"pos": "助詞",
|
112
|
+
"pos_detail_1": '格助詞',
|
113
|
+
"_capture": "$1"
|
114
|
+
},{
|
115
|
+
"pos": "助詞",
|
116
|
+
"pos_detail_1": '連体化',
|
117
|
+
"_capture": "$2"
|
118
|
+
}
|
119
|
+
]
|
120
|
+
},
|
121
|
+
{
|
122
|
+
"message": "助詞の連続",
|
123
|
+
"expected": '$1',
|
124
|
+
"tokens": [
|
125
|
+
{
|
126
|
+
"pos": "助詞",
|
127
|
+
"pos_detail_1": '並立助詞',
|
128
|
+
"_capture": "$1"
|
129
|
+
},{
|
130
|
+
"pos": "助詞",
|
131
|
+
"_capture": "$2"
|
132
|
+
}
|
133
|
+
]
|
134
|
+
},
|
135
|
+
{
|
136
|
+
"message": "助詞の連続",
|
137
|
+
"expected": '$1',
|
138
|
+
"tokens": [
|
139
|
+
{
|
140
|
+
"pos": "助詞",
|
141
|
+
"pos_detail_1": '副詞化',
|
142
|
+
"_capture": "$1"
|
143
|
+
},{
|
144
|
+
"pos": "助詞",
|
145
|
+
"pos_detail_1": "格助詞",
|
146
|
+
"_capture": "$2"
|
147
|
+
}
|
148
|
+
]
|
149
|
+
},
|
150
|
+
{
|
151
|
+
"message": '助詞の連続',
|
152
|
+
"expected": '$1',
|
153
|
+
"tokens": [
|
154
|
+
{
|
155
|
+
"pos": "助詞",
|
156
|
+
"pos_detail_1": "接続助詞",
|
157
|
+
"_capture": "$1"
|
158
|
+
},{
|
159
|
+
"pos": "副詞化",
|
160
|
+
"_capture": "$2"
|
161
|
+
}
|
162
|
+
]
|
163
|
+
},
|
164
|
+
// {
|
165
|
+
// "message": '助動詞の連続',
|
166
|
+
// "tokens": [
|
167
|
+
// {
|
168
|
+
// "pos": "助動詞",
|
169
|
+
// },{
|
170
|
+
// "pos": "助動詞",
|
171
|
+
// }
|
172
|
+
// ]
|
173
|
+
// },
|
174
|
+
{
|
175
|
+
"message": '接続助詞と接続詞の連続',
|
176
|
+
"expected": '$1',
|
177
|
+
"tokens": [
|
178
|
+
{
|
179
|
+
"pos": "助詞",
|
180
|
+
"pos_detail_1": "接続助詞",
|
181
|
+
"_capture": "$1"
|
182
|
+
},{
|
183
|
+
"surface_form": ["で","が","の","を","へ","や"],
|
184
|
+
"pos": "接続詞",
|
185
|
+
"_capture": "$2"
|
186
|
+
}
|
187
|
+
]
|
188
|
+
},
|
189
|
+
{
|
190
|
+
"message": '接続助詞と助動詞の連続',
|
191
|
+
"expected": '$1',
|
192
|
+
"tokens": [
|
193
|
+
{
|
194
|
+
"pos": "助詞",
|
195
|
+
"pos_detail_1": "接続助詞",
|
196
|
+
"_capture": "$1"
|
197
|
+
},{
|
198
|
+
"surface_form": ["で","が","の","を","へ","や"],
|
199
|
+
"pos": "助動詞",
|
200
|
+
"_capture": "$2"
|
201
|
+
}
|
202
|
+
]
|
203
|
+
},
|
204
|
+
];
|
@@ -0,0 +1,60 @@
|
|
1
|
+
const arrow = require('./dict/arrow');
|
2
|
+
|
3
|
+
class EnhancedEngine {
|
4
|
+
|
5
|
+
constructor() {
|
6
|
+
}
|
7
|
+
|
8
|
+
async checkRetasu(tokenizer, text){
|
9
|
+
if(/れ$/.test(text)){
|
10
|
+
text += "る";
|
11
|
+
}
|
12
|
+
let tokens = await tokenizer(text);
|
13
|
+
let meirei = await tokenizer(tokens[0].surface_form + "。");
|
14
|
+
if(meirei[0].conjugated_form == "命令e" || /五段/.test(meirei[0].conjugated_type)){
|
15
|
+
// 「れる」を抜いても命令形で意味が通じるか、最初の文字が五段活用動詞になると多分れ足す言葉
|
16
|
+
if(!arrow.jidousi_tadousi.includes(meirei[0].surface_form)){
|
17
|
+
// 許可リストにもない
|
18
|
+
return true;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return false;
|
22
|
+
}
|
23
|
+
|
24
|
+
async checkZyosi(tokenizer, result, fulltext){
|
25
|
+
let piece = fulltext.slice(result.range[0], result.range[1]);
|
26
|
+
if(arrow.zyosi.includes(piece)){
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
let fulltokens = await tokenizer(fulltext);
|
30
|
+
let tokens = [];
|
31
|
+
fulltokens.reduce((prev, current) => {
|
32
|
+
if (prev.pos == "助詞" && current.pos == "助詞") {
|
33
|
+
if(prev.surface_form + current.surface_form == piece){
|
34
|
+
tokens = [prev, current];
|
35
|
+
}
|
36
|
+
}
|
37
|
+
return current;
|
38
|
+
});
|
39
|
+
if(new RegExp(tokens[0].surface_form.repeat(3) + "|" + tokens[0].surface_form.repeat(2) + "[~〜ー!!]").test(fulltext)){
|
40
|
+
return false;
|
41
|
+
}
|
42
|
+
if(tokens[0].surface_form == tokens[1].surface_form){
|
43
|
+
return true;
|
44
|
+
}
|
45
|
+
if((/終助詞/.test(tokens[0].pos_detail_1) || /終助詞/.test(tokens[1].pos_detail_1))
|
46
|
+
|| /接続助詞/.test(tokens[0].pos_detail_1)
|
47
|
+
|| (/のみ|から|だけ|とか|など|まで|ばかり|ばっかり|/.test(tokens[0].surface_form) && /格助詞/.test(tokens[1].pos_detail_1))
|
48
|
+
|| /連体化/.test(tokens[1].pos_detail_1)
|
49
|
+
|| ((/格助詞/.test(tokens[0].pos_detail_1) && /係助詞/.test(tokens[1].pos_detail_1)) && !/[をが]/.test(tokens[0].surface_form))
|
50
|
+
|| (/特殊/.test(tokens[0].pos_detail_1) || /特殊/.test(tokens[1].pos_detail_1))
|
51
|
+
|| (/引用/.test(tokens[0].pos_detail_2) && /接続助詞/.test(tokens[1].pos_detail_1))
|
52
|
+
){
|
53
|
+
return false;
|
54
|
+
}
|
55
|
+
return true;
|
56
|
+
}
|
57
|
+
|
58
|
+
}
|
59
|
+
|
60
|
+
export default new EnhancedEngine();
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import { createTextlintMatcher } from "morpheme-match-textlint";
|
2
|
+
import { tokenize } from "kuromojin";
|
3
|
+
import EnhancedEngine from "./enhanced-engine";
|
4
|
+
|
5
|
+
const loadDictionaries = () => {
|
6
|
+
// unavoidable
|
7
|
+
let dict1 = require('./dict/zyosi');
|
8
|
+
let dict2 = require('./dict/gozidatuzi');
|
9
|
+
let dict3 = require('./dict/retasu');
|
10
|
+
let dict4 = require('./dict/sanuki');
|
11
|
+
let dict5 = require('./dict/saire');
|
12
|
+
return dict1.concat(dict2, dict3, dict4, dict5);
|
13
|
+
}
|
14
|
+
|
15
|
+
const reporter = (context) => {
|
16
|
+
const { Syntax, RuleError, fixer, report, getSource } = context;
|
17
|
+
const matchAll = createTextlintMatcher({
|
18
|
+
tokenize: tokenize,
|
19
|
+
dictionaries: loadDictionaries()
|
20
|
+
});
|
21
|
+
const engine = EnhancedEngine
|
22
|
+
return {
|
23
|
+
[Syntax.Str](node) {
|
24
|
+
return new Promise(async (resolve, reject) => {
|
25
|
+
const text = getSource(node);
|
26
|
+
let results = await matchAll(text);
|
27
|
+
for (const result of results) {
|
28
|
+
if(result.message == "れ足す言葉の可能性があります"){
|
29
|
+
if(!(await engine.checkRetasu(tokenize, text.slice(result.range[0],result.range[1])))){
|
30
|
+
continue;
|
31
|
+
}
|
32
|
+
}else if(result.message == "助詞の連続"){
|
33
|
+
if(!(await engine.checkZyosi(tokenize, result, text))){
|
34
|
+
continue;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
if (result.expected) {
|
38
|
+
report(node, new RuleError(result.message, {
|
39
|
+
index: result.index,
|
40
|
+
fix: fixer.replaceTextRange(result.range, result.expected)
|
41
|
+
}));
|
42
|
+
} else {
|
43
|
+
report(node, new RuleError(result.message, {
|
44
|
+
index: result.index
|
45
|
+
}));
|
46
|
+
}
|
47
|
+
}
|
48
|
+
resolve();
|
49
|
+
});
|
50
|
+
}
|
51
|
+
};
|
52
|
+
};
|
53
|
+
|
54
|
+
export default {
|
55
|
+
linter: reporter,
|
56
|
+
fixer: reporter
|
57
|
+
};
|