Skip to content

Commit

Permalink
改善反切查讀音未做例外處理問題
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJui committed Nov 5, 2024
1 parent 2e44a3b commit b6d8db0
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
"program": "a320_廣韻_反切查標音.py",
"console": "integratedTerminal",
"args": [
"烏候"
"余呂"
]
},
{
Expand Down
Binary file modified Ho_Lok_Ue.db
Binary file not shown.
Binary file modified Kong_Un.db
Binary file not shown.
13 changes: 11 additions & 2 deletions a320_廣韻_反切查標音.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
print("反切用的切語,必須有兩個漢字!")
sys.exit(-1)

siong_ji, han_ji = ciat_gu[0], ciat_gu[1]
siong_ji, ha_ji = ciat_gu[0], ciat_gu[1]

# 建立資料庫連線
connection = sqlite3.connect('Kong_Un.db')
Expand All @@ -36,6 +36,10 @@
os.system('cls')

切語上字 = han_ji_ca_piau_im(cursor, siong_ji)
if not 切語上字:
print(f"切語上字:【{siong_ji}】找不到,無法反切出讀音!")
sys.exit(-1)

for record in 切語上字:
切語上字 = record["漢字"]

Expand All @@ -60,7 +64,12 @@
print(f"聲母:{聲母} [{聲母標音}],國際音標:/{聲母國際音標}/,方音符號:{聲母方音符號}")
print(f"(發音部位:{七聲類},清濁:{清濁},發送收:{發送收})")

切語下字 = han_ji_ca_piau_im(cursor, han_ji)
切語下字 = han_ji_ca_piau_im(cursor, ha_ji)
if not 切語下字:
print('\n---------------------------------------')
print(f"切語下字:【{ha_ji}】找不到,無法反切出讀音!")
sys.exit(-1)

for record in 切語下字:
切語下字 = record["漢字"]

Expand Down
10 changes: 7 additions & 3 deletions a701_作業中活頁檔填入漢字.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import xlwings as xw

from p709_reset_han_ji_cells import reset_han_ji_cells
from p710_thiam_han_ji import fill_hanji_in_cells

# =========================================================================
Expand Down Expand Up @@ -34,8 +35,11 @@
print("無法執行,可能原因:(1) 未指定輸入檔案;(2) 未找到作用中的 Excel 工作簿")
sys.exit(2)

# 將待注音的【漢字儲存格】,文字顏色重設為黑色(自動 RGB: 0, 0, 0);填漢顏色重設為無填滿
reset_han_ji_cells(wb)

# 將待注音的漢字填入
fill_hanji_in_cells(wb)
fill_hanji_in_cells(wb)

# 將檔案存放路徑設為【專案根目錄】之下
try:
Expand All @@ -49,9 +53,9 @@
).strip()

# 設定檔案輸出路徑,存於專案根目錄下的 output2 資料夾
output_path = wb.names['OUTPUT_PATH'].refers_to_range.value
output_path = wb.names['OUTPUT_PATH'].refers_to_range.value
new_file_path = os.path.join(
".\\{0}".format(output_path),
".\\{0}".format(output_path),
f"【河洛話注音】{file_name}.xlsx")

# 儲存新建立的工作簿
Expand Down
2 changes: 1 addition & 1 deletion a709_重置漢字儲存格用色.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
print("無法執行,可能原因:(1) 未指定輸入檔案;(2) 未找到作用中的 Excel 工作簿")
sys.exit(2)

# 將待注音的漢字填入
# 將待注音的【漢字儲存格】,文字顏色重設為黑色(自動 RGB: 0, 0, 0);填漢顏色重設為無填滿
reset_han_ji_cells(wb)

# 將檔案存放路徑設為【專案根目錄】之下
Expand Down
Binary file not shown.

0 comments on commit b6d8db0

Please sign in to comment.