Skip to content

Commit c198b5f

Browse files
committed
Extend zh-tw vocab guard with 24 more S-Chinese loan-word patterns
Each pattern uses Traditional characters but is Simplified-Chinese vocabulary — a plain T-vs-S character pass cannot catch them. Hardware: 硬件 → 硬體 主板 → 主機板 顯卡 → 顯示卡 硬盤 → 硬碟 軟盤 → 軟碟 光盤 → 光碟 Printing / I/O: 打印 / 打印機 → 列印 / 印表機 串口 → 序列埠 Crypto / data: 密鑰 → 金鑰 數組 → 陣列 變量 → 變數 (excludes `不變量` = invariant via negative-lookbehind; `不變量` is the math / formal-verification term and is accepted in TW) 字節 → 位元組 比特 → 位元 (excludes `比特幣` = bitcoin via negative-lookahead; the bitcoin loan word is accepted in TW) Code / async: 注釋 → 註解 / 註釋 模板 → 範本 跟蹤 → 追蹤 異步 → 非同步 UI / display / media: 圖標 → 圖示 高清 → 高畫質 寬屏 → 寬螢幕 信道 → 通道 / 頻道 鏡像文件 → 映像檔 文件夾 → 資料夾 短信 → 簡訊 Caught one real offender in scripts/regen_llm_security_batch_zh_tw.py: "讓 origin-entity 不變量明確化…" was OK (math invariant); a separate `…的變量資訊化…` line WAS S-Chinese drift and is fixed to `變數`. .claude/agents/language-vocabulary-check.md table now mirrors the 24 additions so future LLM sessions get the same lexicon when they read the agent doc instead of the regex set. 510/510 tests pass.
1 parent 2a3f84d commit c198b5f

2 files changed

Lines changed: 59 additions & 0 deletions

File tree

.claude/agents/language-vocabulary-check.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,30 @@ A simplified-vs-traditional character checker WILL NOT catch them.
7171
| 注釋 | 註解 | comment / annotation |
7272
| 信號 | 訊號 | signal |
7373
| 互信息 | 互資訊 | mutual information |
74+
| 硬件 | 硬體 | hardware |
75+
| 主板 | 主機板 | motherboard |
76+
| 顯卡 | 顯示卡 | graphics card |
77+
| 硬盤 | 硬碟 | hard disk |
78+
| 軟盤 | 軟碟 | floppy disk |
79+
| 光盤 | 光碟 | optical disc |
80+
| 打印 / 打印機 | 列印 / 印表機 | print(er) |
81+
| 密鑰 | 金鑰 | crypto key |
82+
| 數組 | 陣列 | array |
83+
| 變量 (≠ 不變量) | 變數 | variable (`不變量` = invariant is fine in TW) |
84+
| 字節 | 位元組 | byte |
85+
| 比特 (≠ 比特幣) | 位元 | bit (`比特幣` = bitcoin is accepted in TW) |
86+
| 注釋 | 註解 / 註釋 | comment / annotation (the form starting with `` is S; TW uses ``) |
87+
| 模板 | 範本 | template |
88+
| 跟蹤 | 追蹤 | track / trace |
89+
| 異步 | 非同步 | async |
90+
| 串口 | 序列埠 | serial port |
91+
| 圖標 | 圖示 | icon |
92+
| 高清 | 高畫質 | high definition |
93+
| 寬屏 | 寬螢幕 | widescreen |
94+
| 信道 | 通道 / 頻道 | channel |
95+
| 鏡像文件 | 映像檔 | disk image |
96+
| 文件夾 | 資料夾 | folder |
97+
| 短信 | 簡訊 | SMS / text message |
7498

7599
### Simplified Chinese (zh-cn) — avoid Traditional vocabulary
76100

tests/test_i18n.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,41 @@ def test_zh_tw_files_use_traditional_chinese_vocabulary():
247247
(re.compile(r"對話框"), "對話框 → 對話方塊"),
248248
(re.compile(r"句柄"), "句柄 → 控制代碼"),
249249
(re.compile(r"(?<![異])異常(?![案的快只新終難艱])"), "異常 → 例外"),
250+
# Hardware vocabulary — Traditional chars, Simplified words.
251+
(re.compile(r"硬件"), "硬件 → 硬體"),
252+
(re.compile(r"主板"), "主板 → 主機板"),
253+
(re.compile(r"顯卡"), "顯卡 → 顯示卡"),
254+
(re.compile(r"硬盤"), "硬盤 → 硬碟"),
255+
(re.compile(r"軟盤"), "軟盤 → 軟碟"),
256+
(re.compile(r"光盤"), "光盤 → 光碟"),
257+
# Printing / output devices.
258+
(re.compile(r"打印"), "打印(機) → 列印(機 → 印表機)"),
259+
# Crypto / data structures / variables.
260+
(re.compile(r"密鑰"), "密鑰 → 金鑰"),
261+
(re.compile(r"數組"), "數組 → 陣列"),
262+
# `不變量` (invariant, math / formal-verification context) is
263+
# accepted in TW, so exclude it. Bare `變量` (= variable) is S-only.
264+
(re.compile(r"(?<![不])變量"), "變量 → 變數"),
265+
(re.compile(r"字節"), "字節 → 位元組 (or just 'byte')"),
266+
# `比特` IS legit inside `比特幣` (bitcoin, accepted in TW), so
267+
# exclude that one compound with a negative-lookahead.
268+
(re.compile(r"比特(?!幣)"), "比特 → 位元 (or just 'bit')"),
269+
# Comments / templates / tracking / async.
270+
(re.compile(r"注釋"), "注釋 → 註解 (or 註釋 with 註)"),
271+
(re.compile(r"模板"), "模板 → 範本"),
272+
(re.compile(r"跟蹤"), "跟蹤 → 追蹤"),
273+
(re.compile(r"異步"), "異步 → 非同步"),
274+
# Ports + UI elements.
275+
(re.compile(r"串口"), "串口 → 序列埠"),
276+
(re.compile(r"圖標"), "圖標 → 圖示"),
277+
# Display / media.
278+
(re.compile(r"高清"), "高清 → 高畫質"),
279+
(re.compile(r"寬屏"), "寬屏 → 寬螢幕"),
280+
# Filesystem / messaging.
281+
(re.compile(r"信道"), "信道 → 通道 / 頻道"),
282+
(re.compile(r"鏡像文件"), "鏡像文件 → 映像檔"),
283+
(re.compile(r"文件夾"), "文件夾 → 資料夾"),
284+
(re.compile(r"短信"), "短信 → 簡訊"),
250285
]
251286
zh_tw_paths = [
252287
_REPO_ROOT / "scripts" / "regen_llm_security_batch_zh_tw.py",

0 commit comments

Comments
 (0)