Skip to content
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
3 changes: 3 additions & 0 deletions .github/workflows/continuous-build-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ jobs:
build:
name: Build phrase database
runs-on: ubuntu-latest
env:
LANG: en_US.UTF-8
LC_ALL: en_US.UTF-8
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
Expand Down
2 changes: 2 additions & 0 deletions Source/Data/BPMFBase.txt
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,8 @@
臏 ㄅㄧㄣˋ bin4 1up4 big5
髕 ㄅㄧㄣˋ bin4 1up4 big5
鶣 ㄅㄧㄣˋ bin4 1up4 big5
𰻞 ㄅㄧㄤˊ biang2 11u;6 utf8
𰻝 ㄅㄧㄤˊ biang2 11u;6 utf8
ㄉ ㄉ d 2 big5
都 ㄉㄡ dou 2. big5
兜 ㄉㄡ dou 2. big5
Expand Down
1 change: 1 addition & 0 deletions Source/Data/BPMFMappings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144962,3 +144962,4 @@
龜鑑 ㄍㄨㄟ ㄐㄧㄢˋ
龜頭 ㄍㄨㄟ ㄊㄡˊ
龜鱉目 ㄍㄨㄟ ㄅㄧㄝ ㄇㄨˋ
𰻞𰻞麵 ㄅㄧㄤˊ ㄅㄧㄤˊ ㄇㄧㄢˋ
5 changes: 1 addition & 4 deletions Source/Data/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,7 @@ sort:
check: SHELL:=/bin/bash
check: export LC_ALL=C
check:
@awk 'length($$1)/3!=NF-1' BPMFMappings.txt
@awk '{print $$2,$$3,$$4,$$5,$$6,$$7}' BPMFMappings.txt | awk '/一/'
@diff -u <(awk '{print $$1}' BPMFMappings.txt|sort -u) \
<(awk 'length($$1)>4{print $$1}' phrase.occ|sort -u)
@python3 scripts/check.py

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But if check.py finds anything incorrect, does it end the program with a non-0 exit code?


tidy:
@sed -i '' -e 's/ //g' phrase.occ
Expand Down
3 changes: 3 additions & 0 deletions Source/Data/phrase.occ
Original file line number Diff line number Diff line change
Expand Up @@ -152591,3 +152591,6 @@
嗀 0
𡻈 0
𢻯 0
𰻝 0
𰻞 0
𰻞𰻞麵 0
63 changes: 63 additions & 0 deletions Source/Data/scripts/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
def check_if_bpmf_mappings_matches():
issues = []
with open("BPMFMappings.txt", encoding="utf-8") as f:
for line in f:
components = line.strip().split(" ")
first = components[0]
if len(first) != len(components) - 1:
issues.append(f"Length mismatch: {line.strip()}")
return issues

def check_if_readings_in_bpmf_mappings_contains_non_bpmf():
issues = []
bpmf = (
"ㄅㄆㄇㄈㄉㄊㄋㄌㄍㄎㄏㄐㄑㄒㄓㄔㄕㄖㄗㄘㄙㄚㄛㄜㄝㄞㄟㄠㄡㄢㄣㄤㄥㄦㄧㄨㄩˊˇˋ˙"
)
with open("BPMFMappings.txt", encoding="utf-8") as f:
for line in f:
components = line.strip().split()[1:]
for c in components:
if any(char not in bpmf for char in c):
issues.append(f"Non bpmf {c} in {line.strip()}")
break
return issues

def compare_bpmf_mappings_with_phrase_occ():
issues = []
bpmf_mappings_phrases = set()
phrase_occ_phrases = set()
with open("BPMFMappings.txt", encoding="utf-8") as f:
for line in f:
components = line.strip().split(" ")
first = components[0]
if len(first) > 1:
bpmf_mappings_phrases.add(first)
with open("phrase.occ", encoding="utf-8") as f:
for line in f:
components = line.strip().split(" ")
first = components[0]
if len(first) > 1:
phrase_occ_phrases.add(first)
missing_in_phrase_occ = bpmf_mappings_phrases - phrase_occ_phrases
missing_in_bpmf_mappings = phrase_occ_phrases - bpmf_mappings_phrases
if missing_in_phrase_occ:
issues.append(f"Missing in phrase.occ: {missing_in_phrase_occ}")
if missing_in_bpmf_mappings:
issues.append(f"Missing in BPMFMappings.txt: {missing_in_bpmf_mappings}")
return issues


def main():
all_issues = []
all_issues.extend(check_if_bpmf_mappings_matches())
all_issues.extend(check_if_readings_in_bpmf_mappings_contains_non_bpmf())
all_issues.extend(compare_bpmf_mappings_with_phrase_occ())

for issue in all_issues:
print(issue)

if all_issues:
raise RuntimeError(f"Data check failed with {len(all_issues)} issue(s).")

if __name__ == "__main__":
main()
Loading