地區用字及地區慣用詞轉換詞典架構調整方案
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Refactor
- Clarity
- Needs clarification
- Activity status
- Quiet
- Tech stack
- cpp
- Domain
- localization
Research direction
Start by reading the current HKVariants.txt, HKVariantsRev.ocd2, TWVariants.txt, and JPShinjitaiCharacters.txt conventions, then review the related discussions in #378, #495, and #496. Compare the three proposed dictionary architectures and determine which migration and compatibility requirements the project can accept. Done means an agreed architecture, naming scheme, and implementation plan for regional character and phrase conversion.
Written by the indexing model from the issue text.
Description
目前的地區用字及地區慣用詞轉換詞典架構比較混亂,且實際有些問題(參見:#378, #495, #496),反映現行架構有些不足,因此討論下是否要一次把架構調整及優化好。
目前遇到的問題
目前遇到的問題主要有兩個,還有一個優化的議題:
無法處理一對多
如 #378 所述,以 hk2t, hk2s 為例,程式根據 HKVariants.txt 反轉生成的 HKVariantsRev.ocd2 無法妥善處理一對多的優先權問題。
@BYVoid 目前提出可以加一個 HKVariantsRev.txt 修正。hk2t 可以以 HKVariantsRev.txt 優先,HKVariantsRev.ocd2 次之。
無法處理單向轉換
這種情況可能會發生在罕用字或罕用詞的轉換。如 #495 所述,假設 TWVariants.txt 加上「宂=>冗/穴」,程式根據 TWVariants.txt 反轉生成的 TWVariantsRev.ocd2 就必然會有「冗=>宂」、「穴=>宂」,但後者是我們不希望的轉換。換言之,「宂=>穴」應該只作為單向轉換。
以目前架構來說,要解決這問題,可以加個擴充詞典 TWVariantsUni.txt,t2tw 時以 TWVariants.txt 優先,TWVariantsUni.txt 次之;反向轉換時只取 TWVariants.txt 反轉生成 TWVariantsRev.ocd2,忽略 TWVariantsUni.txt。
優化及減少冗餘
另外有一個優化的問題:目前架構是以 XXVariants.txt 為主詞典,反向轉換時用程式自動生成反轉詞典;但實際上一對多的情況是「地區轉標準」遠比「標準轉地區」為多,中國的繁轉簡和簡轉繁是如此,日本新字體也是如此。像簡化字總表、日本的常用漢字表,都是以地區正體為主鍵,被兼併字為副。
考量此點,其實改以 XXStandard.txt 為主詞典,「地區轉標準」直接使用,「標準轉地區」時用程式自動生成反向詞典,整體需要的修正和冗餘量會比較少。
除了冗餘量,也比較容易處理一對多。「標準轉地區」的表在多個標準字對應一個地區字時會有分散的「發=>发」、「髮=>发」,不易維護,改成「发=>發/髮」就清楚得多。或許有人會覺得「標準轉地區」的方向比較直觀,不過這更多是視角和習慣問題。
地區用字轉換的調整方案
據上,可大略整理出幾個調整方案:
方案一:標準轉地區+標準轉地區擴充+地區轉標準修正
以轉香港用字為例:
- 字典:HKVariants.txt、HKVariantsUni.txt、HKVariantsRev.txt
- 詞典:HKVariantsPhrases.txt、HKVariantsPhrasesUni.txt、HKVariantsRevPhrases.txt
這個方案大部分沿用原架構,優點是改動最小;缺點方面就是優化得少,另外日文和此架構有點不一致。
方案二:地區轉標準+地區轉標準擴充+標準轉地區修正
以轉香港用字為例:
- 字典:HKStandard.txt、HKStandardUni.txt、HKStandardRev.txt
- 詞典:HKStandardPhrases.txt、HKStandardPhrasesUni.txt、HKStandardRevPhrases.txt
若採用此方案,JPVariants.txt 可以全部併入 JPShinjitaiCharacters.txt,t2jp 改用程式自動生成反向的 JPShinjitaiCharactersRev.ocd2(或 JPVariants.ocd2?)
方案三:標準轉地區+地區轉標準
以轉香港用字為例:
- 字典:HKVariants.txt、HKVariantsRev.txt
- 詞典:HKVariantsPhrases.txt、HKVariantsRevPhrases.txt
這方案其實就是比照簡轉繁和繁轉簡,把正向和反向詞典分開。優點是邏輯比較簡單,改詞典時不需一邊思考合併的問題。缺點是冗餘量比較大,而且每加一組字詞都要正、反向都加入。
地區慣用詞轉換的調整方案
慣用詞轉換和地區字轉換類似,但是慣用詞比較沒有一對多集中在「地區轉標準」的情況,較無必要改成以「地區轉標準」為主詞典,但是如果地區字轉換要改,慣用詞轉換一併改會比較一致。
方案一:標準轉地區+標準轉地區擴充+地區轉標準修正
以轉香港用詞為例:
- HKPhrases.txt、HKPhrasesUni.txt、HKPhrasesRev.txt
方案二:地區轉標準+地區轉標準擴充+標準轉地區修正
以轉香港用詞為例:
- HKPhrases.txt、HKPhrasesUni.txt、HKPhrasesRev.txt
我認為檔名可以和方案一一樣,只是方向反轉。不過如果考慮相容性問題,還是可以改檔名,但怎麼改就待集思廣義了。
方案三:標準轉地區+地區轉標準
以轉香港用詞為例:
- HKPhrases.txt、HKPhrasesRev.txt
小結
總之就是待大家集思廣義。我個人比較偏好方案二,這樣日後會比較好維護。但如果考量向下相容性,方案一是衝擊最小的做法。
- Dominant language
- C++
- Stars
- 10.1k
- Forks
- 1.1k
- Avg merge
- 47m
- Merged PRs (30d)
- 3
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from BYVoid/OpenCC
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
术忽 → 朮忽 should be the s2t mapping (currently 術忽)Possibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 1/5 1-3 hours Newbie friendliness 85/100
-
update TWPhrasesOther.txtMay be free again A pull request for this issue was closed without being merged. Open
Difficulty 1/5 Under an hour Newbie friendliness 68/100
-
「100人参加了这次活动」转化错误May be free again A pull request for this issue was closed without being merged. Opentriaged
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
-
挽「发」 -> 挽「發」May be free again A pull request for this issue was closed without being merged. Opentriaged
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
bug needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/DirectXShaderCompiler#9173 ·
Maintainers usually reply within 2 days
-
feature:config kind:docs os:windows toolchain:cmake triaged
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
arch-based bug niri
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
noctalia-dev/noctalia#5552 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 5 days