Skip to content

Commit

Permalink
fix(dictionary): "処理を{行う,実行}"をデフォルトで許可する
Browse files Browse the repository at this point in the history
  • Loading branch information
azu committed Jan 8, 2019
1 parent b9d6b3f commit 6b1f136
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 20 deletions.
43 changes: 30 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,33 @@

"すること\[助詞]()可能"は冗長な表現です。"すること\[助詞]()可能"を省き簡潔な表現にすると文章が明瞭になります。

- 参考: <http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0>
**参考:**

- <http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0>

### 【dict2】

"すること\[助詞]できる"は冗長な表現です。"すること\[助詞]"を省き簡潔な表現にすると文章が明瞭になります。

- 参考: <http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0>
**参考:**

- <http://qiita.com/takahi-i/items/a93dc2ff42af6b93f6e0>

### 【dict3】

"であると言えます"は冗長な表現です。"である" または "と言えます"を省き簡潔な表現にすると文章が明瞭になります。

- 参考: <http://www.sekaihaasobiba.com/entry/2014/10/24/204024>
**参考:**

- <http://www.sekaihaasobiba.com/entry/2014/10/24/204024>

### 【dict4】

"であると考えている"は冗長な表現です。"である" または "と考えている"を省き簡潔な表現にすると文章が明瞭になります。

- 参考: <http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html>
**参考:**

- <http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html>

### 【dict5】

Expand All @@ -38,9 +46,13 @@

例)「行動(する)」、「プログラム(する)」

誤検知を防ぐためにデフォルトでは、[カタカナ]を行う」と「[アルファベット]を行う」は"allows"で無視するように定義されています
誤検知を防ぐためにデフォルトでは、"allows"オプションに次のパターンが定義されています

- 参考: <http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html>
["/^処理を行[ぁ-ん]/","/^[ァ-ヶ]+を.?行[ぁ-ん]/","/^[a-zA-Z]+を.?行[ぁ-ん]/"]

**参考:**

- <http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html>

### 【dict6】

Expand All @@ -50,9 +62,13 @@

例)「行動(する)」、「プログラム(する)」

誤検知を防ぐためにデフォルトでは、「[カタカナ]を実行」と「[アルファベット]を実行」は"allows"で無視するように定義されています。
誤検知を防ぐためにデフォルトでは、"allows"オプションに次のパターンが定義されています。

["/^処理を実行/","/^[ァ-ヶ]+を.?実行/","/^[a-zA-Z]+を.?実行/"]

**参考:**

- 参考: <http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html>
- <http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html>

## Install

Expand Down Expand Up @@ -91,7 +107,7 @@ Via CLI
- `allows`: `string[]`
- エラーを無視したいパターンを[正規表現ライクな文字列](https://github.com/textlint/regexp-string-matcher)で指定

例) [dict1](#dict1)は無効化、[dict5](#dict5)で"処理を行う"をエラーにしない。
例) [dict1](#dict1)は無効化、[dict5](#dict5)で"議論を行う"をエラーにしない。

```json5
{
Expand All @@ -102,12 +118,13 @@ Via CLI
"disabled": true
},
"dict5": {
// "処理を行う" を許可する
// "議論を行う" を許可する
allows: [
"/^処理を行う/",
"/^議論を行う/",
// デフォルトの許可リストは上書きされるので、維持したい場合は追加する
"/^[ァ-ヶ]+を.?行う/",
"/^[a-zA-Z]+を.?行う/"
"/^処理を行[ぁ-ん]/",
"/^[ァ-ヶ]+を.?行[ぁ-ん]/",
"/^[a-zA-Z]+を.?行[ぁ-ん]/"
]
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,13 +271,12 @@ const Dictionary = [
// https://azu.github.io/morpheme-match/?text=動作の(確認を行わなければ)ならない
id: "dict5",
disabled: false,
allows: ["/^[ァ-ヶ]+を.?行う/", "/^[a-zA-Z]+を.?行う/"],
allows: ["/^処理を行[ぁ-ん]/", "/^[ァ-ヶ]+を.?行[ぁ-ん]/", "/^[a-zA-Z]+を.?行[ぁ-ん]/"],
message: `"$1を$5行う"は冗長な表現です。"$1する"など簡潔な表現にすると文章が明瞭になります。`,
description: `[サ変名詞]とは「[名詞]する」というように「する」が後ろについた場合に、動詞の働きをする名詞です。
例)「行動(する)」、「プログラム(する)」
誤検知を防ぐためにデフォルトでは、「[カタカナ]を行う」と「[アルファベット]を行う」は"allows"で無視するように定義されています。
`,
url: "http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html",
tokens: [
Expand Down Expand Up @@ -317,13 +316,12 @@ const Dictionary = [
{
id: "dict6",
disabled: false,
allows: ["/^[ァ-ヶ]+を.?実行/", "/^[a-zA-Z]+を.?実行/"],
allows: ["/^処理を実行/", "/^[ァ-ヶ]+を.?実行/", "/^[a-zA-Z]+を.?実行/"],
message: `"$1を$5実行"は冗長な表現です。"$1する"など簡潔な表現にすると文章が明瞭になります。`,
description: `[サ変名詞]とは「[名詞]する」というように「する」が後ろについた場合に、動詞の働きをする名詞です。
例)「行動(する)」、「プログラム(する)」
誤検知を防ぐためにデフォルトでは、「[カタカナ]を実行」と「[アルファベット]を実行」は"allows"で無視するように定義されています。
`,
url: "http://www.atmarkit.co.jp/ait/articles/1001/19/news106_2.html",
tokens: [
Expand Down
1 change: 1 addition & 0 deletions test/index-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ tester.run("textlint-rule-ja-no-redundant-expression", rule, {
// デフォルトの例外
"プログラムを実行する",
"テストを行う",
"テストを行っているとき",
{
text: "処理を行う",
options: {
Expand Down
29 changes: 26 additions & 3 deletions tools/update-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,27 @@ const escapeMarkdown = (text) => {
* @param dict
*/
const createDescription = (dict) => {
return dict.description ? `\n\n${dict.description}` : ""
return dict.description ? `\n\n${dict.description}\n\n` : ""
};
/**
* allowsがある場合はその内容を返す
* @param dict
*/
const createAllows = (dict) => {
if(!dict.allows){
return ""
}
if (!Array.isArray(dict.allows)) {
return "";
}
if (dict.allows.length === 0) {
return ""
}
return `
誤検知を防ぐためにデフォルトでは、"allows"オプションに次のパターンが定義されています。
${JSON.stringify(dict.allows)}
`;
};
const replaceWithCaptureTokens = (text, tokens) => {
let resultText = text;
Expand All @@ -40,10 +60,13 @@ const createExamples = dictionaries => {
return (
`### 【${dict.id}
${replaceWithCaptureTokens(dict.message, dict.tokens)}${createDescription(dict)}` +
${replaceWithCaptureTokens(dict.message, dict.tokens)}${createDescription(dict)}${createAllows(dict)}` +
(dict.url
? `
- 参考: ${dict.url}
**参考:**
- ${dict.url}
`
: "")
);
Expand Down

0 comments on commit 6b1f136

Please sign in to comment.