Skip to content

Commit 996d84e

Browse files
authored
fix: "やす" は ですます調の判定から除外する (#20)
* fix: "やす" は ですます調の判定から除外する * CI: add .github/release.yml
1 parent 25ec350 commit 996d84e

File tree

5 files changed

+54
-7
lines changed

5 files changed

+54
-7
lines changed

.github/release.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
changelog:
2+
exclude:
3+
labels:
4+
- 'Type: Meta'
5+
- 'Type: Question'
6+
- 'Type: Release'
7+
8+
categories:
9+
- title: Security Fixes
10+
labels: ['Type: Security']
11+
- title: Breaking Changes
12+
labels: ['Type: Breaking Change']
13+
- title: Features
14+
labels: ['Type: Feature']
15+
- title: Bug Fixes
16+
labels: ['Type: Bug']
17+
- title: Documentation
18+
labels: ['Type: Documentation']
19+
- title: Refactoring
20+
labels: ['Type: Refactoring']
21+
- title: Testing
22+
labels: ['Type: Testing']
23+
- title: Maintenance
24+
labels: ['Type: Maintenance']
25+
- title: CI
26+
labels: ['Type: CI']
27+
- title: Dependency Updates
28+
labels: ['Type: Dependencies', "dependencies"]
29+
- title: Other Changes
30+
labels: ['*']

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ jobs:
66
runs-on: ubuntu-latest
77
strategy:
88
matrix:
9-
node-version: [12, 14]
9+
node-version: [ 20, 22 ]
1010
steps:
1111
- name: checkout
12-
uses: actions/checkout@v2
12+
uses: actions/checkout@v4
1313
- name: setup Node.js ${{ matrix.node-version }}
14-
uses: actions/setup-node@v2
14+
uses: actions/setup-node@v4
1515
with:
1616
node-version: ${{ matrix.node-version }}
1717
- name: Install

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@
5757
"*.{js,jsx,ts,tsx,css}": [
5858
"prettier --write"
5959
]
60-
}
60+
},
61+
"packageManager": "yarn@1.22.22+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
6162
}

src/analyze.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,16 @@ export function isDearu({ type }) {
5050
}
5151

5252
/**
53-
* typeが敬体(ですます調)か常体(である調)かを判定する
53+
* typeが敬体(ですます調)なら true を返す
5454
* @param {string} type
5555
* @returns {boolean}
5656
*/
5757
const isDesumasuType = (type) => type === Types.desu || type === Types.masu;
58+
/**
59+
* typeが常体(である調)なら true を返す
60+
* @param type
61+
* @returns {boolean}
62+
*/
5863
const isDearuType = (type) => type === Types.dearu;
5964

6065
/**
@@ -122,8 +127,7 @@ const mapToAnalyzedResult = (tokens) => {
122127
return {
123128
type: token["conjugated_type"],
124129
value: value,
125-
surface: token["surface_form"],
126-
// index start with 0
130+
surface: token["surface_form"], // index start with 0
127131
index: token["word_position"] - 1,
128132
/**
129133
* @type {AnalyzedToken}
@@ -160,6 +164,12 @@ export function analyze(text, options = defaultOptions) {
160164
}
161165
}
162166
} else if (isDesumasuType(conjugatedType)) {
167+
// "やす" は "特殊・マス" として認識されるが、誤判定を避けるために除外する
168+
// https://github.com/textlint-ja/textlint-rule-no-mix-dearu-desumasu/issues/52
169+
if (token["basic_form"] === "やす") {
170+
return false;
171+
}
172+
163173
// TODO: can omit?
164174
if (token["conjugated_form"] === "基本形") {
165175
// 文末の"です"のみを許容する場合は、文末であるかどうかを調べる

test/analyze-test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ describe("analyze-test", function () {
139139
});
140140
});
141141
});
142+
it("'やす'はですます調としては認識しない", function () {
143+
let text = "構成物の崩れやすさ、脆さに注意が必要である。";
144+
return analyzeDesumasu(text).then((results) => {
145+
assert(results.length === 0);
146+
});
147+
});
142148
});
143149
});
144150
describe("analyzeDearu", function () {

0 commit comments

Comments
 (0)