Skip to content

Commit

Permalink
改善作業的處理細節。
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJui committed Oct 13, 2024
1 parent cb01070 commit c8d2319
Show file tree
Hide file tree
Showing 11 changed files with 911 additions and 30 deletions.
Binary file modified Tai_Loo_Han_Ji_Khoo.db
Binary file not shown.
14 changes: 1 addition & 13 deletions a702_查找及填入漢字標音.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,10 @@

import xlwings as xw

from mod_台羅音標漢字庫 import get_sound_type
from p702_Ca_Han_Ji_Thak_Im import ca_han_ji_thak_im
from p730_Tng_Sing_Bang_Iah import tng_sing_bang_iah


# ==========================================================
# 查詢語音類型,若未設定則預設為文讀音
# ==========================================================
def get_sound_type(wb):
try:
reading_type = wb.names['語音類型'].refers_to_range.value
except KeyError:
reading_type = "文讀音"
return reading_type


# 指定虛擬環境的 Python 路徑
venv_python = os.path.join(".venv", "Scripts", "python.exe") if sys.platform == "win32" else os.path.join(".venv", "bin", "python")

Expand Down Expand Up @@ -48,7 +37,6 @@ def get_sound_type(wb):
sheet.range('A1').select() # 將 A1 儲存格設為作用儲存格

# (2) A731: 自動為漢字查找讀音,並抄寫到漢字的上方(拼音)及下方(注音)。
# type = '白話音'
type = get_sound_type(wb)
ca_han_ji_thak_im(wb, '漢字注音', 'V3', type)

Expand Down
30 changes: 14 additions & 16 deletions a704_批次式查找及填入漢字標音.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,17 @@

import xlwings as xw

from mod_台羅音標漢字庫 import get_sound_type
from p702_Ca_Han_Ji_Thak_Im import ca_han_ji_thak_im
from p710_thiam_han_ji import fill_hanji_in_cells
from p730_Tng_Sing_Bang_Iah import tng_sing_bang_iah


# ==========================================================
# 自動補上 Excel 檔案的副檔名 .xlsx (單個檔案處理)
# ==========================================================
def ensure_xlsx_extension(file_name):
return file_name if file_name.lower().endswith('.xlsx') else file_name + '.xlsx'

# 指定虛擬環境的 Python 路徑
venv_python = os.path.join(".venv", "Scripts", "python.exe") if sys.platform == "win32" else os.path.join(".venv", "bin", "python")

Expand All @@ -15,24 +22,14 @@

# 所有檔案名稱
files = [
"【河洛話注音】金剛般若波羅蜜經001。法會因由分第一.xlsx",
"【河洛話注音】金剛般若波羅蜜經002。善現啟請分第二.xlsx",
"【河洛話注音】金剛般若波羅蜜經003。大乘正宗分第三.xlsx",
"【河洛話注音】金剛般若波羅蜜經004。妙行無住分第四.xlsx",
"【河洛話注音】金剛般若波羅蜜經005。如理實見分第五.xlsx",
"【河洛話注音】金剛般若波羅蜜經006。正信希有分第六.xlsx",
"【河洛話注音】金剛般若波羅蜜經007。無得無說分第七.xlsx",
"【河洛話注音】金剛般若波羅蜜經008。依法出生分第八.xlsx",
"【河洛話注音】金剛般若波羅蜜經009。一相無相分第九.xlsx",
"【河洛話注音】金剛般若波羅蜜經010。莊嚴淨土分第十.xlsx",
"【河洛話注音】金剛般若波羅蜜經011。無為福勝分第十一.xlsx",
"【河洛話注音】金剛般若波羅蜜經012。尊重正教分第十二.xlsx",
"【河洛話注音】金剛般若波羅蜜經013。如法受持分第十三.xlsx"
"【河洛話注音】桃花源記【白話音】",
# "【河洛話注音】桃花源記【文讀音】",
]

# 迴圈遍歷所有檔案並依次執行 Python 檔案
for file_name in files:
file_path = os.path.join(directory, file_name)
updated_file_name = ensure_xlsx_extension(file_name)
file_path = os.path.join(directory, updated_file_name)

# 打開 Excel 檔案
wb = xw.Book(file_path)
Expand All @@ -45,7 +42,8 @@
# fill_hanji_in_cells(wb)

# (2) A731: 自動為漢字查找讀音,並抄寫到漢字的上方(拼音)及下方(注音)。
ca_han_ji_thak_im(wb, '漢字注音', 'V3')
type = get_sound_type(wb)
ca_han_ji_thak_im(wb, '漢字注音', 'V3', type)

# (3) A740: 將【漢字注音】工作表的內容,轉成 HTML 網頁檔案。
tng_sing_bang_iah(wb, '漢字注音', 'V3')
Expand Down
2 changes: 1 addition & 1 deletion docs/assets/styles/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
body {
/* width: 100%; */
margin: 0 auto;
width: 100%;
width: 95%;
color: #333;
line-height: 2.0;
font-size: 28pt;
Expand Down
Loading

0 comments on commit c8d2319

Please sign in to comment.