textlint-ja / textlint-rule-ja-no-redundant-expression

冗長な表現をチェックするtextlintルール
MIT License
27 stars 3 forks source link

辞書の項目ごとにオプションを設定できるようにする #8

Closed azu closed 5 years ago

azu commented 5 years ago

From https://github.com/textlint-ja/textlint-rule-ja-no-redundant-expression/pull/6#issuecomment-449903529

辞書のtokenに対して名前をつけて、オプションを指定できるようにする。 いくつかのtokenに対してはデフォルトで許可リストをもつ。

Example

module.exports = [
    {
        id: "$1を実行",
        message: `"$1を実行"は冗長な表現です。"$1する"など簡潔な表現にすると文章が明瞭になります。`,
        url: "http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html",
        tokens: [
            {
                "pos": "名詞",
                "pos_detail_1": "サ変接続",
                "_capture": "$1"
            },
            {
                "surface_form": "を",
                "pos": "助詞",
                "pos_detail_1": "格助詞",
                "pos_detail_2": "一般",
                "pos_detail_3": "*",
                "conjugated_type": "*",
                "conjugated_form": "*",
                "basic_form": "を",
                "reading": "ヲ",
                "pronunciation": "ヲ"
            },
            {
                "surface_form": "実行",
                "pos": "名詞",
                "pos_detail_1": "サ変接続",
                "pos_detail_2": "*",
                "pos_detail_3": "*",
                "conjugated_type": "*",
                "conjugated_form": "*",
                "basic_form": "実行",
                "reading": "ジッコウ",
                "pronunciation": "ジッコー"
            },
        ]
    }

]

.textlintrc:

{
    "rules": {
        "ja-no-redundant-expression": {
           "dictionary": {
              "$1を行う": {
                "disable": true
              },
              "$1を実行": {
                "allow": ["ソフトウェア"] // 含まれているなら無視
              }
           }
        }
    }
}
azu commented 5 years ago

「実行」は漢字とひらがなだけをデフォルトの対象にすれば、比較的false positiveが減るんじゃないかなと思った。 カタカナと英数字の場合は許可する感じ。

プログラム、テスト

azu commented 5 years ago

15

カタカナと英数字の場合は許可する感じ。

デフォルトのallowsはこれ入れた