Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: "やす" は ですます調の判定から除外する #20

Merged
merged 2 commits into from
Jan 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
changelog:
exclude:
labels:
- 'Type: Meta'
- 'Type: Question'
- 'Type: Release'

categories:
- title: Security Fixes
labels: ['Type: Security']
- title: Breaking Changes
labels: ['Type: Breaking Change']
- title: Features
labels: ['Type: Feature']
- title: Bug Fixes
labels: ['Type: Bug']
- title: Documentation
labels: ['Type: Documentation']
- title: Refactoring
labels: ['Type: Refactoring']
- title: Testing
labels: ['Type: Testing']
- title: Maintenance
labels: ['Type: Maintenance']
- title: CI
labels: ['Type: CI']
- title: Dependency Updates
labels: ['Type: Dependencies', "dependencies"]
- title: Other Changes
labels: ['*']
6 changes: 3 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,6 @@
"*.{js,jsx,ts,tsx,css}": [
"prettier --write"
]
}
},
"packageManager": "[email protected]+sha256.c17d3797fb9a9115bf375e31bfd30058cac6bc9c3b8807a3d8cb2094794b51ca"
}
16 changes: 13 additions & 3 deletions src/analyze.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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"] === "基本形") {
// 文末の"です"のみを許容する場合は、文末であるかどうかを調べる
Expand Down
6 changes: 6 additions & 0 deletions test/analyze-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ describe("analyze-test", function () {
});
});
});
it("'やす'はですます調としては認識しない", function () {
let text = "構成物の崩れやすさ、脆さに注意が必要である。";
return analyzeDesumasu(text).then((results) => {
assert(results.length === 0);
});
});
});
});
describe("analyzeDearu", function () {
Expand Down
Loading