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

Add 鈍音 and 銳音 #24

Merged
merged 2 commits into from
Mar 27, 2022
Merged
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
8 changes: 6 additions & 2 deletions src/lib/音韻地位.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const 輕脣韻 = '東鍾微虞廢文元陽尤凡';
const 次入韻 = '祭泰夬廢';
const 陰聲韻 = '支脂之微魚虞模齊祭泰佳皆夬灰咍廢蕭宵肴豪歌麻侯尤幽';

const 鈍音組 = '幫見影';

const 特別編碼: Record<number, [string, string]> = {
0: ['東', '一'],
1: ['東', '三'],
Expand Down Expand Up @@ -479,7 +481,7 @@ export class 音韻地位 {
*
* * 音韻地位六要素:`……母`, `……等`, `……韻`, `……聲`, `開口`, `合口`, `開合中立`, `重紐A類`, `重紐B類`, `不分重紐`
* * 拓展音韻地位:`……組`, `……音`, `……攝`, `全清`, `次清`, `全濁`, `次濁`, `清音`, `濁音`
* * 其他表達式:`陰聲韻`, `陽聲韻`, `入聲韻`, `輕脣韻`, `次入韻`, `仄聲`, `舒聲`
* * 其他表達式:`陰聲韻`, `陽聲韻`, `入聲韻`, `輕脣韻`, `次入韻`, `仄聲`, `舒聲`, `鈍音`, `銳音`
*
* 支援的運算子:
*
Expand Down Expand Up @@ -534,7 +536,7 @@ export class 音韻地位 {
if (typeof 表達式 === 'string') 表達式 = [表達式];

/** 普通字串 token 求值 */
const { 呼, 等, 重紐, 韻, 聲, 清濁, 韻別 } = this;
const { 呼, 等, 重紐, 韻, 聲, 清濁, 韻別, 組 } = this;
const evalToken = (token: string): boolean => {
let match: RegExpExecArray = null;
const tryMatch = (pat: RegExp) => !!(match = pat.exec(token));
Expand All @@ -549,6 +551,8 @@ export class 音韻地位 {
if (tryMatch(/^不分重紐$/)) return 重紐 === null;
if (tryMatch(/^(清|濁)音$/)) return 清濁[1] === match[1];
if (tryMatch(/^[全次][清濁]$/)) return 清濁 === match[0];
if (tryMatch(/^鈍音$/)) return 鈍音組.includes(組);
if (tryMatch(/^銳音$/)) return !鈍音組.includes(組);
if (tryMatch(/^(.+?)([母等韻音攝組聲])$/)) {
const values = [...match[1]];
const check = 檢查[match[2]];
Expand Down