Skip to content

Commit

Permalink
Fix cumulative bugs and add features (#4)
Browse files Browse the repository at this point in the history
Co-authored-by: unt <unt_tianjin@163.com>
  • Loading branch information
ayaka14732 and untunt authored Apr 19, 2024
1 parent 15a6fff commit c724f09
Show file tree
Hide file tree
Showing 32 changed files with 1,122 additions and 523 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ on:

jobs:
build:
runs-on: windows-latest
strategy:
matrix:
os: [ windows-latest, ubuntu-latest ]
python-version: ['3.10', '3.11', '3.12']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -25,6 +26,8 @@ jobs:
python -m pip install -U pip
pip install -r requirements.txt
pip install build
- name: Test
run: python tests/test.py
- name: Install package
run: pip install .
- name: Install PyTest
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# qieyun-encoder-python
# Qieyun Encoder Python

A Python library for the operating the basic structure of the Qieyun phonological system

Expand All @@ -7,3 +7,12 @@ A Python library for the operating the basic structure of the Qieyun phonologica
```sh
$ pip install qieyun-encoder
```

## Usage

```python
import QieyunEncoder as QE
print(QE.音韻地位.from描述('幫三凡入').攝) # output: 咸
```

For detailed usage, see [documentation](https://qieyun-encoder-python.readthedocs.io).
22 changes: 12 additions & 10 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ Qieyun Encoder Python 說明文件
:maxdepth: 1

常量
轉換
音韻地位
韻鏡位置
工具


Expand Down Expand Up @@ -56,7 +58,7 @@ Qieyun Encoder Python 說明文件

不要與中古後期三十六字母混淆。

中古後期三十六字母:
中古後期三十六字母

.. raw:: html

Expand Down Expand Up @@ -91,14 +93,14 @@ Qieyun Encoder Python 說明文件

韻與開合的關係如下:

- 開合皆有的韻:支脂微齊祭泰佳皆夬廢眞元寒刪山仙先歌麻陽唐庚耕清青蒸登
- 開合兼備的韻:支脂微齊祭泰佳皆夬廢眞元寒刪山仙先歌麻陽唐庚耕清青蒸登
- 必爲開口的韻:咍痕欣嚴之魚臻蕭宵肴豪侯侵覃談鹽添咸銜
- 必爲合口的韻:灰魂文凡
- 開合中立的韻:東冬鍾江虞模尤幽

.. hint::

不要與韻圖的開合混淆
不要與韻鏡的開合混淆

以《韻鏡》爲例,開合有三種取值:開、合、開合。

Expand All @@ -124,9 +126,9 @@ Qieyun Encoder Python 說明文件

.. hint::

不要與韻圖的等混淆
不要與韻鏡的等混淆

- 韻圖將重紐 A 類字置於四等,實際爲三等
- 韻鏡將重紐 A 類字置於四等,實際爲三等
- 三等韻的莊組字列在二等
- 三等韻的精組字列在四等
- 三等的幽韻列在四等
Expand All @@ -151,10 +153,10 @@ Qieyun Encoder Python 說明文件
- 止攝:支脂之微
- 遇攝:魚虞模
- 蟹攝:齊佳皆灰咍祭泰夬廢
- 臻攝:眞諄臻文欣元魂痕
- 山攝:寒桓刪山先仙
- 臻攝:真臻文殷魂痕
- 山攝:元寒刪山先仙
- 效攝:蕭宵肴豪
- 果攝:歌戈
- 果攝:
- 假攝:麻
- 宕攝:唐陽
- 梗攝:庚耕清青
Expand All @@ -165,9 +167,9 @@ Qieyun Encoder Python 說明文件

.. hint::

元韻在臻攝而非山攝(註:下一版會改爲山攝)
不使用諄桓戈韻,分別併入真寒歌韻

《廣韻》沒有諄桓戈韻,分別併入眞寒歌韻。殷韻爲欣韻(註:下一版會改爲殷韻)
使用殷韻的名稱,不使用欣韻;使用真韻的寫法,不使用眞韻。但構造函式及 ``from描述`` 方法具備容錯功能,會執行自動轉換

^^
Expand Down
6 changes: 6 additions & 0 deletions docs/常量.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
QieyunEncoder.常量
==================

.. raw:: html

<style>
.property > .pre { white-space: pre-wrap }
</style>

.. automodule:: QieyunEncoder.常量
:members:
:undoc-members:
Expand Down
8 changes: 8 additions & 0 deletions docs/轉換.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
QieyunEncoder.轉換
==================

.. automodule:: QieyunEncoder.轉換
:imported-members:
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/韻鏡位置.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
QieyunEncoder.韻鏡位置
======================

.. automodule:: QieyunEncoder.韻鏡位置
:members:
:undoc-members:
:show-inheritance:
6 changes: 4 additions & 2 deletions src/QieyunEncoder/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-

from . import 常量
from .工具 import *
from .轉換 import *
from .音韻地位 import 音韻地位
from .工具 import 反切, 正則化韻
from .韻鏡位置 import 韻鏡位置

__version__ = '0.4.3'
__version__ = '0.5.0'
106 changes: 0 additions & 106 deletions src/QieyunEncoder/_拓展音韻屬性.py

This file was deleted.

43 changes: 43 additions & 0 deletions src/QieyunEncoder/_母對應的標準等.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding: utf-8 -*-

# 實際可能超出此範圍,即「無音有字」
母對應的標準等 = {
'幫': '一二三四',
'滂': '一二三四',
'並': '一二三四',
'明': '一二三四',
'端': '一四',
'透': '一四',
'定': '一四',
'泥': '一四',
'來': '一二三四',
'知': '二三',
'徹': '二三',
'澄': '二三',
'孃': '二三',
'精': '一三四',
'清': '一三四',
'從': '一三四',
'心': '一三四',
'邪': '三',
'莊': '二三',
'初': '二三',
'崇': '二三',
'生': '二三',
'俟': '三',
'章': '三',
'昌': '三',
'常': '三',
'書': '三',
'船': '三',
'日': '三',
'見': '一二三四',
'溪': '一二三四',
'羣': '三',
'疑': '一二三四',
'影': '一二三四',
'曉': '一二三四',
'匣': '一二四',
'云': '三',
'以': '三',
}
8 changes: 3 additions & 5 deletions src/QieyunEncoder/工具/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# -*- coding: utf-8 -*-

'''
與切韻音系相關的工具。
'''

from .反切 import 反切
from .正則化韻 import 正則化韻
from .音韻地位到韻鏡位置 import 音韻地位到韻鏡位置
from .音韻屬性到韻鏡位置們 import 音韻屬性到韻鏡位置們
from .韻鏡位置到音韻地位 import 韻鏡位置到音韻地位
13 changes: 3 additions & 10 deletions src/QieyunEncoder/工具/反切.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
# -*- coding: utf-8 -*-

'''
根據反切規律自動完成反切過程。
'''

from typing import List
from .. import 常量
from .._母對應的標準等 import 母對應的標準等
from ..音韻地位 import 音韻地位
from .._拓展音韻屬性 import 母到標準等


def _jointer(xs: List[str]):
def _jointer(xs: list[str]):
'''
將多個字串以頓號和「或」字連接。
Expand All @@ -25,7 +19,6 @@ def _jointer(xs: List[str]):
'''
return ''.join(x + '、' for x in xs[:-2]) + '或'.join(xs[-2:])


def 反切(上字音韻地位: 音韻地位, 下字音韻地位: 音韻地位, 顯示步驟=False, 類隔切=False):
'''
根據反切規律自動完成反切過程。
Expand Down Expand Up @@ -139,7 +132,7 @@ def 反切(上字音韻地位: 音韻地位, 下字音韻地位: 音韻地位,

# 母對等的約束

標準等 = 母到標準等[]
標準等 = 母對應的標準等[]
if any(等1 not in 標準等 for 等1 in ):
= ''.join(等1 for 等1 in if 等1 in 標準等)
步驟.append(f'{}母只能爲{標準等}等')
Expand Down
Loading

0 comments on commit c724f09

Please sign in to comment.