Skip to content

Commit 737b5b4

Browse files
committed
feat: 「〜てる」→「〜ている」のい抜き言葉を検知できるように
1 parent 56aa752 commit 737b5b4

File tree

5 files changed

+2907
-2429
lines changed

5 files changed

+2907
-2429
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
い抜き言葉を検出する[textlint](https://github.com/textlint/textlint "textlint")ルールです。
44

5-
- ◯ 開発しています。
6-
- ✗ 開発してます。
5+
- ◯ 開発しています。 / 開発している。
6+
- ✗ 開発してます。 / 開発してる。
77

88
## Installation
99

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
},
66
"dependencies": {
77
"kuromojin": "^3.0.0",
8-
"textlint-rule-helper": "^2.1.1"
8+
"textlint-rule-helper": "^2.3.1"
99
},
1010
"description": "い抜き言葉を検出するtextlint rule",
1111
"devDependencies": {

src/no-dropping-i.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,22 @@
33
import { RuleHelper } from "textlint-rule-helper";
44
import { tokenize } from "kuromojin";
55

6-
function isTargetWord(token) {
6+
function isMasuTargetWord(token) {
77
return token.pos === "助詞" && token.pos_detail_1 === "接続助詞" && token.basic_form === "て";
88
}
99

1010
function isMasuWord(token) {
1111
return token.pos === "助動詞" && token.pos_detail_1 === "*" && token.basic_form === "ます";
1212
}
1313

14+
function isTeruTargetWord(token){
15+
return token.pos === "動詞" && token.pos_detail_1 === "自立";
16+
}
17+
18+
function isTeruWord(token) {
19+
return token.pos === "動詞" && token.pos_detail_1 === "非自立" && token.basic_form === "てる";
20+
}
21+
1422
module.exports = function(context) {
1523
const helper = new RuleHelper(context);
1624
const { Syntax, report, getSource, RuleError } = context;
@@ -27,7 +35,7 @@ module.exports = function(context) {
2735
if (!prev || !current) {
2836
return;
2937
}
30-
if (isTargetWord(prev) && isMasuWord(current)) {
38+
if ((isMasuTargetWord(prev) && isMasuWord(current)) || (isTeruTargetWord(prev) && isTeruWord(current))) {
3139
report(
3240
node,
3341
new RuleError("い抜き言葉を使用しています。", {

test/test.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import TextLintTester from "textlint-tester";
33

44
const tester = new TextLintTester();
55
tester.run("no-dropping-i", rule, {
6-
valid: ["見ています", "開発しています。"],
6+
valid: ["見ています", "開発しています。", "笑っている。", "見学している。"],
77
invalid: [
88
{
99
text: "見てます。",
@@ -25,10 +25,25 @@ tester.run("no-dropping-i", rule, {
2525
}
2626
]
2727
},
28-
// TODO: support
29-
// {
30-
// text: "人が話してる",
31-
// errors: [{}]
32-
// }
28+
{
29+
text: "笑ってる。",
30+
errors: [
31+
{
32+
message: "い抜き言葉を使用しています。",
33+
line: 1,
34+
column: 3
35+
}
36+
]
37+
},
38+
{
39+
text: "見学してる。",
40+
errors: [
41+
{
42+
message: "い抜き言葉を使用しています。",
43+
line: 1,
44+
column: 4
45+
}
46+
]
47+
}
3348
]
3449
});

0 commit comments

Comments
 (0)