From 5ce9f183424e22918dac9aea9fb350cea983a94e Mon Sep 17 00:00:00 2001 From: Hiroki KIYOHARA Date: Fri, 16 Oct 2020 13:54:21 +0900 Subject: [PATCH 1/2] Added test to detect the case --- test/no-double-joshi-test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/no-double-joshi-test.js b/test/no-double-joshi-test.js index eef0905..8b7e972 100644 --- a/test/no-double-joshi-test.js +++ b/test/no-double-joshi-test.js @@ -31,6 +31,16 @@ tester.run("no-dropping-the-ra", rule, { } ] }, + { + text: "この距離からでも見れる。", + errors: [ + { + message: "ら抜き言葉を使用しています。", + line: 1, + column: 10 + } + ] + }, { text: "来れる", errors: [ From d39ef173c69eea5d959df883e28ccddeebae82f4 Mon Sep 17 00:00:00 2001 From: Hiroki KIYOHARA Date: Fri, 16 Oct 2020 13:54:45 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fixed=20to=20handle=20=E8=A6=8B=E3=82=8C?= =?UTF-8?q?=E3=82=8B=20as=20special=20case=20too?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/no-dropping-the-ra.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/no-dropping-the-ra.js b/src/no-dropping-the-ra.js index 8191a52..2a993cd 100644 --- a/src/no-dropping-the-ra.js +++ b/src/no-dropping-the-ra.js @@ -16,8 +16,10 @@ function isRaWord(token) { return token.pos == "動詞" && token.pos_detail_1 == "接尾" && token.basic_form == "れる"; } -function isKoreru(token) { - return token.pos == "動詞" && token.basic_form == "来れる"; +function isSpecialCases(token) { + // Due to kuromoji.js's behavior, some dropping-ra words will be tokenized as one. + // See also https://github.com/takuyaa/kuromoji.js/issues/28 + return token.pos == "動詞" && (token.basic_form == "来れる" || token.basic_form == "見れる"); } module.exports = function (context) { @@ -31,7 +33,7 @@ module.exports = function (context) { const text = getSource(node); return tokenize(text).then(tokens => { tokens.forEach(token => { - if (isKoreru(token)) { + if (isSpecialCases(token)) { report( node, new RuleError("ら抜き言葉を使用しています。", {