Skip to content

s2twp/tw2sp: stop converting ambiguous general words by default, keep technical collocations - #1432

Closed
stantheman0128 wants to merge 8 commits into
BYVoid:masterfrom
stantheman0128:fix/s2twp-dictionary
Closed

stantheman0128 wants to merge 8 commits into
BYVoid:masterfrom
stantheman0128:fix/s2twp-dictionary

Conversation

@stantheman0128

Copy link
Copy Markdown
Contributor

Closes #1313.

Problem

s2twp and tw2sp convert several general words unconditionally, which corrupts ordinary non technical text. Reproduced with the dictionaries at current master:

s2twp: 法律程序 -> 法律程式    历史进程 -> 歷史程序    政府文件 -> 政府檔案
       住宅社区 -> 住宅社群    设置路障 -> 設定路障    高级餐厅 -> 高階餐廳
       列车运行 -> 列車執行    支持候选人 -> 支援候選人
tw2sp: 執行判決 -> 运行判决    法律程序 -> 法律进程    個人資料 -> 个人数据
       歷史檔案 -> 历史文件    社群媒體 -> 社区媒体    遊戲設定 -> 游戏设置

Issue #1313 covers eight word groups (程序/進程/程式, 文件/文檔/檔案, 資料/數據, 社區/社群, 設定/設置/預設, 高級/高階/進階, 執行/運行, 支持/支援) and recommends dropping the generic conversions while keeping semantically stable collocations. 預設 needed no dictionary change; 預設值 and 預設選項 already convert correctly and are now covered by tests.

Change

Each generic mapping keeps the source word as the default candidate and the old conversion as a non default alternative, per the rule in CONTRIBUTING.md (改為非預設候選, A -> A B) and the precedent of #1423. For example 程序 -> 程序 程式 and 支持 -> 支持 支援 in TWPhrases.txt. TWPhrasesRev.txt receives the mirrored updates, including the self mapping candidates described in the repo docs, so the forward and reverse dictionaries stay closed under the reverse mapping test.

So that technical text keeps converting well, stable noun collocations are added explicitly (checked against doc/regional-phrase-criteria.md): 應用程序, 驅動程序, 小程序, 電腦程序, 計算機程序 and 程序設計 to their 程式 forms; 文件系統/檔案系統; 數據結構, 數據中心, 數據集 and 個人數據 to their 資料 forms (Taiwan standard usage, as in 個人資料保護法); 技術支持 -> 技術支援; 系統設置 and 偏好設置 -> 設定 forms; 高級語言 -> 高階語言; 社交媒體 -> 社群媒體; 社交網站 -> 社群網站; 社區版 -> 社群版 (software edition, as in MySQL 社群版); 開源社區/開源社群. Existing entries such as 數據庫, 文件夾, 高級設置, 執行緒, 支持者 and the 程序正義 protections are unchanged.

Test changes:

  • 16 new cases (BYVoid_OpenCC_Issue_1313_*) pin the intended behavior for all eight groups in both directions.
  • variants_tw_s2twp and variants_tw_tw2sp asserted the generic 社區/社群 swap and were updated to the new defaults.
  • BYVoid_OpenCC_Issue_475_mixed_script_input: the mixed script token 数据庫 previously came out as 資料庫 only because 數據 -> 資料 fired inside the segment boundary 数据|庫. It now stays 數據庫. The pure script inputs 数据库 and 數據庫 in the same case still convert to 資料庫.

The work is split into one commit per word group; every commit keeps both dictionaries sorted (data/scripts/sort.py) and the forward/reverse mapping closed.

Verification

I had no C++ toolchain available, so I verified with the OpenCC 1.4.1 wheel engine driving this branch's text dictionaries directly: config JSONs identical to data/config/*.json with ocd2 references switched to text, and TSCharactersExt, the *Rev variant dictionaries and STPhrases_GeneratedFromRegionalPhrases regenerated with the repo's own scripts. The generator run also confirms the new TWPhrases keys introduce no conflicting simplified projections. There are no conversion related engine changes between ver.1.4.1 and master, and the same harness reproduces master exactly:

all testcases.json expectations, master dictionaries:    512/512 passed
all testcases.json expectations, this branch:            528/528 passed
reverse mapping closure (DictionaryReverseMappingTest port): MISSING = 0
sort.py idempotence on TWPhrases.txt / TWPhrasesRev.txt:  no diff
generator conflict gate (generate_st_phrases_from_regional_phrases.py): pass

Sample before/after from the harness (base = master, mod = this branch):

s2twp  法律程序      base=法律程式      mod=法律程序
s2twp  操作系统进程  base=作業系統程序  mod=作業系統進程
s2twp  应用程序      base=應用程式      mod=應用程式
s2twp  驱动程序      base=驅動程式      mod=驅動程式
s2twp  政府文件      base=政府檔案      mod=政府文件
s2twp  文件系统      base=檔案系統      mod=檔案系統
s2twp  统计数据      base=統計資料      mod=統計數據
s2twp  数据库        base=資料庫        mod=資料庫
s2twp  住宅社区      base=住宅社群      mod=住宅社區
s2twp  社交媒体      base=社交媒體      mod=社群媒體
s2twp  设置路障      base=設定路障      mod=設置路障
s2twp  系统设置      base=系統設定      mod=系統設定
s2twp  高级餐厅      base=高階餐廳      mod=高級餐廳
s2twp  高级语言      base=高階語言      mod=高階語言
s2twp  列车运行      base=列車執行      mod=列車運行
s2twp  支持候选人    base=支援候選人    mod=支持候選人
s2twp  技术支持      base=技術支援      mod=技術支援
tw2sp  執行判決      base=运行判决      mod=执行判决
tw2sp  法律程序      base=法律进程      mod=法律程序
tw2sp  個人資料      base=个人数据      mod=个人资料
tw2sp  歷史檔案      base=历史文件      mod=历史档案
tw2sp  資料庫        base=数据库        mod=数据库
tw2sp  社群媒體      base=社区媒体      mod=社交媒体
tw2sp  遊戲設定      base=游戏设置      mod=游戏设定
tw2sp  技術支援      base=技术支持      mod=技术支持

