├── .eslintrc.yml ├── .gitignore ├── README.md ├── dict └── fukushi.yml ├── package-lock.json ├── package.json ├── src └── index.js └── test ├── fukushi.test.yml └── index-test.js /.eslintrc.yml: -------------------------------------------------------------------------------- 1 | env: 2 | node: true 3 | es6: true 4 | extends: 'eslint:recommended' 5 | rules: 6 | indent: 7 | - error 8 | - 2 9 | linebreak-style: 10 | - error 11 | - unix 12 | quotes: 13 | - error 14 | - double 15 | semi: 16 | - error 17 | - always 18 | prefer-const: 19 | - error 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ### https://raw.github.com/github/gitignore/608690d6b9a78c2a003affc792e49a84905b3118/Node.gitignore 2 | 3 | # Logs 4 | logs 5 | *.log 6 | 7 | # Runtime data 8 | pids 9 | *.pid 10 | *.seed 11 | 12 | # Directory for instrumented libs generated by jscoverage/JSCover 13 | lib-cov 14 | 15 | # Coverage directory used by tools like istanbul 16 | coverage 17 | 18 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 19 | .grunt 20 | 21 | # node-waf configuration 22 | .lock-wscript 23 | 24 | # Compiled binary addons (http://nodejs.org/api/addons.html) 25 | build/Release 26 | 27 | # Dependency directory 28 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- 29 | node_modules 30 | 31 | # Debug log from npm 32 | npm-debug.log 33 | 34 | # Publish src/ instead lib/ 35 | /lib 36 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # textlint-rule-ja-hiragana-fukushi 2 | 3 | Check easy-to-read Fukushi(adverbs) written in Hiragana than Kanji. 4 | 5 | 漢字よりもひらがなで表記したほうが読みやすい副詞を指摘します。検出には形態素解析を使っています。自動修正にも対応しています。 6 | 7 | ## Install 8 | 9 | Install with [npm](https://www.npmjs.com/): 10 | 11 | npm install textlint-rule-ja-hiragana-fukushi 12 | 13 | ## Usage 14 | 15 | Via `.textlintrc`(Recommended) 16 | 17 | ```json 18 | { 19 | "rules": { 20 | "ja-hiragana-fukushi": true 21 | } 22 | } 23 | ``` 24 | 25 | Or you can specify custom dictionary as follows: 26 | 27 | ```json 28 | { 29 | "rules": { 30 | "ja-hiragana-fukushi": { 31 | "rulePath": "path/to/fukushi.yml" 32 | } 33 | } 34 | } 35 | ``` 36 | 37 | Via CLI 38 | 39 | ``` 40 | textlint --rule ja-hiragana-fukushi README.md 41 | ``` 42 | 43 | ### Fixable 44 | 45 | ``` 46 | textlint --fix ja-hiragana-fukushi README.md 47 | ``` 48 | 49 | ### Build 50 | 51 | Builds source codes for publish to the `lib` folder. 52 | You can write ES2015+ source codes in `src/` folder. 53 | 54 | npm run build 55 | 56 | ### Tests 57 | 58 | Run test code in `test` folder. 59 | Test textlint rule by [textlint-tester](https://github.com/textlint/textlint-tester "textlint-tester"). 60 | 61 | npm test 62 | 63 | 64 | ### List 65 | 66 | | from | to | 67 | | --- | --- | 68 | | 生憎 | あいにく | 69 | | 敢えて | あえて | 70 | | 飽くまで | あくまで | 71 | | 飽く迄 | あくまで | 72 | | 一旦 | いったん | 73 | | 薄々 | うすうす | 74 | | 予め | あらかじめ | 75 | | 粗方 | あらかた | 76 | | 改めて | あらためて | 77 | | 如何に | いかに | 78 | | 如何にも | いかにも | 79 | | 徒に | いたずらに | 80 | | いち早く | いちはやく | 81 | | 未だに | いまだに | 82 | | 苟も | いやしくも | 83 | | 言わば | いわば | 84 | | 薄々 | うすうす | 85 | | 概ね | おおむね | 86 | | 押し並べて | おしなべて | 87 | | 押しなべて | おしなべて | 88 | | 自ずから | おのずから | 89 | | 自ずと | おのずと | 90 | | 凡そ | およそ | 91 | | 却って | かえって | 92 | | 且つ | かつ | 93 | | 嘗て | かつて | 94 | | 予て | かねて | 95 | | 悉く | ことごとく | 96 | | 尽く | ことごとく | 97 | | 細々 | こまごま | 98 | | 更に | さらに | 99 | | 頻りに | しきりに | 100 | | 暫く | しばらく | 101 | | 所詮 | しょせん | 102 | | 頗る | すこぶる | 103 | | 既に | すでに | 104 | | 精一杯 | せいいっぱい | 105 | | 折角 | せっかく | 106 | | 是非 | ぜひ | 107 | | 是非とも | ぜひとも | 108 | | 沢山 | たくさん | 109 | | 立ち所に | たちどころに | 110 | | 仮令 | たとえ | 111 | | 縦令 | たとえ | 112 | | 丁度 | ちょうど | 113 | | 篤と | とくと | 114 | | 土台 | どだい | 115 | | 取り分け | とりわけ | 116 | | 何故 | なぜ | 117 | | 偏に | ひとえに | 118 | | 一際 | ひときわ | 119 | | 一入 | ひとしお | 120 | | 一先ず | ひとまず | 121 | | 独りでに | ひとりでに | 122 | | 殆ど | ほとんど | 123 | | 正しく | まさしく | 124 | | 正に | まさに | 125 | | 況して | まして | 126 | | 先ず | まず | 127 | | 丸で | まるで | 128 | | 満更 | まんざら | 129 | | 無碍に | むげに | 130 | | 寧ろ | むしろ | 131 | | 無理矢理 | 無理やり | 132 | | 滅法 | めっぽう | 133 | | 若しも | もしも | 134 | | 若しくは | もしくは | 135 | | 勿論 | もちろん | 136 | | 最も | もっとも | 137 | | 元々 | もともと | 138 | | 素より | もとより | 139 | | 最早 | もはや | 140 | | 矢張り | やはり | 141 | | 矢っ張り | やっぱり | 142 | | 漸く | ようやく | 143 | | 余程 | よほど | 144 | | 僅かに | わずかに | 145 | 146 | ## License 147 | 148 | MIT © Hiroshi Takase 149 | -------------------------------------------------------------------------------- /dict/fukushi.yml: -------------------------------------------------------------------------------- 1 | message: ひらがなで表記したほうが読みやすい副詞 2 | dict: 3 | - 4 | expected: あいにく 5 | extensions: {} 6 | tokens: 7 | - 8 | surface_form: "生憎" 9 | pos: "副詞" 10 | pos_detail_1: "一般" 11 | pos_detail_2: "*" 12 | pos_detail_3: "*" 13 | conjugated_type: "*" 14 | conjugated_form: "*" 15 | basic_form: "生憎" 16 | reading: "アイニク" 17 | pronunciation: "アイニク" 18 | - 19 | expected: あえて 20 | extensions: {} 21 | tokens: 22 | - 23 | surface_form: "敢えて" 24 | pos: "副詞" 25 | pos_detail_1: "一般" 26 | pos_detail_2: "*" 27 | pos_detail_3: "*" 28 | conjugated_type: "*" 29 | conjugated_form: "*" 30 | basic_form: "敢えて" 31 | reading: "アエテ" 32 | pronunciation: "アエテ" 33 | - 34 | expected: あくまで 35 | extensions: {} 36 | tokens: 37 | - 38 | surface_form: "飽くまで" 39 | pos: "副詞" 40 | pos_detail_1: "一般" 41 | pos_detail_2: "*" 42 | pos_detail_3: "*" 43 | conjugated_type: "*" 44 | conjugated_form: "*" 45 | basic_form: "飽くまで" 46 | reading: "アクマデ" 47 | pronunciation: "アクマデ" 48 | - 49 | expected: あくまで 50 | extensions: {} 51 | tokens: 52 | - 53 | surface_form: "飽く迄" 54 | pos: "副詞" 55 | pos_detail_1: "一般" 56 | pos_detail_2: "*" 57 | pos_detail_3: "*" 58 | conjugated_type: "*" 59 | conjugated_form: "*" 60 | basic_form: "飽く迄" 61 | reading: "アクマデ" 62 | pronunciation: "アクマデ" 63 | - 64 | expected: いったん 65 | tokens: 66 | - 67 | surface_form: "一旦" 68 | pos: "副詞" 69 | - 70 | expected: うすうす 71 | extensions: {} 72 | tokens: 73 | - 74 | surface_form: "薄々" 75 | pos: "副詞" 76 | pos_detail_1: "一般" 77 | pos_detail_2: "*" 78 | pos_detail_3: "*" 79 | conjugated_type: "*" 80 | conjugated_form: "*" 81 | basic_form: "薄々" 82 | reading: "ウスウス" 83 | pronunciation: "ウスウス" 84 | - 85 | expected: あらかじめ 86 | extensions: {} 87 | tokens: 88 | - 89 | surface_form: "予め" 90 | pos: "副詞" 91 | pos_detail_1: "一般" 92 | pos_detail_2: "*" 93 | pos_detail_3: "*" 94 | conjugated_type: "*" 95 | conjugated_form: "*" 96 | basic_form: "予め" 97 | reading: "アラカジメ" 98 | pronunciation: "アラカジメ" 99 | - 100 | expected: あらかた 101 | extensions: {} 102 | tokens: 103 | - 104 | surface_form: "粗方" 105 | pos: "名詞" 106 | pos_detail_1: "一般" 107 | pos_detail_2: "*" 108 | pos_detail_3: "*" 109 | conjugated_type: "*" 110 | conjugated_form: "*" 111 | basic_form: "粗方" 112 | reading: "アラカタ" 113 | pronunciation: "アラカタ" 114 | - 115 | expected: あらためて 116 | extensions: {} 117 | tokens: 118 | - 119 | surface_form: "改めて" 120 | pos: "副詞" 121 | pos_detail_1: "一般" 122 | pos_detail_2: "*" 123 | pos_detail_3: "*" 124 | conjugated_type: "*" 125 | conjugated_form: "*" 126 | basic_form: "改めて" 127 | reading: "アラタメテ" 128 | pronunciation: "アラタメテ" 129 | - 130 | expected: いかに 131 | extensions: {} 132 | tokens: 133 | - 134 | surface_form: "如何に" 135 | pos: "副詞" 136 | pos_detail_1: "一般" 137 | pos_detail_2: "*" 138 | pos_detail_3: "*" 139 | conjugated_type: "*" 140 | conjugated_form: "*" 141 | basic_form: "如何に" 142 | reading: "イカニ" 143 | pronunciation: "イカニ" 144 | - 145 | expected: いかにも 146 | extensions: {} 147 | tokens: 148 | - 149 | surface_form: "如何にも" 150 | pos: "副詞" 151 | pos_detail_1: "一般" 152 | pos_detail_2: "*" 153 | pos_detail_3: "*" 154 | conjugated_type: "*" 155 | conjugated_form: "*" 156 | basic_form: "如何にも" 157 | reading: "イカニモ" 158 | pronunciation: "イカニモ" 159 | - 160 | expected: いたずらに 161 | tokens: 162 | - 163 | surface_form: "徒に" 164 | pos: "副詞" 165 | pos_detail_1: "一般" 166 | pos_detail_2: "*" 167 | pos_detail_3: "*" 168 | conjugated_type: "*" 169 | conjugated_form: "*" 170 | basic_form: "徒に" 171 | reading: "イタズラニ" 172 | pronunciation: "イタズラニ" 173 | - 174 | expected: いちはやく 175 | extensions: {} 176 | tokens: 177 | - 178 | surface_form: "いち早く" 179 | pos: "形容詞" 180 | pos_detail_1: "自立" 181 | pos_detail_2: "*" 182 | pos_detail_3: "*" 183 | conjugated_type: "形容詞・アウオ段" 184 | conjugated_form: "連用テ接続" 185 | basic_form: "いち早い" 186 | reading: "イチハヤク" 187 | pronunciation: "イチハヤク" 188 | - 189 | expected: いまだに 190 | extensions: {} 191 | tokens: 192 | - 193 | surface_form: "未だに" 194 | pos: "副詞" 195 | pos_detail_1: "一般" 196 | pos_detail_2: "*" 197 | pos_detail_3: "*" 198 | conjugated_type: "*" 199 | conjugated_form: "*" 200 | basic_form: "未だに" 201 | reading: "イマダニ" 202 | pronunciation: "イマダニ" 203 | - 204 | expected: いやしくも 205 | extensions: {} 206 | tokens: 207 | - 208 | surface_form: "苟も" 209 | pos: "副詞" 210 | pos_detail_1: "一般" 211 | pos_detail_2: "*" 212 | pos_detail_3: "*" 213 | conjugated_type: "*" 214 | conjugated_form: "*" 215 | basic_form: "苟も" 216 | reading: "イヤシクモ" 217 | pronunciation: "イヤシクモ" 218 | - 219 | expected: いわば 220 | extensions: {} 221 | tokens: 222 | - 223 | surface_form: "言わば" 224 | pos: "副詞" 225 | pos_detail_1: "一般" 226 | pos_detail_2: "*" 227 | pos_detail_3: "*" 228 | conjugated_type: "*" 229 | conjugated_form: "*" 230 | basic_form: "言わば" 231 | reading: "イワバ" 232 | pronunciation: "イワバ" 233 | - 234 | expected: うすうす 235 | extensions: {} 236 | tokens: 237 | - 238 | surface_form: "薄々" 239 | pos: "副詞" 240 | pos_detail_1: "一般" 241 | pos_detail_2: "*" 242 | pos_detail_3: "*" 243 | conjugated_type: "*" 244 | conjugated_form: "*" 245 | basic_form: "薄々" 246 | reading: "ウスウス" 247 | pronunciation: "ウスウス" 248 | - 249 | expected: おおむね 250 | extensions: {} 251 | tokens: 252 | - 253 | surface_form: "概ね" 254 | pos: "副詞" 255 | pos_detail_1: "一般" 256 | pos_detail_2: "*" 257 | pos_detail_3: "*" 258 | conjugated_type: "*" 259 | conjugated_form: "*" 260 | basic_form: "概ね" 261 | reading: "オオムネ" 262 | pronunciation: "オームネ" 263 | - 264 | expected: おしなべて 265 | extensions: {} 266 | tokens: 267 | - 268 | surface_form: "押し並べて" 269 | pos: "副詞" 270 | pos_detail_1: "一般" 271 | pos_detail_2: "*" 272 | pos_detail_3: "*" 273 | conjugated_type: "*" 274 | conjugated_form: "*" 275 | basic_form: "押し並べて" 276 | reading: "オシナベテ" 277 | pronunciation: "オシナベテ" 278 | - 279 | expected: おしなべて 280 | extensions: {} 281 | tokens: 282 | - 283 | surface_form: "押しなべて" 284 | pos: "副詞" 285 | pos_detail_1: "一般" 286 | pos_detail_2: "*" 287 | pos_detail_3: "*" 288 | conjugated_type: "*" 289 | conjugated_form: "*" 290 | basic_form: "押しなべて" 291 | reading: "オシナベテ" 292 | pronunciation: "オシナベテ" 293 | - 294 | expected: おのずから 295 | extensions: {} 296 | tokens: 297 | - 298 | surface_form: "自ずから" 299 | pos: "副詞" 300 | pos_detail_1: "一般" 301 | pos_detail_2: "*" 302 | pos_detail_3: "*" 303 | conjugated_type: "*" 304 | conjugated_form: "*" 305 | basic_form: "自ずから" 306 | reading: "オノズカラ" 307 | pronunciation: "オノズカラ" 308 | - 309 | expected: おのずと 310 | extensions: {} 311 | tokens: 312 | - 313 | surface_form: "自ずと" 314 | pos: "副詞" 315 | pos_detail_1: "一般" 316 | pos_detail_2: "*" 317 | pos_detail_3: "*" 318 | conjugated_type: "*" 319 | conjugated_form: "*" 320 | basic_form: "自ずと" 321 | reading: "オノズト" 322 | pronunciation: "オノズト" 323 | - 324 | expected: およそ 325 | extensions: {} 326 | tokens: 327 | - 328 | surface_form: "凡そ" 329 | pos: "名詞" 330 | pos_detail_1: "一般" 331 | pos_detail_2: "*" 332 | pos_detail_3: "*" 333 | conjugated_type: "*" 334 | conjugated_form: "*" 335 | basic_form: "凡そ" 336 | reading: "オヨソ" 337 | pronunciation: "オヨソ" 338 | - 339 | expected: かえって 340 | extensions: {} 341 | tokens: 342 | - 343 | surface_form: "却って" 344 | po": "副詞" 345 | pos_detail_1: "一般" 346 | pos_detail_2: "*" 347 | pos_detail_3: "*" 348 | conjugated_type: "*" 349 | conjugated_form: "*" 350 | basic_form: "却って" 351 | reading: "カエッテ" 352 | pronunciation: "カエッテ" 353 | - 354 | expected: かつ 355 | extensions: {} 356 | tokens: 357 | - 358 | surface_form: "且つ" 359 | pos: "副詞" 360 | pos_detail_1: "一般" 361 | pos_detail_2: "*" 362 | pos_detail_3: "*" 363 | conjugated_type: "*" 364 | conjugated_form: "*" 365 | basic_form: "且つ" 366 | reading: "カツ" 367 | pronunciation: "カツ" 368 | - 369 | expected: かつて 370 | extensions: {} 371 | tokens: 372 | - 373 | surface_form: "嘗て" 374 | pos: "副詞" 375 | pos_detail_1: "一般" 376 | pos_detail_2: "*" 377 | pos_detail_3: "*" 378 | conjugated_type: "*" 379 | conjugated_form: "*" 380 | basic_form: "嘗て" 381 | reading: "カツテ" 382 | pronunciation: "カツテ" 383 | - 384 | expected: かねて 385 | extensions: {} 386 | tokens: 387 | - 388 | surface_form: "予て" 389 | pos: "副詞" 390 | pos_detail_1: "一般" 391 | pos_detail_2: "*" 392 | pos_detail_3: "*" 393 | conjugated_type: "*" 394 | conjugated_form: "*" 395 | basic_form: "予て" 396 | reading: "カネテ" 397 | pronunciation: "カネテ" 398 | - 399 | expected: ことごとく 400 | extensions: {} 401 | tokens: 402 | - 403 | surface_form: "悉く" 404 | pos: "副詞" 405 | pos_detail_1: "一般" 406 | pos_detail_2: "*" 407 | pos_detail_3: "*" 408 | conjugated_type: "*" 409 | conjugated_form: "*" 410 | basic_form: "悉く" 411 | reading: "コトゴトク" 412 | pronunciation: "コトゴトク" 413 | - 414 | expected: ことごとく 415 | extensions: {} 416 | tokens: 417 | - 418 | surface_form: "尽く" 419 | pos: "副詞" 420 | pos_detail_1: "一般" 421 | pos_detail_2: "*" 422 | pos_detail_3: "*" 423 | conjugated_type: "*" 424 | conjugated_form: "*" 425 | basic_form: "尽く" 426 | reading: "コトゴトク" 427 | pronunciation: "コトゴトク" 428 | - 429 | expected: こまごま 430 | extensions: {} 431 | tokens: 432 | - 433 | surface_form: "細々" 434 | pos: "副詞" 435 | pos_detail_1: "助詞類接続" 436 | pos_detail_2: "*" 437 | pos_detail_3: "*" 438 | conjugated_type: "*" 439 | conjugated_form: "*" 440 | basic_form: "細々" 441 | reading: "コマゴマ" 442 | pronunciation: "コマゴマ" 443 | - 444 | expected: さらに 445 | extensions: {} 446 | tokens: 447 | - 448 | surface_form: "更に" 449 | pos: "副詞" 450 | pos_detail_1: "助詞類接続" 451 | pos_detail_2: "*" 452 | pos_detail_3: "*" 453 | conjugated_type: "*" 454 | conjugated_form: "*" 455 | basic_form: "更に" 456 | reading: "サラニ" 457 | pronunciation: "サラニ" 458 | - 459 | expected: しきりに 460 | extensions: {} 461 | tokens: 462 | - 463 | surface_form: "頻りに" 464 | pos: "副詞" 465 | pos_detail_1: "一般" 466 | pos_detail_2: "*" 467 | pos_detail_3: "*" 468 | conjugated_type: "*" 469 | conjugated_form: "*" 470 | basic_form: "頻りに" 471 | reading: "シキリニ" 472 | pronunciation: "シキリニ" 473 | - 474 | expected: しばらく 475 | extensions: {} 476 | tokens: 477 | - 478 | surface_form: "暫く" 479 | pos: "副詞" 480 | pos_detail_1: "一般" 481 | pos_detail_2: "*" 482 | pos_detail_3: "*" 483 | conjugated_type: "*" 484 | conjugated_form: "*" 485 | basic_form: "暫く" 486 | reading: "シバラク" 487 | pronunciation: "シバラク" 488 | - 489 | expected: しょせん 490 | extensions: {} 491 | tokens: 492 | - 493 | surface_form: "所詮" 494 | pos: "副詞" 495 | pos_detail_1: "助詞類接続" 496 | pos_detail_2: "*" 497 | pos_detail_3: "*" 498 | conjugated_type: "*" 499 | conjugated_form: "*" 500 | basic_form: "所詮" 501 | reading: "ショセン" 502 | pronunciation: "ショセン" 503 | - 504 | expected: すこぶる 505 | extensions: {} 506 | tokens: 507 | - 508 | surface_form: "頗る" 509 | pos: "副詞" 510 | pos_detail_1: "一般" 511 | pos_detail_2: "*" 512 | pos_detail_3: "*" 513 | conjugated_type: "*" 514 | conjugated_form: "*" 515 | basic_form: "頗る" 516 | reading: "スコブル" 517 | pronunciation: "スコブル" 518 | - 519 | expected: すでに 520 | tokens: 521 | - 522 | surface_form: "既に" 523 | pos: "副詞" 524 | - 525 | expected: せいいっぱい 526 | extensions: {} 527 | tokens: 528 | - 529 | surface_form: "精一杯" 530 | pos: "名詞" 531 | pos_detail_1: "副詞可能" 532 | pos_detail_2: "*" 533 | pos_detail_3: "*" 534 | conjugated_type: "*" 535 | conjugated_form: "*" 536 | basic_form: "精一杯" 537 | reading: "セイイッパイ" 538 | pronunciation: "セイイッパイ" 539 | - 540 | expected: せっかく 541 | extensions: {} 542 | tokens: 543 | - 544 | surface_form: "折角" 545 | pos: "名詞" 546 | pos_detail_1: "一般" 547 | pos_detail_2: "*" 548 | pos_detail_3: "*" 549 | conjugated_type: "*" 550 | conjugated_form: "*" 551 | basic_form: "折角" 552 | reading: "セッカク" 553 | pronunciation: "セッカク" 554 | - 555 | expected: ぜひ 556 | extensions: {} 557 | tokens: 558 | - 559 | surface_form: "是非" 560 | pos: "副詞" 561 | pos_detail_1: "一般" 562 | pos_detail_2: "*" 563 | pos_detail_3: "*" 564 | conjugated_type: "*" 565 | conjugated_form: "*" 566 | basic_form: "是非" 567 | reading: "ゼヒ" 568 | pronunciation: "ゼヒ" 569 | - 570 | expected: ぜひとも 571 | extensions: {} 572 | tokens: 573 | - 574 | surface_form: "是非" 575 | pos: "名詞" 576 | pos_detail_1: "サ変接続" 577 | pos_detail_2: "*" 578 | pos_detail_3: "*" 579 | conjugated_type: "*" 580 | conjugated_form: "*" 581 | basic_form: "是非" 582 | reading: "ゼヒ" 583 | pronunciation: "ゼヒ" 584 | - 585 | surface_form: "とも" 586 | pos: "助詞" 587 | pos_detail_1: "副助詞" 588 | pos_detail_2: "*" 589 | pos_detail_3: "*" 590 | conjugated_type: "*" 591 | conjugated_form: "*" 592 | basic_form: "とも" 593 | reading: "トモ" 594 | pronunciation: "トモ" 595 | - 596 | expected: たくさん 597 | extensions: {} 598 | tokens: 599 | - 600 | surface_form: "沢山" 601 | pos: "名詞" 602 | pos_detail_1: "一般" 603 | pos_detail_2: "*" 604 | pos_detail_3: "*" 605 | conjugated_type: "*" 606 | conjugated_form: "*" 607 | basic_form: "沢山" 608 | reading: "タクサン" 609 | pronunciation: "タクサン" 610 | - 611 | expected: たちどころに 612 | extensions: {} 613 | tokens: 614 | - 615 | surface_form: "立ち所に" 616 | pos: "副詞" 617 | pos_detail_1: "一般" 618 | pos_detail_2: "*" 619 | pos_detail_3: "*" 620 | conjugated_type: "*" 621 | conjugated_form: "*" 622 | basic_form: "立ち所に" 623 | reading: "タチドコロニ" 624 | pronunciation: "タチドコロニ" 625 | - 626 | expected: たとえ 627 | extensions: {} 628 | tokens: 629 | - 630 | surface_form: "仮令" 631 | pos: "副詞" 632 | pos_detail_1: "一般" 633 | pos_detail_2: "*" 634 | pos_detail_3: "*" 635 | conjugated_type: "*" 636 | conjugated_form: "*" 637 | basic_form: "仮令" 638 | reading: "タトエ" 639 | pronunciation: "タトエ" 640 | - 641 | expected: たとえ 642 | extensions: {} 643 | tokens: 644 | - 645 | surface_form: "縦令" 646 | pos: "副詞" 647 | pos_detail_1: "一般" 648 | pos_detail_2: "*" 649 | pos_detail_3: "*" 650 | conjugated_type: "*" 651 | conjugated_form: "*" 652 | basic_form: "縦令" 653 | reading: "タトエ" 654 | pronunciation: "タトエ" 655 | - 656 | expected: ちょうど 657 | extensions: {} 658 | tokens: 659 | - 660 | surface_form: "丁度" 661 | pos: "副詞" 662 | pos_detail_1: "一般" 663 | pos_detail_2: "*" 664 | pos_detail_3: "*" 665 | conjugated_type: "*" 666 | conjugated_form: "*" 667 | basic_form: "丁度" 668 | reading: "チョウド" 669 | pronunciation: "チョード" 670 | - 671 | expected: とくと 672 | extensions: {} 673 | tokens: 674 | - 675 | surface_form: "篤と" 676 | pos: "副詞" 677 | pos_detail_1: "一般" 678 | pos_detail_2: "*" 679 | pos_detail_3: "*" 680 | conjugated_type: "*" 681 | conjugated_form: "*" 682 | basic_form: "篤と" 683 | reading: "トクト" 684 | pronunciation: "トクト" 685 | - 686 | expected: どだい 687 | extensions: {} 688 | tokens: 689 | - 690 | surface_form: "土台" 691 | pos: "副詞" 692 | pos_detail_1: "一般" 693 | pos_detail_2: "*" 694 | pos_detail_3: "*" 695 | conjugated_type: "*" 696 | conjugated_form: "*" 697 | basic_form: "土台" 698 | reading: "ドダイ" 699 | pronunciation: "ドダイ" 700 | - 701 | expected: とりわけ 702 | extensions: {} 703 | tokens: 704 | - 705 | surface_form: "取り分け" 706 | pos: "名詞" 707 | pos_detail_1: "一般" 708 | pos_detail_2: "*" 709 | pos_detail_3: "*" 710 | conjugated_type: "*" 711 | conjugated_form: "*" 712 | basic_form: "取り分け" 713 | reading: "トリワケ" 714 | pronunciation: "トリワケ" 715 | - 716 | expected: なぜ 717 | extensions: {} 718 | tokens: 719 | - 720 | surface_form: "何故" 721 | pos: "副詞" 722 | pos_detail_1: "助詞類接続" 723 | pos_detail_2: "*" 724 | pos_detail_3: "*" 725 | conjugated_type: "*" 726 | conjugated_form: "*" 727 | basic_form: "何故" 728 | reading: "ナゼ" 729 | pronunciation: "ナゼ" 730 | - 731 | expected: ひとえに 732 | extensions: {} 733 | tokens: 734 | - 735 | surface_form: "偏に" 736 | pos: "副詞" 737 | pos_detail_1: "一般" 738 | pos_detail_2: "*" 739 | pos_detail_3: "*" 740 | conjugated_type: "*" 741 | conjugated_form: "*" 742 | basic_form: "偏に" 743 | reading: "ヒトエニ" 744 | pronunciation: "ヒトエニ" 745 | - 746 | expected: ひときわ 747 | extensions: {} 748 | tokens: 749 | - 750 | surface_form: "一際" 751 | pos: "副詞" 752 | pos_detail_1: "一般" 753 | pos_detail_2: "*" 754 | pos_detail_3: "*" 755 | conjugated_type: "*" 756 | conjugated_form: "*" 757 | basic_form: "一際" 758 | reading: "ヒトキワ" 759 | pronunciation: "ヒトキワ" 760 | - 761 | expected: ひとしお 762 | extensions: {} 763 | tokens: 764 | - 765 | surface_form: "一入" 766 | pos: "副詞" 767 | pos_detail_1: "一般" 768 | pos_detail_2: "*" 769 | pos_detail_3: "*" 770 | conjugated_type: "*" 771 | conjugated_form: "*" 772 | basic_form: "一入" 773 | reading: "ヒトシオ" 774 | pronunciation: "ヒトシオ" 775 | - 776 | expected: ひとまず 777 | extensions: {} 778 | tokens: 779 | - 780 | surface_form: "一先ず" 781 | pos: "副詞" 782 | pos_detail_1: "一般" 783 | pos_detail_2: "*" 784 | pos_detail_3: "*" 785 | conjugated_type: "*" 786 | conjugated_form: "*" 787 | basic_form: "一先ず" 788 | reading: "ヒトマズ" 789 | pronunciation: "ヒトマズ" 790 | - 791 | expected: ひとりでに 792 | extensions: {} 793 | tokens: 794 | - 795 | surface_form: "独りでに" 796 | pos: "副詞" 797 | pos_detail_1: "一般" 798 | pos_detail_2: "*" 799 | pos_detail_3: "*" 800 | conjugated_type: "*" 801 | conjugated_form: "*" 802 | basic_form: "独りでに" 803 | reading: "ヒトリデニ" 804 | pronunciation: "ヒトリデニ" 805 | - 806 | expected: ほとんど 807 | extensions: {} 808 | tokens: 809 | - 810 | surface_form: "殆ど" 811 | pos: "名詞" 812 | pos_detail_1: "副詞可能" 813 | pos_detail_2: "*" 814 | pos_detail_3: "*" 815 | conjugated_type: "*" 816 | conjugated_form: "*" 817 | basic_form: "殆ど" 818 | reading: "ホトンド" 819 | pronunciation: "ホトンド" 820 | - 821 | expected: まさしく 822 | extensions: {} 823 | tokens: 824 | - 825 | surface_form: "正しく" 826 | pos: "副詞" 827 | pos_detail_1: "一般" 828 | pos_detail_2: "*" 829 | pos_detail_3: "*" 830 | conjugated_type: "*" 831 | conjugated_form: "*" 832 | basic_form: "正しく" 833 | reading: "マサシク" 834 | pronunciation: "マサシク" 835 | - 836 | expected: まさに 837 | extensions: {} 838 | tokens: 839 | - 840 | surface_form: "正に" 841 | pos: "副詞" 842 | pos_detail_1: "一般" 843 | pos_detail_2: "*" 844 | pos_detail_3: "*" 845 | conjugated_type: "*" 846 | conjugated_form: "*" 847 | basic_form: "正に" 848 | reading: "マサニ" 849 | pronunciation: "マサニ" 850 | - 851 | expected: まして 852 | extensions: {} 853 | tokens: 854 | - 855 | surface_form: "況して" 856 | pos: "副詞" 857 | pos_detail_1: "一般" 858 | pos_detail_2: "*" 859 | pos_detail_3: "*" 860 | conjugated_type: "*" 861 | conjugated_form: "*" 862 | basic_form: "況して" 863 | reading: "マシテ" 864 | pronunciation: "マシテ" 865 | - 866 | expected: まず 867 | extensions: {} 868 | tokens: 869 | - 870 | surface_form: "先ず" 871 | pos: "副詞" 872 | pos_detail_1: "一般" 873 | pos_detail_2: "*" 874 | pos_detail_3: "*" 875 | conjugated_type: "*" 876 | conjugated_form: "*" 877 | basic_form: "先ず" 878 | reading: "マズ" 879 | pronunciation: "マズ" 880 | - 881 | expected: まるで 882 | extensions: {} 883 | tokens: 884 | - 885 | surface_form: "丸" 886 | pos: "名詞" 887 | pos_detail_1: "一般" 888 | pos_detail_2: "*" 889 | pos_detail_3: "*" 890 | conjugated_type: "*" 891 | conjugated_form: "*" 892 | basic_form: "丸" 893 | reading: "マル" 894 | pronunciation: "マル" 895 | - 896 | surface_form: "で" 897 | pos: "助詞" 898 | pos_detail_1: "格助詞" 899 | pos_detail_2: "一般" 900 | pos_detail_3: "*" 901 | conjugated_type: "*" 902 | conjugated_form: "*" 903 | basic_form: "で" 904 | reading: "デ" 905 | pronunciation: "デ" 906 | - 907 | expected: まんざら 908 | extensions: {} 909 | tokens: 910 | - 911 | surface_form: "満更" 912 | pos: "副詞" 913 | pos_detail_1: "一般" 914 | pos_detail_2: "*" 915 | pos_detail_3: "*" 916 | conjugated_type: "*" 917 | conjugated_form: "*" 918 | basic_form: "満更" 919 | reading: "マンザラ" 920 | pronunciation: "マンザラ" 921 | - 922 | expected: むげに 923 | extensions: {} 924 | tokens: 925 | - 926 | surface_form: "無碍" 927 | pos: "名詞" 928 | pos_detail_1: "形容動詞語幹" 929 | pos_detail_2: "*" 930 | pos_detail_3: "*" 931 | conjugated_type: "*" 932 | conjugated_form: "*" 933 | basic_form: "無碍" 934 | reading: "ムゲ" 935 | pronunciation: "ムゲ" 936 | - 937 | surface_form: "に" 938 | pos: "助詞" 939 | pos_detail_1: "副詞化" 940 | pos_detail_2: "*" 941 | pos_detail_3: "*" 942 | conjugated_type: "*" 943 | conjugated_form: "*" 944 | basic_form: "に" 945 | reading: "ニ" 946 | pronunciation: "ニ" 947 | - 948 | expected: むしろ 949 | extensions: {} 950 | tokens: 951 | - 952 | surface_form: "寧ろ" 953 | pos: "副詞" 954 | pos_detail_1: "一般" 955 | pos_detail_2: "*" 956 | pos_detail_3: "*" 957 | conjugated_type: "*" 958 | conjugated_form: "*" 959 | basic_form: "寧ろ" 960 | reading: "ムシロ" 961 | pronunciation: "ムシロ" 962 | - 963 | expected: 無理やり 964 | extensions: {} 965 | tokens: 966 | - 967 | surface_form: "無理矢理" 968 | pos: "名詞" 969 | pos_detail_1: "一般" 970 | pos_detail_2: "*" 971 | pos_detail_3: "*" 972 | conjugated_type: "*" 973 | conjugated_form: "*" 974 | basic_form: "無理矢理" 975 | reading: "ムリヤリ" 976 | pronunciation: "ムリヤリ" 977 | - 978 | expected: めっぽう 979 | extensions: {} 980 | tokens: 981 | - 982 | surface_form: "滅法" 983 | pos: "副詞" 984 | pos_detail_1: "一般" 985 | pos_detail_2: "*" 986 | pos_detail_3: "*" 987 | conjugated_type: "*" 988 | conjugated_form: "*" 989 | basic_form: "滅法" 990 | reading: "メッポウ" 991 | pronunciation: "メッポー" 992 | - 993 | expected: もしも 994 | extensions: {} 995 | tokens: 996 | - 997 | surface_form: "若しも" 998 | pos: "副詞" 999 | pos_detail_1: "一般" 1000 | pos_detail_2: "*" 1001 | pos_detail_3: "*" 1002 | conjugated_type: "*" 1003 | conjugated_form: "*" 1004 | basic_form: "若しも" 1005 | reading: "モシモ" 1006 | pronunciation: "モシモ" 1007 | - 1008 | expected: もしくは 1009 | extensions: {} 1010 | tokens: 1011 | - 1012 | surface_form: "若しくは" 1013 | pos: "接続詞" 1014 | pos_detail_1: "*" 1015 | pos_detail_2: "*" 1016 | pos_detail_3: "*" 1017 | conjugated_type: "*" 1018 | conjugated_form: "*" 1019 | basic_form: "若しくは" 1020 | reading: "モシクハ" 1021 | pronunciation: "モシクワ" 1022 | - 1023 | expected: もちろん 1024 | extensions: {} 1025 | tokens: 1026 | - 1027 | surface_form: "勿論" 1028 | pos: "副詞" 1029 | pos_detail_1: "一般" 1030 | pos_detail_2: "*" 1031 | pos_detail_3: "*" 1032 | conjugated_type: "*" 1033 | conjugated_form: "*" 1034 | basic_form: "勿論" 1035 | reading: "モチロン" 1036 | pronunciation: "モチロン" 1037 | - 1038 | expected: もっとも 1039 | tokens: 1040 | - 1041 | surface_form: "最も" 1042 | pos: "副詞" 1043 | - 1044 | expected: もともと 1045 | extensions: {} 1046 | tokens: 1047 | - 1048 | surface_form: "元々" 1049 | pos: "副詞" 1050 | pos_detail_1: "助詞類接続" 1051 | pos_detail_2: "*" 1052 | pos_detail_3: "*" 1053 | conjugated_type: "*" 1054 | conjugated_form: "*" 1055 | basic_form: "元々" 1056 | reading: "モトモト" 1057 | pronunciation: "モトモト" 1058 | - 1059 | expected: もとより 1060 | extensions: {} 1061 | tokens: 1062 | - 1063 | surface_form: "素より" 1064 | pos: "副詞" 1065 | pos_detail_1: "一般" 1066 | pos_detail_2: "*" 1067 | pos_detail_3: "*" 1068 | conjugated_type: "*" 1069 | conjugated_form: "*" 1070 | basic_form: "素より" 1071 | reading: "モトヨリ" 1072 | pronunciation: "モトヨリ" 1073 | - 1074 | expected: もはや 1075 | extensions: {} 1076 | tokens: 1077 | - 1078 | surface_form: "最早" 1079 | pos: "副詞" 1080 | pos_detail_1: "一般" 1081 | pos_detail_2: "*" 1082 | pos_detail_3: "*" 1083 | conjugated_type: "*" 1084 | conjugated_form: "*" 1085 | basic_form: "最早" 1086 | reading: "モハヤ" 1087 | pronunciation: "モハヤ" 1088 | - 1089 | expected: やはり 1090 | extensions: {} 1091 | tokens: 1092 | - 1093 | surface_form: "矢" 1094 | pos: "名詞" 1095 | pos_detail_1: "一般" 1096 | pos_detail_2: "*" 1097 | pos_detail_3: "*" 1098 | conjugated_type: "*" 1099 | conjugated_form: "*" 1100 | basic_form: "矢" 1101 | reading: "ヤ" 1102 | pronunciation: "ヤ" 1103 | - 1104 | surface_form: "張り" 1105 | pos: "名詞" 1106 | pos_detail_1: "接尾" 1107 | pos_detail_2: "一般" 1108 | pos_detail_3: "*" 1109 | conjugated_type: "*" 1110 | conjugated_form: "*" 1111 | basic_form: "張り" 1112 | reading: "バリ" 1113 | pronunciation: "バリ" 1114 | - 1115 | expected: やっぱり 1116 | extensions: {} 1117 | tokens: 1118 | - 1119 | surface_form: "矢" 1120 | pos: "名詞" 1121 | pos_detail_1: "一般" 1122 | pos_detail_2: "*" 1123 | pos_detail_3: "*" 1124 | conjugated_type: "*" 1125 | conjugated_form: "*" 1126 | basic_form: "矢" 1127 | reading: "ヤ" 1128 | pronunciation: "ヤ" 1129 | - 1130 | surface_form: "っ" 1131 | pos: "動詞" 1132 | pos_detail_1: "非自立" 1133 | pos_detail_2: "*" 1134 | pos_detail_3: "*" 1135 | conjugated_type: "五段・カ行促音便" 1136 | conjugated_form: "連用タ接続" 1137 | basic_form: "く" 1138 | reading: "ッ" 1139 | pronunciation: "ッ" 1140 | - 1141 | surface_form: "張り" 1142 | pos: "名詞" 1143 | pos_detail_1: "接尾" 1144 | pos_detail_2: "一般" 1145 | pos_detail_3: "*" 1146 | conjugated_type: "*" 1147 | conjugated_form: "*" 1148 | basic_form: "張り" 1149 | reading: "ハリ" 1150 | pronunciation: "ハリ" 1151 | - 1152 | expected: ようやく 1153 | extensions: {} 1154 | tokens: 1155 | - 1156 | surface_form: "漸く" 1157 | pos: "副詞" 1158 | pos_detail_1: "一般" 1159 | pos_detail_2: "*" 1160 | pos_detail_3: "*" 1161 | conjugated_type: "*" 1162 | conjugated_form: "*" 1163 | basic_form: "漸く" 1164 | reading: "ヨウヤク" 1165 | pronunciation: "ヨーヤク" 1166 | - 1167 | expected: よほど 1168 | extensions: {} 1169 | tokens: 1170 | - 1171 | surface_form: "余程" 1172 | pos: "副詞" 1173 | pos_detail_1: "一般" 1174 | pos_detail_2: "*" 1175 | pos_detail_3: "*" 1176 | conjugated_type: "*" 1177 | conjugated_form: "*" 1178 | basic_form: "余程" 1179 | reading: "ヨホド" 1180 | pronunciation: "ヨホド" 1181 | - 1182 | expected: わずかに 1183 | extensions: {} 1184 | tokens: 1185 | - 1186 | surface_form: "僅か" 1187 | pos: "名詞" 1188 | pos_detail_1: "形容動詞語幹" 1189 | pos_detail_2: "*" 1190 | pos_detail_3: "*" 1191 | conjugated_type: "*" 1192 | conjugated_form: "*" 1193 | basic_form: "僅か" 1194 | reading: "ワズカ" 1195 | pronunciation: "ワズカ" 1196 | - 1197 | surface_form: "に" 1198 | pos: "助詞" 1199 | pos_detail_1: "副詞化" 1200 | pos_detail_2: "*" 1201 | pos_detail_3: "*" 1202 | conjugated_type: "*" 1203 | conjugated_form: "*" 1204 | basic_form: "に" 1205 | reading: "ニ" 1206 | pronunciation: "ニ" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.3.0", 3 | "keywords": [ 4 | "textlintrule" 5 | ], 6 | "main": "lib/index.js", 7 | "files": [ 8 | "lib/", 9 | "src/", 10 | "dict/" 11 | ], 12 | "scripts": { 13 | "test": "textlint-scripts test", 14 | "build": "textlint-scripts build", 15 | "prepublish": "npm run --if-present build" 16 | }, 17 | "devDependencies": { 18 | "eslint": "^6.6.0", 19 | "textlint-scripts": "^1.2.2" 20 | }, 21 | "name": "textlint-rule-ja-hiragana-fukushi", 22 | "directories": { 23 | "test": "test" 24 | }, 25 | "repository": { 26 | "type": "git", 27 | "url": "git+https://github.com/lostandfound/textlint-rule-ja-hiragana-fukushi.git" 28 | }, 29 | "author": "Hiroshi Takase", 30 | "license": "MIT", 31 | "description": "Check easy-to-read Fukushi(adverbs) written in Hiragana than Kanji.", 32 | "dependencies": { 33 | "js-yaml": "^3.8.2", 34 | "kuromojin": "^2.1.1", 35 | "morpheme-match-all": "^1.1.0", 36 | "untildify": "^4.0.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | const fs = require("fs"); 4 | const kuromojin = require("kuromojin"); 5 | const createMatcher = require("morpheme-match-all"); 6 | const yaml = require("js-yaml"); 7 | 8 | const path = require("path"); 9 | const untildify = require("untildify"); 10 | 11 | const defaultOptions = { 12 | rulePath: __dirname + "/../dict/fukushi.yml" 13 | }; 14 | 15 | function loadDictionaries(rulePath, baseDir) { 16 | if (typeof rulePath === "undefined" || rulePath ==="") { 17 | return null; 18 | } 19 | const expandedRulePath = untildify(rulePath); 20 | const dictionaries = []; 21 | const data = yaml.safeLoad(fs.readFileSync(path.resolve(baseDir, expandedRulePath), "utf8")); 22 | 23 | data.dict.forEach(function (item) { 24 | var form = ""; 25 | item.tokens.forEach(function (token) { 26 | form += token.surface_form; 27 | }); 28 | dictionaries.push({ 29 | message: data.message + ": \"" + form + "\" => \"" + item.expected + "\"", 30 | fix: item.expected, 31 | tokens: item.tokens 32 | }); 33 | }); 34 | 35 | return dictionaries; 36 | } 37 | 38 | function reporter(context, userOptions = {}) { 39 | const options = Object.assign(defaultOptions, userOptions); 40 | const matchAll = createMatcher(loadDictionaries(options.rulePath, getConfigBaseDir(context))); 41 | const {Syntax, RuleError, report, getSource, fixer} = context; 42 | return { 43 | [Syntax.Str](node){ // "Str" node 44 | const text = getSource(node); // Get text 45 | return kuromojin.tokenize(text).then((actualTokens) => { 46 | const results = matchAll(actualTokens); 47 | 48 | if (results.length == 0) { 49 | return; 50 | } 51 | 52 | results.forEach(function (result) { 53 | const tokenIndex = result.index; 54 | const index = getIndexFromTokens(tokenIndex, actualTokens); 55 | let replaceFrom = ""; 56 | result.tokens.forEach(function(token){ 57 | replaceFrom += token.surface_form; 58 | }); 59 | const replaceTo = fixer.replaceTextRange([index, index + replaceFrom.length], result.dict.fix); 60 | const ruleError = new RuleError(result.dict.message, { 61 | index: index, 62 | fix: replaceTo // https://github.com/textlint/textlint/blob/master/docs/rule-fixable.md 63 | }); 64 | report(node, ruleError); 65 | }); 66 | }); 67 | } 68 | }; 69 | } 70 | 71 | function getIndexFromTokens(tokenIndex, actualTokens) { 72 | let index = 0; 73 | for ( let i = 0; i < tokenIndex; i++) { 74 | index += actualTokens[i].surface_form.length; 75 | } 76 | return index; 77 | } 78 | 79 | // from https://github.com/textlint-rule/textlint-rule-prh/blob/master/src/textlint-rule-prh.js#L147 80 | const getConfigBaseDir = context => { 81 | if (typeof context.getConfigBaseDir === "function") { 82 | return context.getConfigBaseDir() || process.cwd(); 83 | } 84 | const textlintRcFilePath = context.config ? context.config.configFile : null; 85 | return textlintRcFilePath ? path.dirname(textlintRcFilePath) : process.cwd(); 86 | }; 87 | 88 | module.exports = { 89 | linter: reporter, 90 | fixer: reporter 91 | }; 92 | 93 | -------------------------------------------------------------------------------- /test/fukushi.test.yml: -------------------------------------------------------------------------------- 1 | message: ひらがなで表記したほうが読みやすい副詞 2 | dict: 3 | - 4 | expected: あいにく 5 | extensions: {} 6 | tokens: 7 | - 8 | surface_form: "生憎" 9 | pos: "副詞" 10 | pos_detail_1: "一般" 11 | pos_detail_2: "*" 12 | pos_detail_3: "*" 13 | conjugated_type: "*" 14 | conjugated_form: "*" 15 | basic_form: "生憎" 16 | reading: "アイニク" 17 | pronunciation: "アイニク" 18 | - 19 | expected: あえて 20 | extensions: {} 21 | tokens: 22 | - 23 | surface_form: "敢えて" 24 | pos: "副詞" 25 | pos_detail_1: "一般" 26 | pos_detail_2: "*" 27 | pos_detail_3: "*" 28 | conjugated_type: "*" 29 | conjugated_form: "*" 30 | basic_form: "敢えて" 31 | reading: "アエテ" 32 | pronunciation: "アエテ" 33 | -------------------------------------------------------------------------------- /test/index-test.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | const TextLintTester = require("textlint-tester"); 3 | const tester = new TextLintTester(); 4 | // rule 5 | const rule = require("../src/index"); 6 | // ruleName, rule, { valid, invalid } 7 | tester.run("rule", rule, { 8 | valid: [ 9 | // no problem 10 | "text", 11 | { 12 | text: "正しく記載されていなかった。", 13 | options: { 14 | rulePath: "./test/fukushi.test.yml" 15 | } 16 | } 17 | ], 18 | 19 | invalid: [ 20 | // single match fukushi 21 | { 22 | text: "僕は生憎風流人よりもずつと多慾に生まれついてゐる。", 23 | output: "僕はあいにく風流人よりもずつと多慾に生まれついてゐる。", 24 | errors: [ 25 | { 26 | message: "ひらがなで表記したほうが読みやすい副詞: \"生憎\" => \"あいにく\"", 27 | line: 1, 28 | column: 3 29 | } 30 | ] 31 | }, 32 | { 33 | text: "人は僅かに岩と浪との間を行く", 34 | output: "人はわずかに岩と浪との間を行く", 35 | errors: [ 36 | { 37 | message: "ひらがなで表記したほうが読みやすい副詞: \"僅かに\" => \"わずかに\"", 38 | line: 1, 39 | column: 3 40 | } 41 | ] 42 | }, 43 | { 44 | text: "一旦初期設定に戻す", 45 | output: "いったん初期設定に戻す", 46 | errors: [ 47 | { 48 | message: "ひらがなで表記したほうが読みやすい副詞: \"一旦\" => \"いったん\"", 49 | line: 1, 50 | column: 1 51 | } 52 | ] 53 | }, 54 | { 55 | text: "既に解決した", 56 | output: "すでに解決した", 57 | errors: [ 58 | { 59 | message: "ひらがなで表記したほうが読みやすい副詞: \"既に\" => \"すでに\"", 60 | line: 1, 61 | column: 1 62 | } 63 | ] 64 | }, 65 | { 66 | text: "最も負荷が少ない", 67 | output: "もっとも負荷が少ない", 68 | errors: [ 69 | { 70 | message: "ひらがなで表記したほうが読みやすい副詞: \"最も\" => \"もっとも\"", 71 | line: 1, 72 | column: 1 73 | } 74 | ] 75 | }, 76 | // multiple match 77 | { 78 | text: `僕は敢えて怠っていると言う。 79 | 80 | 飽くまで平民の間にのみ存在し了解されているのである。`, 81 | output: `僕はあえて怠っていると言う。 82 | 83 | あくまで平民の間にのみ存在し了解されているのである。`, 84 | errors: [ 85 | { 86 | message: "ひらがなで表記したほうが読みやすい副詞: \"敢えて\" => \"あえて\"", 87 | line: 1, 88 | column: 3 89 | }, 90 | { 91 | message: "ひらがなで表記したほうが読みやすい副詞: \"飽くまで\" => \"あくまで\"", 92 | line: 3, 93 | column: 1 94 | } 95 | ] 96 | }, 97 | // custom dictionary 98 | { 99 | text: "正しく記載されていなかった。", 100 | output: "まさしく記載されていなかった。", 101 | errors: [ 102 | { 103 | message: "ひらがなで表記したほうが読みやすい副詞: \"正しく\" => \"まさしく\"", 104 | line: 1, 105 | column: 1 106 | } 107 | ] 108 | }, 109 | { 110 | text: "僕は生憎風流人よりもずつと多慾に生まれついてゐる。", 111 | output: "僕はあいにく風流人よりもずつと多慾に生まれついてゐる。", 112 | options: { 113 | rulePath: "./test/fukushi.test.yml" 114 | }, 115 | errors: [ 116 | { 117 | message: "ひらがなで表記したほうが読みやすい副詞: \"生憎\" => \"あいにく\"", 118 | line: 1, 119 | column: 3 120 | } 121 | ] 122 | } 123 | 124 | ] 125 | 126 | }); 127 | --------------------------------------------------------------------------------