From 9c65a896ccdd96cdffe747e97809a4a2e52764d3 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Sun, 7 Jun 2026 11:51:58 -0700 Subject: [PATCH 1/2] =?UTF-8?q?=E5=B0=86=20s2twp=20=E3=80=8C=E4=BF=A1?= =?UTF-8?q?=E9=81=93=20->=20=E9=80=9A=E9=81=93=E3=80=8D=E6=94=B9=E4=B8=BA?= =?UTF-8?q?=E5=8D=95=E5=90=91=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/dictionary/TWPhrases.txt | 1 + data/dictionary/TWPhrasesRev.txt | 2 +- test/testcases/testcases.json | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/data/dictionary/TWPhrases.txt b/data/dictionary/TWPhrases.txt index 5d04c7df6..7d63eebb7 100644 --- a/data/dictionary/TWPhrases.txt +++ b/data/dictionary/TWPhrases.txt @@ -596,6 +596,7 @@ U盤 隨身碟 轉義字符 跳脫字元 通信 通訊 通訊卡 通話卡 +通道 通道 通配符 萬用字元 連接 連線 連接器 聯結器 diff --git a/data/dictionary/TWPhrasesRev.txt b/data/dictionary/TWPhrasesRev.txt index 4fb9685d2..d2f5a5e1e 100644 --- a/data/dictionary/TWPhrasesRev.txt +++ b/data/dictionary/TWPhrasesRev.txt @@ -594,7 +594,7 @@ SQL隱碼攻擊 SQL注入 SQL注入攻擊 通訊 通信 通話卡 通訊卡 通話記錄 聯繫歷史 -通道 信道 +通道 通道 信道 速食麵 方便麪 連結 鏈接 連結串列 鏈表 diff --git a/test/testcases/testcases.json b/test/testcases/testcases.json index b0378fec1..c5d60fc8b 100755 --- a/test/testcases/testcases.json +++ b/test/testcases/testcases.json @@ -379,6 +379,20 @@ "t2s": "写一个解算器程式来解决方程式" } }, + { + "id": "BYVoid_OpenCC_PR_1291_s2twp", + "input": "现代无线通信技术可以通过无线信道进行高速传输,不受电缆束缚", + "expected": { + "s2twp": "現代無線通訊技術可以通過無線通道進行高速傳輸,不受電纜束縛" + } + }, + { + "id": "BYVoid_OpenCC_PR_1291_tw2sp", + "input": "現代無線通訊技術可以透過無線通道進行高速傳輸,不受電纜束縛", + "expected": { + "tw2sp": "现代无线通信技术可以透过无线通道进行高速传输,不受电缆束缚" + } + }, { "id": "ByVoid_OpenCC_Issue950_AlgorithmConversion", "input": "算法", From ad9d0812bc99dabbf944683e363befe9644eab73 Mon Sep 17 00:00:00 2001 From: Frank Lin Date: Sun, 7 Jun 2026 12:00:00 -0700 Subject: [PATCH 2/2] Document one-way Taiwan phrase mappings --- AGENTS.md | 1 + 1 file changed, 1 insertion(+) diff --git a/AGENTS.md b/AGENTS.md index 5381cbd8f..a528fc4a0 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -18,6 +18,7 @@ This document compiles the Open Chinese Convert (OpenCC) project information to - Reserve `TWVariantsPhrases.txt` for phrase-level exceptions to Taiwan variant character conversion, especially when a phrase must override character-level mappings from `TWVariants.txt`. It is part of `s2tw`, `s2twp`, and `t2tw`; using it for vocabulary translations will incorrectly affect `s2tw`. - For `s2twp`, remember the conversion chain is `STPhrases/STCharacters -> TWPhrases -> TWVariantsPhrases/TWVariants`. If a Simplified input phrase must be matched later by `TWPhrases`, add a necessary Simplified-to-Traditional segmentation entry to `STPhrases.txt`; otherwise the phrase can be split before the Taiwan vocabulary stage. - Keep `TWPhrases.txt` and `TWPhrasesRev.txt` bidirectionally consistent. Run `bazel test //data/dictionary:dictionary_TWPhrases_reverse_mapping_test` after editing either file. +- For intentional one-way Taiwan vocabulary conversions, keep the forward mapping in `TWPhrases.txt` and add a self-mapping candidate on both sides so `tw2sp` can preserve the Taiwan term. For example, to make `s2twp` convert `信道 -> 通道` without forcing `tw2sp` to convert every `通道` back to `信道`, use `信道 -> 通道` plus `通道 -> 通道` in `TWPhrases.txt`, and make `TWPhrasesRev.txt` map `通道 -> 通道 信道`. The self-mapping keeps the reverse dictionary structurally consistent while making the reverse conversion prefer unchanged `通道`. - Use `python3 data/scripts/sort.py ` for edited dictionary files instead of hand-sorting. Dictionary tests enforce sorted unique keys. - Add tests to `test/testcases/testcases.json` against the config that actually uses the dictionary. Taiwan vocabulary in `TWPhrases.txt` should normally be tested with `s2twp` / `tw2sp`, not `s2tw`.