Skip to content

Commit

Permalink
Check 反切 & 釋義
Browse files Browse the repository at this point in the history
  • Loading branch information
syimyuzya committed Dec 26, 2024
1 parent be4a0ea commit 6c573c2
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions check.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
PATTERN_描述 = re.compile(
f'([{所有母}])([開合])?([{所有等}])([ABC])?([{所有韻}])([{所有聲}])'
)
PATTERN_反切 = re.compile(
r"""(?x)(
\[.\] | # 脫字
. ( <.> | ⦉.⦊ | \(.\) | ⦅.⦆ )* # 原貌及校正
){2}"""
)


def contains_ascii(s: str):
Expand All @@ -35,12 +41,16 @@ def contains_ascii(s: str):
釋義,
釋義補充,
) = line.rstrip('\n').split(',')

assert (
PATTERN_描述.fullmatch(音韻地位描述) is not None
), f'invalid 音韻地位: {音韻地位描述}'
# TODO 反切

if 反切:
assert PATTERN_反切.fullmatch(反切) is not None, f'invalid 反切: {反切}'
assert len(字頭) == 1, 'The length of 字頭 should be 1'

assert 釋義 + 釋義補充, '釋義 and 釋義補充 should not be both empty'
assert not contains_ascii(
釋義
), '釋義 should not contain any ASCII characters'
# TODO 釋義 should not be empty

0 comments on commit 6c573c2

Please sign in to comment.