Skip to content

Keep the Taiwan standard form 祕 in s2tw and s2twp - #1493

Merged
frankslin merged 2 commits into
BYVoid:masterfrom
pucedoteth:keep-mi-tw-standard-form
Sep 20, 2026
Merged

frankslin merged 2 commits into
BYVoid:masterfrom
pucedoteth:keep-mi-tw-standard-form

Conversation

@pucedoteth

Copy link
Copy Markdown
Contributor

Fixes #1490.

TWVariants.txt mapped 祕 -> 秘, which undid the STCharacters 秘 -> 祕 conversion later in the s2tw chain. The result was that s2t and s2tw disagreed on the same input:

$ opencc -c s2t.json   <<< "秘书 秘书长 神秘 秘密"
祕書 祕書長 神祕 祕密
$ opencc -c s2tw.json  <<< "秘书 秘书长 神秘 秘密"
秘書 秘書長 神秘 秘密      # ← the 祕 is undone

The Taiwan MOE dictionaries give 祕 as the standard form — 祕書, 祕書長 — so the Taiwan variant mapping is not needed, as @frankslin and @LeeiFrankJaw noted in the issue.

Change

One line removed from TWVariants.txt. TWVariantsRev is generated from it at build time, so the reverse direction follows automatically, and there were no 祕/秘 entries in TWVariantsPhrases.txt, TWVariantsRevPhrases.txt, TWPhrases.txt or TWPhrasesRev.txt to keep in sync.

HKVariants.txt keeps 祕 -> 秘 and is untouched, along with the four 祕書處 -> 秘書處 entries in HKVariantsPhrases.txt.

After:

s2t    祕書 祕書長 神祕 祕密
s2tw   祕書 祕書長 神祕 祕密
s2twp  祕書 祕書長 神祕 祕密
s2hk   秘書 秘書長 神秘 秘密     # unchanged

One behaviour change worth a look

TWVariantsRev previously normalised 秘 -> 祕, so tw2t and tw2s rewrote a Taiwan-side 秘. Both are now identity for that character:

tw2t  祕書 秘書  ->  祕書 秘書     (was 祕書 祕書)
tw2s  祕書 秘書  ->  秘书 秘书     (unchanged)

Since 祕 is the Taiwan standard, a 秘 in Taiwan input is already non-standard and leaving it alone seems right, but it is the one thing this removal changes beyond the reported bug. Happy to restore normalisation another way if you would rather keep it.

Tests

  • Three cases added to test/testcases/testcases.json covering s2t/s2tw/s2twp, the s2hk form, and t2tw identity.
  • Four golden outputs regenerated: s2tw, s2twp, s2tw_jieba, s2twp_jieba. Each differs from the old file by exactly three characters, all 秘 → 祕 — the US Constitution text has "秘書 威廉·傑克遜". s2t, s2t_jieba, s2hk, s2hkp, s2hk_jieba, s2hkp_jieba regenerate byte-identical.

Built with CMake (core plus the Jieba plugin, so the jieba goldens were regenerated rather than hand-edited) and ran every pair in testcases.json through the built CLI:

ran 567 case/config pairs, 0 failures

I could not run the Bazel suites — Bazel is not available in my environment — so //data/dictionary:... and the golden test targets have not been exercised here beyond the manual regeneration above.

AI disclosure

Written with AI assistance (Claude Code): the investigation, the change, the tests, and this description.

🤖 Generated with Claude Code

pucedoteth and others added 2 commits September 18, 2026 19:15
TWVariants mapped 祕 to 秘, undoing the STCharacters 秘 to 祕 conversion, so
s2tw produced 秘書 where s2t produced 祕書. The Taiwan MOE dictionaries give
祕書 as the standard form, so the mapping is dropped; the Hong Kong variant
keeps 秘 and is untouched.
Resolve the testcases.json conflict by keeping both the new Seal script cases from master and the 祕 cases from this branch.
@frankslin
frankslin merged commit e02cb54 into BYVoid:master Sep 20, 2026
40 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

s2tw 秘書 vs 祕書

2 participants