Please treat the CI Bazel dictionary tests as the authoritative check.

This fix was developed with AI assistance (Claude Code) and verified locally as shown above.

stantheman0128 and others added 8 commits July 17, 2026 12:12
「程序」在法律、行政語境是兩岸通用詞(法律程序、審批程序),不應因
技術語境預設轉成「程式」;「進程」(歷史進程、作業系統進程)同理。
依 CONTRIBUTING.md 字級規則改為非預設候選(程序 -> 程序 程式),並
補充語義穩定的技術詞組:應用程序、驅動程序、小程序、電腦程序、
計算機程序、程序設計 -> 程式系詞彙,維持既有技術文本的轉換品質。
TWPhrasesRev 同步更新以保持雙向映射封閉。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「文件」在兩岸都可指公文、資料(政府文件、機密文件),不應預設轉成
「檔案」;「檔案」也可指 archives(歷史檔案、人事檔案),簡體「档案」
同樣通行,不應一律轉成「文件」。改為非預設候選,保留語義穩定的固定
搭配:文件夾、文件名、文件擴展名(既有)與新增的文件系統 -> 檔案系統。
TWPhrasesRev 同步更新以保持雙向映射封閉。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「資料」可指材料、參考內容(個人資料、參考資料、報名資料),不應
預設轉成「數據」;「統計數據」「實驗數據」「大數據」在臺灣正體也
以「數據」通行,不應預設轉成「資料」。改為非預設候選,保留既有的
數據庫、數據倉庫、數據挖掘、數據源等固定搭配,並補充數據結構、
數據中心、數據集、個人數據 -> 資料系詞彙(臺灣標準用語,如個資法
之「個人資料」)。

BYVoid_OpenCC_Issue_475_mixed_script_input 中混寫輸入「数据庫」原經
「數據 -> 資料」湊出「資料庫」;分詞在簡體詞邊界切為「数据|庫」,
現「數據」預設保留自身,輸出改為同樣正確的「數據庫」。純簡體
「数据库」與純繁體「數據庫」仍轉為「資料庫」。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「社區」指實體居住區(住宅社區、社區服務、社區醫院),臺灣正體
同樣通行,不應預設轉成「社群」;「社群」指網路、興趣群體,也不應
一律轉回「社區」。改為非預設候選,新增語義穩定的固定搭配:
開源社區 -> 開源社群、社交媒體 -> 社群媒體、社交網站 -> 社群網站、
社區版 -> 社群版(軟體版本名,如 MySQL 社群版),反向對應收入
TWPhrasesRev。variants_tw_s2twp / variants_tw_tw2sp 原斷言通用互轉,
隨預設行為更新。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「設置」可指設立、安裝(設置路障、設置機構),兩岸通用,不應預設
轉成「設定」;「設定」在臺灣另有故事設定、遊戲設定等用法,反向
也不應一律轉成「設置」。改為非預設候選,UI 語境保留既有的
高級設置 -> 進階設定,並新增系統設置 -> 系統設定、
偏好設置 -> 偏好設定。TWPhrasesRev 同步更新以保持雙向映射封閉。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「高級」是通用等級形容詞(高級餐廳、高級住宅、高級會員、高級中學),
臺灣正體同樣通行,不應預設轉成「高階」。改為非預設候選,保留既有的
高級設置 -> 進階設定、高級選項 -> 進階選項 與 高端 -> 高階,並新增
術語化詞組 高級語言 -> 高階語言(程式語言分級)。TWPhrasesRev 同步
收入 高階語言 -> 高級語言。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「執行」可指法律、命令、任務(執行判決、執行任務),兩岸通用,
tw2sp 不應預設轉成「運行」;「運行」指系統、列車持續運轉(系統運行、
列車運行),s2twp 也不應預設轉成「執行」。改為非預設候選,保留既有
邊界清楚的執行緒、執行檔等詞組。TWPhrasesRev 同步更新以保持雙向
映射封閉。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
「支持」可指贊成、擁護、資助(支持候選人、財政支持、支持率),
臺灣正體同樣通行,不應預設轉成「支援」。改為非預設候選,收錄語義
穩定的名詞詞組 技術支持 -> 技術支援;既有的 支援 -> 支持(tw2sp)
與 支持者 保護詞條不變。TWPhrasesRev 同步更新以保持雙向映射封閉。

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@frankslin

Copy link
Copy Markdown
Collaborator

cc @skyuns 老師如何看?

@frankslin frankslin closed this Jul 17, 2026
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.

s2twp / tw2sp 過度轉換問題

2 participants