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
1 change: 1 addition & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <file> <file>` 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`.

Expand Down
1 change: 1 addition & 0 deletions data/dictionary/TWPhrases.txt
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,7 @@ U盤 隨身碟
轉義字符 跳脫字元
通信 通訊
通訊卡 通話卡
通道 通道
通配符 萬用字元
連接 連線
連接器 聯結器
Expand Down
2 changes: 1 addition & 1 deletion data/dictionary/TWPhrasesRev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ SQL隱碼攻擊 SQL注入 SQL注入攻擊
通訊 通信
通話卡 通訊卡
通話記錄 聯繫歷史
通道 信道
通道 通道 信道
速食麵 方便麪
連結 鏈接
連結串列 鏈表
Expand Down
14 changes: 14 additions & 0 deletions test/testcases/testcases.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "算法",
Expand Down
Loading