Skip to content

Detect 見れる as special invalid case. #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/no-dropping-the-ra.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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("ら抜き言葉を使用しています。", {
Expand Down
10 changes: 10 additions & 0 deletions test/no-double-joshi-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@ tester.run("no-dropping-the-ra", rule, {
}
]
},
{
text: "この距離からでも見れる。",
errors: [
{
message: "ら抜き言葉を使用しています。",
line: 1,
column: 10
}
]
},
{
text: "来れる",
errors: [
Expand Down