diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 170443f..ae01ba4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,12 +6,12 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node-version: [12, 14] + node-version: [ 20, 22 ] steps: - name: checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 + uses: actions/setup-node@v4 with: node-version: ${{ matrix.node-version }} - name: Install diff --git a/package.json b/package.json index ae6d6b5..c49a95e 100644 --- a/package.json +++ b/package.json @@ -57,5 +57,6 @@ "*.{js,jsx,ts,tsx,css}": [ "prettier --write" ] - } + }, + "packageManager": "yarn@1.22.22+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca" } diff --git a/src/analyze.js b/src/analyze.js index 747656c..712a7b7 100644 --- a/src/analyze.js +++ b/src/analyze.js @@ -50,11 +50,16 @@ export function isDearu({ type }) { } /** - * typeが敬体(ですます調)か常体(である調)かを判定する + * typeが敬体(ですます調)なら true を返す * @param {string} type * @returns {boolean} */ const isDesumasuType = (type) => type === Types.desu || type === Types.masu; +/** + * typeが常体(である調)なら true を返す + * @param type + * @returns {boolean} + */ const isDearuType = (type) => type === Types.dearu; /** @@ -122,8 +127,7 @@ const mapToAnalyzedResult = (tokens) => { return { type: token["conjugated_type"], value: value, - surface: token["surface_form"], - // index start with 0 + surface: token["surface_form"], // index start with 0 index: token["word_position"] - 1, /** * @type {AnalyzedToken} @@ -160,6 +164,12 @@ export function analyze(text, options = defaultOptions) { } } } else if (isDesumasuType(conjugatedType)) { + // "やす" は "特殊・マス" として認識されるが、誤判定を避けるために除外する + // https://github.com/textlint-ja/textlint-rule-no-mix-dearu-desumasu/issues/52 + if (token["basic_form"] === "やす") { + return false; + } + // TODO: can omit? if (token["conjugated_form"] === "基本形") { // 文末の"です"のみを許容する場合は、文末であるかどうかを調べる diff --git a/test/analyze-test.js b/test/analyze-test.js index 0b81901..a835c7d 100644 --- a/test/analyze-test.js +++ b/test/analyze-test.js @@ -139,6 +139,12 @@ describe("analyze-test", function () { }); }); }); + it("'やす'はですます調としては認識しない", function () { + let text = "構成物の崩れやすさ、脆さに注意が必要である。"; + return analyzeDesumasu(text).then((results) => { + assert(results.length === 0); + }); + }); }); }); describe("analyzeDearu", function () {