@doujinreviewers/textlint-rule-for-creation 0.0.1 → 0.0.2
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/README.md +4 -4
- package/lib/dict/arrow.js +6 -0
- package/lib/dict/arrow.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/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/enhanced-engine.js +57 -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 +40 -15
- package/lib/textlint-rule-for-creation.js.map +1 -1
- package/package.json +3 -1
- package/src/dict/arrow.js +6 -0
- package/src/dict/miss.js +32 -0
- package/src/dict/retasu.js +16 -0
- package/src/enhanced-engine.js +37 -0
- package/src/textlint-rule-for-creation.js +38 -29
- package/src/dict/dict.js +0 -55
- package/src/dict/dict2.js +0 -32
package/README.md
CHANGED
@@ -13,13 +13,13 @@
|
|
13
13
|
|
14
14
|
例えば、文章の形式、スタイル、文体、文の冗長さ、二重否定、二重助詞、表記ゆれ、送り仮名のゆれ、記号や三点リーダーの使い方など
|
15
15
|
|
16
|
-
-
|
16
|
+
- ら抜き言葉、い抜き言葉
|
17
17
|
|
18
18
|
これで喋るキャラがいるかもしれないし、作品の雰囲気に必要かもしれない
|
19
19
|
|
20
20
|
## インストール
|
21
21
|
|
22
|
-
npm install textlint-rule-for-creation
|
22
|
+
npm install @doujinreviewers/textlint-rule-for-creation
|
23
23
|
|
24
24
|
## 使い方
|
25
25
|
|
@@ -28,7 +28,7 @@
|
|
28
28
|
```json
|
29
29
|
{
|
30
30
|
"rules": {
|
31
|
-
"for-creation": true
|
31
|
+
"@doujinreviewers/textlint-rule-for-creation": true
|
32
32
|
}
|
33
33
|
}
|
34
34
|
```
|
@@ -36,7 +36,7 @@
|
|
36
36
|
コマンドラインで使う
|
37
37
|
|
38
38
|
```
|
39
|
-
textlint --rule for-creation README.md
|
39
|
+
textlint --rule @doujinreviewers/textlint-rule-for-creation README.md
|
40
40
|
```
|
41
41
|
|
42
42
|
### Build
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/arrow.js"],"names":["module","exports"],"mappings":";;AAAAA,MAAM,CAACC,OAAP,GAAiB;AACf,qBAAmB,CACjB,IADiB,EAEjB,IAFiB;AADJ,CAAjB","sourcesContent":["module.exports = {\n \"jidousi_tadousi\": [\n \"開け\",\n \"あけ\",\n ]\n};"],"file":"arrow.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=dictAA.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/dictAA.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":"dictAA.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=dict_miss.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/dict_miss.js"],"names":["module","exports"],"mappings":";;AAAAA,MAAM,CAACC,OAAP,GAAiB,CACf;AACE,aAAW,+BADb;AAEE,cAAY,KAFd;AAGE,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;AAHZ,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":"dict_miss.js"}
|
package/lib/dict/miss.js
ADDED
@@ -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=miss.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/miss.js"],"names":["module","exports"],"mappings":";;AAAAA,MAAM,CAACC,OAAP,GAAiB,CACf;AACE,aAAW,+BADb;AAEE,cAAY,KAFd;AAGE,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;AAHZ,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":"miss.js"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../../src/dict/retasu.js"],"names":["module","exports"],"mappings":";;AAAAA,MAAM,CAACC,OAAP,GAAiB,CACf;AACE,aAAW,gBADb;AAEE,YAAU,CACR;AACE,WAAO,IADT;AAEE,uBAAmB;AAFrB,GADQ,EAKR;AACE,WAAO,IADT;AAEE,oBAAgB,IAFlB;AAGE,kBAAc;AAHhB,GALQ;AAFZ,CADe,CAAjB","sourcesContent":["module.exports = [\n {\n \"message\": \"れ足す言葉の可能性があります\",\n \"tokens\": [\n {\n \"pos\": \"動詞\",\n \"conjugated_type\": \"一段\",\n },\n {\n \"pos\": \"動詞\",\n \"pos_detail_1\": \"接尾\",\n \"basic_form\": \"れる\",\n }\n ]\n },\n];"],"file":"retasu.js"}
|
@@ -0,0 +1,57 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
9
|
+
|
10
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
11
|
+
|
12
|
+
var Romanizer = require('js-hira-kata-romanize');
|
13
|
+
|
14
|
+
var romajiConv = require('@koozaki/romaji-conv');
|
15
|
+
|
16
|
+
var arrow = require('./dict/arrow');
|
17
|
+
|
18
|
+
class EnhancedEngine {
|
19
|
+
constructor() {
|
20
|
+
this.romanizer = new Romanizer({
|
21
|
+
mapping: Romanizer.MAPPING_KUNREI,
|
22
|
+
chouon: Romanizer.CHOUON_CIRCUMFLEX,
|
23
|
+
upper: Romanizer.UPPER_NONE
|
24
|
+
});
|
25
|
+
}
|
26
|
+
|
27
|
+
romanize(hiraganaOrKatakana) {
|
28
|
+
return this.romanizer.romanize(hiraganaOrKatakana);
|
29
|
+
}
|
30
|
+
|
31
|
+
checkRetasu(tokenizer, text) {
|
32
|
+
return _asyncToGenerator(function* () {
|
33
|
+
if (/れ$/.test(text)) {
|
34
|
+
text += "る";
|
35
|
+
}
|
36
|
+
|
37
|
+
var tokens = yield tokenizer(text);
|
38
|
+
var meirei = yield tokenizer(tokens[0].surface_form + "。");
|
39
|
+
|
40
|
+
if (meirei[0].conjugated_form == "命令e" || /五段/.test(meirei[0].conjugated_type)) {
|
41
|
+
// 「れる」を抜いても命令形で意味が通じるか、最初の文字が五段活用動詞になると多分れ足す言葉
|
42
|
+
if (!arrow.jidousi_tadousi.includes(meirei[0].surface_form)) {
|
43
|
+
// 許可リストにもない
|
44
|
+
return true;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
return false;
|
49
|
+
})();
|
50
|
+
}
|
51
|
+
|
52
|
+
}
|
53
|
+
|
54
|
+
var _default = new EnhancedEngine();
|
55
|
+
|
56
|
+
exports.default = _default;
|
57
|
+
//# sourceMappingURL=enhanced-engine.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/enhanced-engine.js"],"names":["Romanizer","require","romajiConv","arrow","EnhancedEngine","constructor","romanizer","mapping","MAPPING_KUNREI","chouon","CHOUON_CIRCUMFLEX","upper","UPPER_NONE","romanize","hiraganaOrKatakana","checkRetasu","tokenizer","text","test","tokens","meirei","surface_form","conjugated_form","conjugated_type","jidousi_tadousi","includes"],"mappings":";;;;;;;;;;;AAAA,IAAMA,SAAS,GAAGC,OAAO,CAAC,uBAAD,CAAzB;;AACA,IAAMC,UAAU,GAAGD,OAAO,CAAC,sBAAD,CAA1B;;AACA,IAAME,KAAK,GAAGF,OAAO,CAAC,cAAD,CAArB;;AAEA,MAAMG,cAAN,CAAqB;AAEnBC,EAAAA,WAAW,GAAG;AACZ,SAAKC,SAAL,GAAiB,IAAIN,SAAJ,CAAc;AAC7BO,MAAAA,OAAO,EAAEP,SAAS,CAACQ,cADU;AAE7BC,MAAAA,MAAM,EAAET,SAAS,CAACU,iBAFW;AAG7BC,MAAAA,KAAK,EAAEX,SAAS,CAACY;AAHY,KAAd,CAAjB;AAKD;;AAEDC,EAAAA,QAAQ,CAACC,kBAAD,EAAoB;AAC1B,WAAO,KAAKR,SAAL,CAAeO,QAAf,CAAwBC,kBAAxB,CAAP;AACD;;AAEKC,EAAAA,WAAW,CAACC,SAAD,EAAYC,IAAZ,EAAiB;AAAA;AAChC,UAAG,KAAKC,IAAL,CAAUD,IAAV,CAAH,EAAmB;AACjBA,QAAAA,IAAI,IAAI,GAAR;AACD;;AACD,UAAIE,MAAM,SAASH,SAAS,CAACC,IAAD,CAA5B;AACA,UAAIG,MAAM,SAASJ,SAAS,CAACG,MAAM,CAAC,CAAD,CAAN,CAAUE,YAAV,GAAyB,GAA1B,CAA5B;;AACA,UAAGD,MAAM,CAAC,CAAD,CAAN,CAAUE,eAAV,IAA6B,KAA7B,IAAsC,KAAKJ,IAAL,CAAUE,MAAM,CAAC,CAAD,CAAN,CAAUG,eAApB,CAAzC,EAA8E;AAC5E;AACA,YAAG,CAACpB,KAAK,CAACqB,eAAN,CAAsBC,QAAtB,CAA+BL,MAAM,CAAC,CAAD,CAAN,CAAUC,YAAzC,CAAJ,EAA2D;AACzD;AACA,iBAAO,IAAP;AACD;AACF;;AACD,aAAO,KAAP;AAbgC;AAcjC;;AA5BkB;;eAgCN,IAAIjB,cAAJ,E","sourcesContent":["const Romanizer = require('js-hira-kata-romanize');\nconst romajiConv = require('@koozaki/romaji-conv');\nconst arrow = require('./dict/arrow');\n\nclass EnhancedEngine {\n\n constructor() {\n this.romanizer = new Romanizer({\n mapping: Romanizer.MAPPING_KUNREI,\n chouon: Romanizer.CHOUON_CIRCUMFLEX,\n upper: Romanizer.UPPER_NONE\n });\n }\n\n romanize(hiraganaOrKatakana){\n return this.romanizer.romanize(hiraganaOrKatakana);\n }\n\n async checkRetasu(tokenizer, text){\n if(/れ$/.test(text)){\n text += \"る\";\n }\n let tokens = await tokenizer(text);\n let meirei = await tokenizer(tokens[0].surface_form + \"。\");\n if(meirei[0].conjugated_form == \"命令e\" || /五段/.test(meirei[0].conjugated_type)){\n // 「れる」を抜いても命令形で意味が通じるか、最初の文字が五段活用動詞になると多分れ足す言葉\n if(!arrow.jidousi_tadousi.includes(meirei[0].surface_form)){\n // 許可リストにもない\n return true;\n }\n }\n return false;\n }\n\n}\n\nexport default new EnhancedEngine();"],"file":"enhanced-engine.js"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.default = void 0;
|
7
|
+
|
8
|
+
var Romanizer = require('js-hira-kata-romanize');
|
9
|
+
|
10
|
+
class ModifiedEngine {
|
11
|
+
constructor() {
|
12
|
+
this.romanizer = new Romanizer({
|
13
|
+
chouon: Romanizer.CHOUON_CIRCUMFLEX,
|
14
|
+
upper: Romanizer.UPPER_NONE
|
15
|
+
});
|
16
|
+
}
|
17
|
+
|
18
|
+
romanize(hiraganaOrKatakana) {
|
19
|
+
return this.romanizer.romanize(hiraganaOrKatakana);
|
20
|
+
}
|
21
|
+
|
22
|
+
}
|
23
|
+
|
24
|
+
var _default = new ModifiedEngine();
|
25
|
+
|
26
|
+
exports.default = _default;
|
27
|
+
//# sourceMappingURL=modified-engine.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"sources":["../src/modified-engine.js"],"names":["Romanizer","require","ModifiedEngine","constructor","romanizer","chouon","CHOUON_CIRCUMFLEX","upper","UPPER_NONE","romanize","hiraganaOrKatakana"],"mappings":";;;;;;;AAAA,IAAMA,SAAS,GAAGC,OAAO,CAAC,uBAAD,CAAzB;;AAEA,MAAMC,cAAN,CAAqB;AAEnBC,EAAAA,WAAW,GAAG;AACZ,SAAKC,SAAL,GAAiB,IAAIJ,SAAJ,CAAc;AAC7BK,MAAAA,MAAM,EAAEL,SAAS,CAACM,iBADW;AAE7BC,MAAAA,KAAK,EAAEP,SAAS,CAACQ;AAFY,KAAd,CAAjB;AAID;;AAEDC,EAAAA,QAAQ,CAACC,kBAAD,EAAoB;AAC1B,WAAO,KAAKN,SAAL,CAAeK,QAAf,CAAwBC,kBAAxB,CAAP;AACD;;AAXkB;;eAcN,IAAIR,cAAJ,E","sourcesContent":["const Romanizer = require('js-hira-kata-romanize');\n\nclass ModifiedEngine {\n\n constructor() {\n this.romanizer = new Romanizer({\n chouon: Romanizer.CHOUON_CIRCUMFLEX,\n upper: Romanizer.UPPER_NONE\n });\n }\n\n romanize(hiraganaOrKatakana){\n return this.romanizer.romanize(hiraganaOrKatakana);\n }\n}\n\nexport default new ModifiedEngine();"],"file":"modified-engine.js"}
|
@@ -9,11 +9,19 @@ var _morphemeMatchTextlint = require("morpheme-match-textlint");
|
|
9
9
|
|
10
10
|
var _kuromojin = require("kuromojin");
|
11
11
|
|
12
|
+
var _enhancedEngine = _interopRequireDefault(require("./enhanced-engine"));
|
13
|
+
|
14
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
15
|
+
|
16
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
17
|
+
|
18
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
19
|
+
|
12
20
|
var loadDictionaries = () => {
|
13
21
|
// unavoidable
|
14
|
-
var dict1 = require('./dict/
|
22
|
+
var dict1 = require('./dict/retasu');
|
15
23
|
|
16
|
-
var dict2 = require('./dict/
|
24
|
+
var dict2 = require('./dict/miss');
|
17
25
|
|
18
26
|
return dict1.concat(dict2);
|
19
27
|
};
|
@@ -30,23 +38,40 @@ var reporter = context => {
|
|
30
38
|
tokenize: _kuromojin.tokenize,
|
31
39
|
dictionaries: loadDictionaries()
|
32
40
|
});
|
41
|
+
var engine = _enhancedEngine.default;
|
33
42
|
return {
|
34
43
|
[Syntax.Str](node) {
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
44
|
+
return new Promise( /*#__PURE__*/function () {
|
45
|
+
var _ref = _asyncToGenerator(function* (resolve, reject) {
|
46
|
+
var text = getSource(node);
|
47
|
+
var results = yield matchAll(text);
|
48
|
+
|
49
|
+
for (var result of results) {
|
50
|
+
if (result.message == "れ足す言葉の可能性があります") {
|
51
|
+
if (!(yield engine.checkRetasu(_kuromojin.tokenize, text.slice(result.range[0], result.range[1])))) {
|
52
|
+
continue;
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
if (result.expected) {
|
57
|
+
report(node, new RuleError(result.message, {
|
58
|
+
index: result.index,
|
59
|
+
fix: fixer.replaceTextRange(result.range, result.expected)
|
60
|
+
}));
|
61
|
+
} else {
|
62
|
+
report(node, new RuleError(result.message, {
|
63
|
+
index: result.index
|
64
|
+
}));
|
65
|
+
}
|
47
66
|
}
|
67
|
+
|
68
|
+
resolve();
|
48
69
|
});
|
49
|
-
|
70
|
+
|
71
|
+
return function (_x, _x2) {
|
72
|
+
return _ref.apply(this, arguments);
|
73
|
+
};
|
74
|
+
}());
|
50
75
|
}
|
51
76
|
|
52
77
|
};
|
@@ -1 +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","
|
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","engine","EnhancedEngine","Str","node","Promise","resolve","reject","text","results","result","message","checkRetasu","slice","range","expected","index","fix","replaceTextRange","linter"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;AAEA,IAAMA,gBAAgB,GAAG,MAAM;AAC7B;AACA,MAAIC,KAAK,GAAGC,OAAO,CAAC,eAAD,CAAnB;;AACA,MAAIC,KAAK,GAAGD,OAAO,CAAC,aAAD,CAAnB;;AACA,SAAOD,KAAK,CAACG,MAAN,CAAaD,KAAb,CAAP;AACD,CALD;;AAOA,IAAME,QAAQ,GAAIC,OAAD,IAAa;AAC5B,MAAM;AAAEC,IAAAA,MAAF;AAAUC,IAAAA,SAAV;AAAqBC,IAAAA,KAArB;AAA4BC,IAAAA,MAA5B;AAAoCC,IAAAA;AAApC,MAAkDL,OAAxD;AACA,MAAMM,QAAQ,GAAG,kDAAsB;AACrCC,IAAAA,QAAQ,EAAEA,mBAD2B;AAErCC,IAAAA,YAAY,EAAEd,gBAAgB;AAFO,GAAtB,CAAjB;AAIA,MAAMe,MAAM,GAAGC,uBAAf;AACA,SAAO;AACL,KAACT,MAAM,CAACU,GAAR,EAAaC,IAAb,EAAmB;AACjB,aAAO,IAAIC,OAAJ;AAAA,qCAAY,WAAOC,OAAP,EAAgBC,MAAhB,EAA2B;AAC5C,cAAMC,IAAI,GAAGX,SAAS,CAACO,IAAD,CAAtB;AACA,cAAIK,OAAO,SAASX,QAAQ,CAACU,IAAD,CAA5B;;AACA,eAAK,IAAME,MAAX,IAAqBD,OAArB,EAA8B;AAC5B,gBAAGC,MAAM,CAACC,OAAP,IAAkB,gBAArB,EAAsC;AACpC,kBAAG,QAAQV,MAAM,CAACW,WAAP,CAAmBb,mBAAnB,EAA6BS,IAAI,CAACK,KAAL,CAAWH,MAAM,CAACI,KAAP,CAAa,CAAb,CAAX,EAA2BJ,MAAM,CAACI,KAAP,CAAa,CAAb,CAA3B,CAA7B,CAAR,CAAH,EAAsF;AACpF;AACD;AACF;;AACD,gBAAIJ,MAAM,CAACK,QAAX,EAAqB;AACnBnB,cAAAA,MAAM,CAACQ,IAAD,EAAO,IAAIV,SAAJ,CAAcgB,MAAM,CAACC,OAArB,EAA8B;AACzCK,gBAAAA,KAAK,EAAEN,MAAM,CAACM,KAD2B;AAEzCC,gBAAAA,GAAG,EAAEtB,KAAK,CAACuB,gBAAN,CAAuBR,MAAM,CAACI,KAA9B,EAAqCJ,MAAM,CAACK,QAA5C;AAFoC,eAA9B,CAAP,CAAN;AAID,aALD,MAKO;AACLnB,cAAAA,MAAM,CAACQ,IAAD,EAAO,IAAIV,SAAJ,CAAcgB,MAAM,CAACC,OAArB,EAA8B;AACzCK,gBAAAA,KAAK,EAAEN,MAAM,CAACM;AAD2B,eAA9B,CAAP,CAAN;AAGD;AACF;;AACDV,UAAAA,OAAO;AACR,SArBM;;AAAA;AAAA;AAAA;AAAA,UAAP;AAsBD;;AAxBI,GAAP;AA0BD,CAjCD;;eAmCe;AACba,EAAAA,MAAM,EAAE5B,QADK;AAEbI,EAAAA,KAAK,EAAEJ;AAFM,C","sourcesContent":["import { createTextlintMatcher } from \"morpheme-match-textlint\";\nimport { tokenize } from \"kuromojin\";\nimport EnhancedEngine from \"./enhanced-engine\";\n\nconst loadDictionaries = () => {\n // unavoidable\n let dict1 = require('./dict/retasu');\n let dict2 = require('./dict/miss');\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 const engine = EnhancedEngine\n return {\n [Syntax.Str](node) {\n return new Promise(async (resolve, reject) => {\n const text = getSource(node);\n let results = await matchAll(text);\n for (const result of results) {\n if(result.message == \"れ足す言葉の可能性があります\"){\n if(!(await engine.checkRetasu(tokenize, text.slice(result.range[0],result.range[1])))){\n continue;\n }\n }\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 resolve();\n });\n }\n };\n};\n\nexport default {\n linter: reporter,\n fixer: reporter\n};"],"file":"textlint-rule-for-creation.js"}
|
package/package.json
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
{
|
2
|
-
"version": "0.0.
|
2
|
+
"version": "0.0.2",
|
3
3
|
"keywords": [
|
4
4
|
"textlintrule"
|
5
5
|
],
|
@@ -33,6 +33,8 @@
|
|
33
33
|
"access": "public"
|
34
34
|
},
|
35
35
|
"dependencies": {
|
36
|
+
"@koozaki/romaji-conv": "^2.0.16",
|
37
|
+
"js-hira-kata-romanize": "^1.0.5",
|
36
38
|
"kuromojin": "^3.0.0",
|
37
39
|
"morpheme-match-textlint": "^2.0.6"
|
38
40
|
}
|
package/src/dict/miss.js
ADDED
@@ -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,37 @@
|
|
1
|
+
const Romanizer = require('js-hira-kata-romanize');
|
2
|
+
const romajiConv = require('@koozaki/romaji-conv');
|
3
|
+
const arrow = require('./dict/arrow');
|
4
|
+
|
5
|
+
class EnhancedEngine {
|
6
|
+
|
7
|
+
constructor() {
|
8
|
+
this.romanizer = new Romanizer({
|
9
|
+
mapping: Romanizer.MAPPING_KUNREI,
|
10
|
+
chouon: Romanizer.CHOUON_CIRCUMFLEX,
|
11
|
+
upper: Romanizer.UPPER_NONE
|
12
|
+
});
|
13
|
+
}
|
14
|
+
|
15
|
+
romanize(hiraganaOrKatakana){
|
16
|
+
return this.romanizer.romanize(hiraganaOrKatakana);
|
17
|
+
}
|
18
|
+
|
19
|
+
async checkRetasu(tokenizer, text){
|
20
|
+
if(/れ$/.test(text)){
|
21
|
+
text += "る";
|
22
|
+
}
|
23
|
+
let tokens = await tokenizer(text);
|
24
|
+
let meirei = await tokenizer(tokens[0].surface_form + "。");
|
25
|
+
if(meirei[0].conjugated_form == "命令e" || /五段/.test(meirei[0].conjugated_type)){
|
26
|
+
// 「れる」を抜いても命令形で意味が通じるか、最初の文字が五段活用動詞になると多分れ足す言葉
|
27
|
+
if(!arrow.jidousi_tadousi.includes(meirei[0].surface_form)){
|
28
|
+
// 許可リストにもない
|
29
|
+
return true;
|
30
|
+
}
|
31
|
+
}
|
32
|
+
return false;
|
33
|
+
}
|
34
|
+
|
35
|
+
}
|
36
|
+
|
37
|
+
export default new EnhancedEngine();
|
@@ -1,41 +1,50 @@
|
|
1
1
|
import { createTextlintMatcher } from "morpheme-match-textlint";
|
2
2
|
import { tokenize } from "kuromojin";
|
3
|
+
import EnhancedEngine from "./enhanced-engine";
|
3
4
|
|
4
5
|
const loadDictionaries = () => {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
// unavoidable
|
7
|
+
let dict1 = require('./dict/retasu');
|
8
|
+
let dict2 = require('./dict/miss');
|
9
|
+
return dict1.concat(dict2)
|
9
10
|
}
|
10
11
|
|
11
12
|
const reporter = (context) => {
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
});
|
13
|
+
const { Syntax, RuleError, fixer, report, getSource } = context;
|
14
|
+
const matchAll = createTextlintMatcher({
|
15
|
+
tokenize: tokenize,
|
16
|
+
dictionaries: loadDictionaries()
|
17
|
+
});
|
18
|
+
const engine = EnhancedEngine
|
19
|
+
return {
|
20
|
+
[Syntax.Str](node) {
|
21
|
+
return new Promise(async (resolve, reject) => {
|
22
|
+
const text = getSource(node);
|
23
|
+
let results = await matchAll(text);
|
24
|
+
for (const result of results) {
|
25
|
+
if(result.message == "れ足す言葉の可能性があります"){
|
26
|
+
if(!(await engine.checkRetasu(tokenize, text.slice(result.range[0],result.range[1])))){
|
27
|
+
continue;
|
28
|
+
}
|
29
|
+
}
|
30
|
+
if (result.expected) {
|
31
|
+
report(node, new RuleError(result.message, {
|
32
|
+
index: result.index,
|
33
|
+
fix: fixer.replaceTextRange(result.range, result.expected)
|
34
|
+
}));
|
35
|
+
} else {
|
36
|
+
report(node, new RuleError(result.message, {
|
37
|
+
index: result.index
|
38
|
+
}));
|
39
|
+
}
|
34
40
|
}
|
35
|
-
|
41
|
+
resolve();
|
42
|
+
});
|
43
|
+
}
|
44
|
+
};
|
36
45
|
};
|
37
46
|
|
38
47
|
export default {
|
39
|
-
|
40
|
-
|
48
|
+
linter: reporter,
|
49
|
+
fixer: reporter
|
41
50
|
};
|
package/src/dict/dict.js
DELETED
@@ -1,55 +0,0 @@
|
|
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
|
-
];
|
package/src/dict/dict2.js
DELETED
@@ -1,32 +0,0 @@
|
|
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
|
-
];
|