@doujinreviewers/textlint-rule-for-creation 0.0.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.
Potentially problematic release.
This version of @doujinreviewers/textlint-rule-for-creation might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +76 -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/textlint-rule-for-creation.js +60 -0
- package/lib/textlint-rule-for-creation.js.map +1 -0
- package/package.json +39 -0
- package/src/dict/dict.js +55 -0
- package/src/dict/dict2.js +32 -0
- package/src/textlint-rule-for-creation.js +41 -0
package/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2021 レヴューちゃん
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# textlint-rule-for-creation
|
2
|
+
日本語の明確な誤りのみを検出するtextlintルール
|
3
|
+
|
4
|
+
創作での使用を想定し、クリエイターの邪魔をしないことを目指す
|
5
|
+
|
6
|
+
## 誤りとするもの
|
7
|
+
- 誤字脱字
|
8
|
+
- 助詞の連続
|
9
|
+
- サ抜き言葉、サ入れ言葉、れ足す言葉
|
10
|
+
|
11
|
+
## 表現の範疇として許容するもの
|
12
|
+
- 誤りとするもの以外の全て
|
13
|
+
|
14
|
+
例えば、文章の形式、スタイル、文体、文の冗長さ、二重否定、二重助詞、表記ゆれ、送り仮名のゆれ、記号や三点リーダーの使い方など
|
15
|
+
|
16
|
+
- ら抜き言葉
|
17
|
+
|
18
|
+
これで喋るキャラがいるかもしれないし、作品の雰囲気に必要かもしれない
|
19
|
+
|
20
|
+
## インストール
|
21
|
+
|
22
|
+
npm install textlint-rule-for-creation
|
23
|
+
|
24
|
+
## 使い方
|
25
|
+
|
26
|
+
`.textlintrc`に設定して使う
|
27
|
+
|
28
|
+
```json
|
29
|
+
{
|
30
|
+
"rules": {
|
31
|
+
"for-creation": true
|
32
|
+
}
|
33
|
+
}
|
34
|
+
```
|
35
|
+
|
36
|
+
コマンドラインで使う
|
37
|
+
|
38
|
+
```
|
39
|
+
textlint --rule for-creation README.md
|
40
|
+
```
|
41
|
+
|
42
|
+
### Build
|
43
|
+
|
44
|
+
`src/` 以下がソースコード
|
45
|
+
|
46
|
+
ビルド後のコードは `lib` フォルダーに入る
|
47
|
+
|
48
|
+
npm run build
|
49
|
+
|
50
|
+
### Test
|
51
|
+
|
52
|
+
[textlint-tester](https://github.com/textlint/textlint-tester)で `test` フォルダのコードを実行
|
53
|
+
|
54
|
+
npm test
|
55
|
+
|
56
|
+
## License
|
57
|
+
|
58
|
+
MIT
|
59
|
+
|
60
|
+
## 特記
|
61
|
+
[script-compiler](https://github.com/textlint/editor/tree/master/packages/%40textlint/script-compiler)でworkerにコンパイルして使いたいが、
|
62
|
+
|
63
|
+
2022年1月の時点では外部ファイルのロードに問題がある(nodeのfsモジュールがブラウザで動作しないため)
|
64
|
+
|
65
|
+
そのため、本ルールではfsモジュールを使用しなくても良いようにしている
|
66
|
+
|
67
|
+
問題が修正されるまではこの設計を維持する
|
68
|
+
|
69
|
+
## 参考
|
70
|
+
### worker
|
71
|
+
|
72
|
+
[textlint 12リリース、ブラウザで動くtextlint editorをベータリリース](https://efcl.info/2021/05/27/textlint-12-editor/)
|
73
|
+
|
74
|
+
### ルール
|
75
|
+
[]()
|
76
|
+
[]()
|
package/lib/dict/dict.js
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = [{
|
4
|
+
message: "\"\u3059\u308B\u3053\u3068\u304C\u53EF\u80FD$1\"\u306F\u5197\u9577\u306A\u8868\u73FE\u3067\u3059\u3002\"\u3059\u308B\u3053\u3068\u304C\u53EF\u80FD\"\u3092\u7701\u304D\u7C21\u6F54\u306A\u8868\u73FE\u306B\u3059\u308B\u3068\u6587\u7AE0\u304C\u660E\u77AD\u306B\u306A\u308A\u307E\u3059\u3002",
|
5
|
+
tokens: [{
|
6
|
+
"surface_form": "する",
|
7
|
+
"pos": "動詞",
|
8
|
+
"pos_detail_1": "自立",
|
9
|
+
"pos_detail_2": "*",
|
10
|
+
"pos_detail_3": "*",
|
11
|
+
"conjugated_type": "サ変・スル",
|
12
|
+
"conjugated_form": "基本形",
|
13
|
+
"basic_form": "する",
|
14
|
+
"reading": "スル",
|
15
|
+
"pronunciation": "スル"
|
16
|
+
}, {
|
17
|
+
"surface_form": "こと",
|
18
|
+
"pos": "名詞",
|
19
|
+
"pos_detail_1": "非自立",
|
20
|
+
"pos_detail_2": "一般",
|
21
|
+
"pos_detail_3": "*",
|
22
|
+
"conjugated_type": "*",
|
23
|
+
"conjugated_form": "*",
|
24
|
+
"basic_form": "こと",
|
25
|
+
"reading": "コト",
|
26
|
+
"pronunciation": "コト"
|
27
|
+
}, {
|
28
|
+
"surface_form": "が",
|
29
|
+
"pos": "助詞",
|
30
|
+
"pos_detail_1": "格助詞",
|
31
|
+
"pos_detail_2": "一般",
|
32
|
+
"pos_detail_3": "*",
|
33
|
+
"conjugated_type": "*",
|
34
|
+
"conjugated_form": "*",
|
35
|
+
"basic_form": "が",
|
36
|
+
"reading": "ガ",
|
37
|
+
"pronunciation": "ガ"
|
38
|
+
}, {
|
39
|
+
"surface_form": "可能",
|
40
|
+
"pos": "名詞",
|
41
|
+
"pos_detail_1": "形容動詞語幹",
|
42
|
+
"pos_detail_2": "*",
|
43
|
+
"pos_detail_3": "*",
|
44
|
+
"conjugated_type": "*",
|
45
|
+
"conjugated_form": "*",
|
46
|
+
"basic_form": "可能",
|
47
|
+
"reading": "カノウ",
|
48
|
+
"pronunciation": "カノー"
|
49
|
+
}, {
|
50
|
+
"pos": "助動詞",
|
51
|
+
"_capture": "$1"
|
52
|
+
}]
|
53
|
+
}];
|
54
|
+
//# sourceMappingURL=dict.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/dict.js"],"names":["module","exports","message","tokens"],"mappings":";;AAAAA,MAAM,CAACC,OAAP,GAAiB,CACf;AACIC,EAAAA,OAAO,kSADX;AAEIC,EAAAA,MAAM,EAAE,CACJ;AACI,oBAAgB,IADpB;AAEI,WAAO,IAFX;AAGI,oBAAgB,IAHpB;AAII,oBAAgB,GAJpB;AAKI,oBAAgB,GALpB;AAMI,uBAAmB,OANvB;AAOI,uBAAmB,KAPvB;AAQI,kBAAc,IARlB;AASI,eAAW,IATf;AAUI,qBAAiB;AAVrB,GADI,EAYD;AACC,oBAAgB,IADjB;AAEC,WAAO,IAFR;AAGC,oBAAgB,KAHjB;AAIC,oBAAgB,IAJjB;AAKC,oBAAgB,GALjB;AAMC,uBAAmB,GANpB;AAOC,uBAAmB,GAPpB;AAQC,kBAAc,IARf;AASC,eAAW,IATZ;AAUC,qBAAiB;AAVlB,GAZC,EAuBD;AACC,oBAAgB,GADjB;AAEC,WAAO,IAFR;AAGC,oBAAgB,KAHjB;AAIC,oBAAgB,IAJjB;AAKC,oBAAgB,GALjB;AAMC,uBAAmB,GANpB;AAOC,uBAAmB,GAPpB;AAQC,kBAAc,GARf;AASC,eAAW,GATZ;AAUC,qBAAiB;AAVlB,GAvBC,EAkCD;AACC,oBAAgB,IADjB;AAEC,WAAO,IAFR;AAGC,oBAAgB,QAHjB;AAIC,oBAAgB,GAJjB;AAKC,oBAAgB,GALjB;AAMC,uBAAmB,GANpB;AAOC,uBAAmB,GAPpB;AAQC,kBAAc,IARf;AASC,eAAW,KATZ;AAUC,qBAAiB;AAVlB,GAlCC,EA6CD;AACC,WAAO,KADR;AAEC,gBAAY;AAFb,GA7CC;AAFZ,CADe,CAAjB","sourcesContent":["module.exports = [\n {\n message: `\"することが可能$1\"は冗長な表現です。\"することが可能\"を省き簡潔な表現にすると文章が明瞭になります。`,\n tokens: [\n {\n \"surface_form\": \"する\",\n \"pos\": \"動詞\",\n \"pos_detail_1\": \"自立\",\n \"pos_detail_2\": \"*\",\n \"pos_detail_3\": \"*\",\n \"conjugated_type\": \"サ変・スル\",\n \"conjugated_form\": \"基本形\",\n \"basic_form\": \"する\",\n \"reading\": \"スル\",\n \"pronunciation\": \"スル\"\n }, {\n \"surface_form\": \"こと\",\n \"pos\": \"名詞\",\n \"pos_detail_1\": \"非自立\",\n \"pos_detail_2\": \"一般\",\n \"pos_detail_3\": \"*\",\n \"conjugated_type\": \"*\",\n \"conjugated_form\": \"*\",\n \"basic_form\": \"こと\",\n \"reading\": \"コト\",\n \"pronunciation\": \"コト\"\n }, {\n \"surface_form\": \"が\",\n \"pos\": \"助詞\",\n \"pos_detail_1\": \"格助詞\",\n \"pos_detail_2\": \"一般\",\n \"pos_detail_3\": \"*\",\n \"conjugated_type\": \"*\",\n \"conjugated_form\": \"*\",\n \"basic_form\": \"が\",\n \"reading\": \"ガ\",\n \"pronunciation\": \"ガ\"\n }, {\n \"surface_form\": \"可能\",\n \"pos\": \"名詞\",\n \"pos_detail_1\": \"形容動詞語幹\",\n \"pos_detail_2\": \"*\",\n \"pos_detail_3\": \"*\",\n \"conjugated_type\": \"*\",\n \"conjugated_form\": \"*\",\n \"basic_form\": \"可能\",\n \"reading\": \"カノウ\",\n \"pronunciation\": \"カノー\"\n }, {\n \"pos\": \"助動詞\",\n \"_capture\": \"$1\"\n }\n ]\n },\n];"],"file":"dict.js"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
module.exports = [{
|
4
|
+
"message": "\"適用\"の誤用である可能性があります。適応 => 適用",
|
5
|
+
"expected": "を適用",
|
6
|
+
"tokens": [{
|
7
|
+
"surface_form": "を",
|
8
|
+
"pos": "助詞",
|
9
|
+
"pos_detail_1": "格助詞",
|
10
|
+
"pos_detail_2": "一般",
|
11
|
+
"pos_detail_3": "*",
|
12
|
+
"conjugated_type": "*",
|
13
|
+
"conjugated_form": "*",
|
14
|
+
"basic_form": "を",
|
15
|
+
"reading": "ヲ",
|
16
|
+
"pronunciation": "ヲ"
|
17
|
+
}, {
|
18
|
+
"surface_form": "適応",
|
19
|
+
"pos": "名詞",
|
20
|
+
"pos_detail_1": "サ変接続",
|
21
|
+
"pos_detail_2": "*",
|
22
|
+
"pos_detail_3": "*",
|
23
|
+
"conjugated_type": "*",
|
24
|
+
"conjugated_form": "*",
|
25
|
+
"basic_form": "適応",
|
26
|
+
"reading": "テキオウ",
|
27
|
+
"pronunciation": "テキオー"
|
28
|
+
}]
|
29
|
+
}];
|
30
|
+
//# sourceMappingURL=dict2.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/dict2.js"],"names":["module","exports"],"mappings":";;AAAAA,MAAM,CAACC,OAAP,GAAiB,CACf;AACI,aAAW,+BADf;AAEI,cAAY,KAFhB;AAGI,YAAU,CACR;AACE,oBAAgB,GADlB;AAEE,WAAO,IAFT;AAGE,oBAAgB,KAHlB;AAIE,oBAAgB,IAJlB;AAKE,oBAAgB,GALlB;AAME,uBAAmB,GANrB;AAOE,uBAAmB,GAPrB;AAQE,kBAAc,GARhB;AASE,eAAW,GATb;AAUE,qBAAiB;AAVnB,GADQ,EAaR;AACE,oBAAgB,IADlB;AAEE,WAAO,IAFT;AAGE,oBAAgB,MAHlB;AAIE,oBAAgB,GAJlB;AAKE,oBAAgB,GALlB;AAME,uBAAmB,GANrB;AAOE,uBAAmB,GAPrB;AAQE,kBAAc,IARhB;AASE,eAAW,MATb;AAUE,qBAAiB;AAVnB,GAbQ;AAHd,CADe,CAAjB","sourcesContent":["module.exports = [\n {\n \"message\": \"\\\"適用\\\"の誤用である可能性があります。適応 => 適用\",\n \"expected\": \"を適用\",\n \"tokens\": [\n {\n \"surface_form\": \"を\",\n \"pos\": \"助詞\",\n \"pos_detail_1\": \"格助詞\",\n \"pos_detail_2\": \"一般\",\n \"pos_detail_3\": \"*\",\n \"conjugated_type\": \"*\",\n \"conjugated_form\": \"*\",\n \"basic_form\": \"を\",\n \"reading\": \"ヲ\",\n \"pronunciation\": \"ヲ\"\n },\n {\n \"surface_form\": \"適応\",\n \"pos\": \"名詞\",\n \"pos_detail_1\": \"サ変接続\",\n \"pos_detail_2\": \"*\",\n \"pos_detail_3\": \"*\",\n \"conjugated_type\": \"*\",\n \"conjugated_form\": \"*\",\n \"basic_form\": \"適応\",\n \"reading\": \"テキオウ\",\n \"pronunciation\": \"テキオー\"\n }\n ]\n },\n];"],"file":"dict2.js"}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var _morphemeMatchTextlint = require("morpheme-match-textlint");
|
9
|
+
|
10
|
+
var _kuromojin = require("kuromojin");
|
11
|
+
|
12
|
+
var loadDictionaries = () => {
|
13
|
+
// unavoidable
|
14
|
+
var dict1 = require('./dict/dict');
|
15
|
+
|
16
|
+
var dict2 = require('./dict/dict2');
|
17
|
+
|
18
|
+
return dict1.concat(dict2);
|
19
|
+
};
|
20
|
+
|
21
|
+
var reporter = context => {
|
22
|
+
var {
|
23
|
+
Syntax,
|
24
|
+
RuleError,
|
25
|
+
fixer,
|
26
|
+
report,
|
27
|
+
getSource
|
28
|
+
} = context;
|
29
|
+
var matchAll = (0, _morphemeMatchTextlint.createTextlintMatcher)({
|
30
|
+
tokenize: _kuromojin.tokenize,
|
31
|
+
dictionaries: loadDictionaries()
|
32
|
+
});
|
33
|
+
return {
|
34
|
+
[Syntax.Str](node) {
|
35
|
+
var text = getSource(node);
|
36
|
+
return matchAll(text).then(results => {
|
37
|
+
results.forEach(result => {
|
38
|
+
if (result.expected) {
|
39
|
+
report(node, new RuleError(result.message, {
|
40
|
+
index: result.index,
|
41
|
+
fix: fixer.replaceTextRange(result.range, result.expected)
|
42
|
+
}));
|
43
|
+
} else {
|
44
|
+
report(node, new RuleError(result.message, {
|
45
|
+
index: result.index
|
46
|
+
}));
|
47
|
+
}
|
48
|
+
});
|
49
|
+
});
|
50
|
+
}
|
51
|
+
|
52
|
+
};
|
53
|
+
};
|
54
|
+
|
55
|
+
var _default = {
|
56
|
+
linter: reporter,
|
57
|
+
fixer: reporter
|
58
|
+
};
|
59
|
+
exports.default = _default;
|
60
|
+
//# sourceMappingURL=textlint-rule-for-creation.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/textlint-rule-for-creation.js"],"names":["loadDictionaries","dict1","require","dict2","concat","reporter","context","Syntax","RuleError","fixer","report","getSource","matchAll","tokenize","dictionaries","Str","node","text","then","results","forEach","result","expected","message","index","fix","replaceTextRange","range","linter"],"mappings":";;;;;;;AAAA;;AACA;;AAEA,IAAMA,gBAAgB,GAAG,MAAM;AAC3B;AACA,MAAIC,KAAK,GAAGC,OAAO,CAAC,aAAD,CAAnB;;AACA,MAAIC,KAAK,GAAGD,OAAO,CAAC,cAAD,CAAnB;;AACA,SAAOD,KAAK,CAACG,MAAN,CAAaD,KAAb,CAAP;AACH,CALD;;AAOA,IAAME,QAAQ,GAAIC,OAAD,IAAa;AAC1B,MAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,SAAV;AAAqBC,IAAAA,KAArB;AAA4BC,IAAAA,MAA5B;AAAoCC,IAAAA;AAApC,MAAkDL,OAAxD;AACA,MAAMM,QAAQ,GAAG,kDAAsB;AACnCC,IAAAA,QAAQ,EAAEA,mBADyB;AAEnCC,IAAAA,YAAY,EAAEd,gBAAgB;AAFK,GAAtB,CAAjB;AAIA,SAAO;AACH,KAACO,MAAM,CAACQ,GAAR,EAAaC,IAAb,EAAmB;AACf,UAAMC,IAAI,GAAGN,SAAS,CAACK,IAAD,CAAtB;AACA,aAAOJ,QAAQ,CAACK,IAAD,CAAR,CAAeC,IAAf,CAAoBC,OAAO,IAAI;AAClCA,QAAAA,OAAO,CAACC,OAAR,CAAgBC,MAAM,IAAI;AACtB,cAAIA,MAAM,CAACC,QAAX,EAAqB;AACjBZ,YAAAA,MAAM,CAACM,IAAD,EAAO,IAAIR,SAAJ,CAAca,MAAM,CAACE,OAArB,EAA8B;AACvCC,cAAAA,KAAK,EAAEH,MAAM,CAACG,KADyB;AAEvCC,cAAAA,GAAG,EAAEhB,KAAK,CAACiB,gBAAN,CAAuBL,MAAM,CAACM,KAA9B,EAAqCN,MAAM,CAACC,QAA5C;AAFkC,aAA9B,CAAP,CAAN;AAIH,WALD,MAKO;AACHZ,YAAAA,MAAM,CAACM,IAAD,EAAO,IAAIR,SAAJ,CAAca,MAAM,CAACE,OAArB,EAA8B;AACvCC,cAAAA,KAAK,EAAEH,MAAM,CAACG;AADyB,aAA9B,CAAP,CAAN;AAGH;AACJ,SAXD;AAYH,OAbM,CAAP;AAcH;;AAjBE,GAAP;AAmBH,CAzBD;;eA2Be;AACXI,EAAAA,MAAM,EAAEvB,QADG;AAEXI,EAAAA,KAAK,EAAEJ;AAFI,C","sourcesContent":["import { createTextlintMatcher } from \"morpheme-match-textlint\";\nimport { tokenize } from \"kuromojin\";\n\nconst loadDictionaries = () => {\n // unavoidable\n let dict1 = require('./dict/dict');\n let dict2 = require('./dict/dict2');\n return dict1.concat(dict2)\n}\n\nconst reporter = (context) => {\n const { Syntax, RuleError, fixer, report, getSource } = context;\n const matchAll = createTextlintMatcher({\n tokenize: tokenize,\n dictionaries: loadDictionaries()\n });\n return {\n [Syntax.Str](node) {\n const text = getSource(node);\n return matchAll(text).then(results => {\n results.forEach(result => {\n if (result.expected) {\n report(node, new RuleError(result.message, {\n index: result.index,\n fix: fixer.replaceTextRange(result.range, result.expected)\n }));\n } else {\n report(node, new RuleError(result.message, {\n index: result.index\n }));\n }\n });\n });\n }\n };\n};\n\nexport default {\n linter: reporter,\n fixer: reporter\n};"],"file":"textlint-rule-for-creation.js"}
|
package/package.json
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
{
|
2
|
+
"version": "0.0.1",
|
3
|
+
"keywords": [
|
4
|
+
"textlintrule"
|
5
|
+
],
|
6
|
+
"main": "lib/textlint-rule-for-creation.js",
|
7
|
+
"files": [
|
8
|
+
"lib/",
|
9
|
+
"src/"
|
10
|
+
],
|
11
|
+
"repository": {
|
12
|
+
"type": "git",
|
13
|
+
"url": "git+https://github.com/doujinreviewers/textlint-rule-for-creation.git"
|
14
|
+
},
|
15
|
+
"homepage": "https://github.com/doujinreviewers/textlint-rule-for-creation",
|
16
|
+
"bugs": {
|
17
|
+
"url": "https://github.com/doujinreviewers/textlint-rule-for-creation/issues"
|
18
|
+
},
|
19
|
+
"scripts": {
|
20
|
+
"test": "textlint-scripts test",
|
21
|
+
"build": "textlint-scripts build",
|
22
|
+
"prepublish": "npm run --if-present build"
|
23
|
+
},
|
24
|
+
"devDependencies": {
|
25
|
+
"textlint-scripts": "^12.0.2",
|
26
|
+
"textlint-tester": "^12.0.2"
|
27
|
+
},
|
28
|
+
"name": "@doujinreviewers/textlint-rule-for-creation",
|
29
|
+
"author": "同人Reviewers",
|
30
|
+
"license": "MIT",
|
31
|
+
"description": "日本語の明確な誤りのみを検出するクリエイター向けtextlintルール",
|
32
|
+
"publishConfig": {
|
33
|
+
"access": "public"
|
34
|
+
},
|
35
|
+
"dependencies": {
|
36
|
+
"kuromojin": "^3.0.0",
|
37
|
+
"morpheme-match-textlint": "^2.0.6"
|
38
|
+
}
|
39
|
+
}
|
package/src/dict/dict.js
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
module.exports = [
|
2
|
+
{
|
3
|
+
message: `"することが可能$1"は冗長な表現です。"することが可能"を省き簡潔な表現にすると文章が明瞭になります。`,
|
4
|
+
tokens: [
|
5
|
+
{
|
6
|
+
"surface_form": "する",
|
7
|
+
"pos": "動詞",
|
8
|
+
"pos_detail_1": "自立",
|
9
|
+
"pos_detail_2": "*",
|
10
|
+
"pos_detail_3": "*",
|
11
|
+
"conjugated_type": "サ変・スル",
|
12
|
+
"conjugated_form": "基本形",
|
13
|
+
"basic_form": "する",
|
14
|
+
"reading": "スル",
|
15
|
+
"pronunciation": "スル"
|
16
|
+
}, {
|
17
|
+
"surface_form": "こと",
|
18
|
+
"pos": "名詞",
|
19
|
+
"pos_detail_1": "非自立",
|
20
|
+
"pos_detail_2": "一般",
|
21
|
+
"pos_detail_3": "*",
|
22
|
+
"conjugated_type": "*",
|
23
|
+
"conjugated_form": "*",
|
24
|
+
"basic_form": "こと",
|
25
|
+
"reading": "コト",
|
26
|
+
"pronunciation": "コト"
|
27
|
+
}, {
|
28
|
+
"surface_form": "が",
|
29
|
+
"pos": "助詞",
|
30
|
+
"pos_detail_1": "格助詞",
|
31
|
+
"pos_detail_2": "一般",
|
32
|
+
"pos_detail_3": "*",
|
33
|
+
"conjugated_type": "*",
|
34
|
+
"conjugated_form": "*",
|
35
|
+
"basic_form": "が",
|
36
|
+
"reading": "ガ",
|
37
|
+
"pronunciation": "ガ"
|
38
|
+
}, {
|
39
|
+
"surface_form": "可能",
|
40
|
+
"pos": "名詞",
|
41
|
+
"pos_detail_1": "形容動詞語幹",
|
42
|
+
"pos_detail_2": "*",
|
43
|
+
"pos_detail_3": "*",
|
44
|
+
"conjugated_type": "*",
|
45
|
+
"conjugated_form": "*",
|
46
|
+
"basic_form": "可能",
|
47
|
+
"reading": "カノウ",
|
48
|
+
"pronunciation": "カノー"
|
49
|
+
}, {
|
50
|
+
"pos": "助動詞",
|
51
|
+
"_capture": "$1"
|
52
|
+
}
|
53
|
+
]
|
54
|
+
},
|
55
|
+
];
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module.exports = [
|
2
|
+
{
|
3
|
+
"message": "\"適用\"の誤用である可能性があります。適応 => 適用",
|
4
|
+
"expected": "を適用",
|
5
|
+
"tokens": [
|
6
|
+
{
|
7
|
+
"surface_form": "を",
|
8
|
+
"pos": "助詞",
|
9
|
+
"pos_detail_1": "格助詞",
|
10
|
+
"pos_detail_2": "一般",
|
11
|
+
"pos_detail_3": "*",
|
12
|
+
"conjugated_type": "*",
|
13
|
+
"conjugated_form": "*",
|
14
|
+
"basic_form": "を",
|
15
|
+
"reading": "ヲ",
|
16
|
+
"pronunciation": "ヲ"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"surface_form": "適応",
|
20
|
+
"pos": "名詞",
|
21
|
+
"pos_detail_1": "サ変接続",
|
22
|
+
"pos_detail_2": "*",
|
23
|
+
"pos_detail_3": "*",
|
24
|
+
"conjugated_type": "*",
|
25
|
+
"conjugated_form": "*",
|
26
|
+
"basic_form": "適応",
|
27
|
+
"reading": "テキオウ",
|
28
|
+
"pronunciation": "テキオー"
|
29
|
+
}
|
30
|
+
]
|
31
|
+
},
|
32
|
+
];
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import { createTextlintMatcher } from "morpheme-match-textlint";
|
2
|
+
import { tokenize } from "kuromojin";
|
3
|
+
|
4
|
+
const loadDictionaries = () => {
|
5
|
+
// unavoidable
|
6
|
+
let dict1 = require('./dict/dict');
|
7
|
+
let dict2 = require('./dict/dict2');
|
8
|
+
return dict1.concat(dict2)
|
9
|
+
}
|
10
|
+
|
11
|
+
const reporter = (context) => {
|
12
|
+
const { Syntax, RuleError, fixer, report, getSource } = context;
|
13
|
+
const matchAll = createTextlintMatcher({
|
14
|
+
tokenize: tokenize,
|
15
|
+
dictionaries: loadDictionaries()
|
16
|
+
});
|
17
|
+
return {
|
18
|
+
[Syntax.Str](node) {
|
19
|
+
const text = getSource(node);
|
20
|
+
return matchAll(text).then(results => {
|
21
|
+
results.forEach(result => {
|
22
|
+
if (result.expected) {
|
23
|
+
report(node, new RuleError(result.message, {
|
24
|
+
index: result.index,
|
25
|
+
fix: fixer.replaceTextRange(result.range, result.expected)
|
26
|
+
}));
|
27
|
+
} else {
|
28
|
+
report(node, new RuleError(result.message, {
|
29
|
+
index: result.index
|
30
|
+
}));
|
31
|
+
}
|
32
|
+
});
|
33
|
+
});
|
34
|
+
}
|
35
|
+
};
|
36
|
+
};
|
37
|
+
|
38
|
+
export default {
|
39
|
+
linter: reporter,
|
40
|
+
fixer: reporter
|
41
|
+
};
|