js-opencc 1.4.2 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +27 -11
  2. package/README.zh-Hant.md +27 -11
  3. package/dist/bundles/cn2t.js +30 -13
  4. package/dist/bundles/full.d.ts +2 -2
  5. package/dist/bundles/full.js +20 -7
  6. package/dist/bundles/t2cn.js +25 -13
  7. package/dist/converter.d.ts +13 -6
  8. package/dist/converter.js +28 -18
  9. package/dist/core.d.ts +5 -1
  10. package/dist/core.js +5 -1
  11. package/dist/dict/HKVariantsPhrases.js +1 -1
  12. package/dist/dict/JPShinjitaiCharactersRev.js +1 -1
  13. package/dist/dict/SealCharacters.d.ts +2 -0
  14. package/dist/dict/SealCharacters.js +2 -0
  15. package/dist/dict/SealCharactersRev.d.ts +2 -0
  16. package/dist/dict/SealCharactersRev.js +2 -0
  17. package/dist/dict/SealVariants.d.ts +2 -0
  18. package/dist/dict/SealVariants.js +2 -0
  19. package/dist/dict/SealVariantsRev.d.ts +2 -0
  20. package/dist/dict/SealVariantsRev.js +2 -0
  21. package/dist/dict/TSCharacters.js +1 -1
  22. package/dist/dict/TSPhrases.js +1 -1
  23. package/dist/dict/TWVariants.js +1 -1
  24. package/dist/dict/TWVariantsRev.js +1 -1
  25. package/dist/dict/index.js +4 -0
  26. package/dist/presets.d.ts +26 -11
  27. package/dist/presets.js +39 -21
  28. package/dist/umd/cn2t.js +72 -37
  29. package/dist/umd/cn2t.js.map +1 -1
  30. package/dist/umd/cn2t.min.js +1 -1
  31. package/dist/umd/cn2t.min.js.map +1 -1
  32. package/dist/umd/full.js +108 -69
  33. package/dist/umd/full.js.map +1 -1
  34. package/dist/umd/full.min.js +1 -1
  35. package/dist/umd/full.min.js.map +1 -1
  36. package/dist/umd/t2cn.js +72 -38
  37. package/dist/umd/t2cn.js.map +1 -1
  38. package/dist/umd/t2cn.min.js +1 -1
  39. package/dist/umd/t2cn.min.js.map +1 -1
  40. package/package.json +1 -1
package/README.md CHANGED
@@ -14,7 +14,7 @@ npm install js-opencc
14
14
  import { createConverter } from "js-opencc";
15
15
 
16
16
  const convert = await createConverter({ from: "cn", to: "twp" });
17
- convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠打開影片
17
+ convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠開啟影片
18
18
  ```
19
19
 
20
20
  ## ✨ 特性
@@ -22,8 +22,8 @@ convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠打
22
22
  - **纯 JavaScript** —— 无需编译,浏览器 / Node.js / Deno 通用,零运行时依赖
23
23
  - **`protectedDict` 硬保护字典** —— PUA 占位符机制锁定,不依赖数据巧合
24
24
  - **直接同步 OpenCC 官方字典** —— 上游漂移会中止同步,不静默产出错误结果
25
- - **对齐 OpenCC 官方用例** —— 16 个 config、556 条期望全量比对,随词典同步刷新
26
- - **按方向加载** —— 繁→简只拉 0.11 MB,不是整包 1.13 MB
25
+ - **对齐 OpenCC 官方用例** —— 19 个 config、583 条期望全量比对,随词典同步刷新
26
+ - **按方向加载** —— 繁→简只拉 0.11 MB,不是整包 1.35 MB
27
27
  - **TypeScript 原生支持 · UMD + ESM** —— 完整类型定义,CDN 与现代模块系统通用
28
28
 
29
29
  ## 支持的地区代码
@@ -36,9 +36,12 @@ convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠打
36
36
  | `hk` | 繁体中文(香港) |
37
37
  | `hkp` | 繁体中文(香港)+ 词汇转换(伍迪·艾伦 → 活地·亞倫) |
38
38
  | `jp` | 日本新字体 |
39
+ | `seal` | 小篆(Unicode 18.0 篆書區塊,实验性) |
39
40
  | `t` | OpenCC 标准繁体 |
40
41
 
41
- 七个代码任意组合,`from` 和 `to` 各取其一。
42
+ 八个代码任意组合,`from` 和 `to` 各取其一。
43
+
44
+ `seal` 是上游在 2026-09 新加的小篆对照(`t2seal` / `seal2t` / `s2seal`),我们照单实现,但也照上游的说法讲清楚:它标为**实验性、仅供探索性研究**,输出落在 U+3D000–U+3FC3F,**没有对应字型就是一片豆腐块**。想做印章字形的视觉效果,这条路多半不是你要的(该找的是篆书字体或字形库);要的是与 OpenCC 逐 config 对齐的行为,它就是。字典按需加载:只有真的转小篆才会拉那 4 本,`js-opencc` 主入口的其他方向体积不变;UMD `full` bundle 是例外,带了就是带了(差值见下面的 Bundle 大小)。
42
45
 
43
46
  **运行环境**:Node.js ≥ 22.12(需要 `require()` ESM 的支持,更低版本 CJS `require("js-opencc")` 会失败);浏览器 / Deno 不受限。
44
47
 
@@ -58,11 +61,20 @@ cn2twp("软件"); // 軟體
58
61
 
59
62
  const hk2cn = await createConverter({ from: "hk", to: "cn" });
60
63
  hk2cn("軟件"); // 软件
64
+
65
+ // 小篆(实验性):输出落在 U+3D000–U+3FC3F,多数环境没有字形,看到的是豆腐块
66
+ const t2seal = await createConverter({ from: "t", to: "seal" });
67
+ t2seal("天地"); // U+3D003 U+3F85A
68
+
69
+ // 反向一次调用到位。上游只有 seal2t.json,简体重写要自己串 seal2t | t2s;
70
+ // 这里 from/to 照常写即可,两段链在同一颗管线里跑完
71
+ const seal2cn = await createConverter({ from: "seal", to: "cn" });
72
+ seal2cn(String.fromCodePoint(0x3d003, 0x3f85a)); // 天地
61
73
  ```
62
74
 
63
75
  ### CDN(浏览器)
64
76
 
65
- 三个 bundle 都注册全局 `OpenCC`,**同一页面只引入其中一个**;每个 bundle 只接受自己支持的方向,传别的方向会直接抛错。
77
+ 三个 bundle 都注册全局 `OpenCC`,**同一页面只引入其中一个**;每个 bundle 只接受自己支持的方向,传别的方向会直接抛错(`seal` 只在完整版里,`cn2t` / `t2cn` 传它会拿到 `does not carry 'to: seal' — use the full bundle`)。
66
78
 
67
79
  ```html
68
80
  <!-- 完整版:任意方向 -->
@@ -162,11 +174,14 @@ OpenCC.Converter({ from: "cn", to: "tw" }, OpenCC.parseOpenCCDict(text));
162
174
 
163
175
  | 包 | 大小(minified) | 说明 |
164
176
  | --- | --- | --- |
165
- | `full.min.js` | ~1.13 MB | 完整版,支持所有转换方向 |
177
+ | `full.min.js` | ~1.35 MB | 完整版,支持所有转换方向(含小篆那 4 本字典) |
166
178
  | `cn2t.min.js` | ~1.04 MB | 仅简体 → 繁体 |
167
179
  | `t2cn.min.js` | ~100 KB | 仅繁体 → 简体(绝大多数字典是简→繁向,反向数据小) |
168
180
 
169
- npm 安装后占 **6.1 MB**(tarball 2.5 MB)。每个 bundle 同时发未压缩和 `.min.js` 两份;这些 bundle 有 97% 是词典字符串,压缩前后只差 3%。
181
+ 小篆收养让 `full.min.js` 从 ~1.13 MB 涨到 ~1.35 MB(gzip 后 +128 KB,即 +26%);`cn2t` / `t2cn` 按设计不带小篆,体积不动,
182
+ 传 `seal` 会拿到一条指向 `full` 的明确错误。
183
+
184
+ npm 安装后占 **6.6 MB**(tarball 2.8 MB)。每个 bundle 同时发未压缩和 `.min.js` 两份;这些 bundle 有 97% 是词典字符串,压缩前后只差 3%。
170
185
 
171
186
  ## 和其他方案的关系
172
187
 
@@ -186,12 +201,13 @@ npm run build # 完整构建(含 sync + tsc + rollup)
186
201
  npm run build:dist # 跳过 sync,只跑 tsc + rollup
187
202
  ```
188
203
 
189
- `sync:opencc` 不只是下载,它同时做四道**会中止**的对账——上游变了而我们没跟上时,宁可让同步失败,也不要静默产出错误结果:
204
+ `sync:opencc` 不只是下载,它同时做五道**会中止**的对账——上游变了而我们没跟上时,宁可让同步失败,也不要静默产出错误结果:
190
205
 
191
206
  1. **词典文件清单** —— 上游新增或删除 `.txt` 且不在白名单里,报错要人裁决
192
- 2. **转换链** —— 11 条链逐个比对上游 config 的 `conversion_chain`
193
- 3. **切段声明** —— 16 个 config 的 `segmentation` 字段**两个方向都查**:我们切的上游不切了,以及上游新增了我们没切的。后者尤其容易漏——什么都不会报错,只是从此少切一刀,地区词汇又开始越界替换
194
- 4. **官方 testcases** —— fixture 与词典同一次快照刷新,避免拿新词典去对旧用例
207
+ 2. **config 覆盖面** —— 上游 `data/config` 里每个 config 都必须落在「链比对名单」或「写明理由的豁免名单」上,切段那两份名单同样要盖全。这条单独存在是因为下面两道只按名单点名的 config 去取文件:**名单少一条,运行照样绿**,只是那条链从此没人看(小篆收养时实测过——从名单删掉 `s2seal`,套件毫无反应)。`test/upstream-contracts.test.ts` 离线盯同一件事,不联网也红得下来
208
+ 3. **转换链** —— 14 条链逐个比对上游 config 的 `conversion_chain`,按步比:一侧占几步就比几步(小篆两侧各两步)
209
+ 4. **切段声明** —— 19 个 config 的 `segmentation` 字段**两个方向都查**:我们切的上游不切了,以及上游新增了我们没切的。后者尤其容易漏——什么都不会报错,只是从此少切一刀,地区词汇又开始越界替换
210
+ 5. **官方 testcases** —— fixture 与词典同一次快照刷新,避免拿新词典去对旧用例
195
211
 
196
212
  `STPhrases_GeneratedFromRegionalPhrases`(OpenCC 构建期生成的切段词典)由同步脚本按上游 `generate_st_phrases_from_regional_phrases.py` 的规则本地生成,不需要 OpenCC 的构建环境。
197
213
 
package/README.zh-Hant.md CHANGED
@@ -14,7 +14,7 @@ npm install js-opencc
14
14
  import { createConverter } from "js-opencc";
15
15
 
16
16
  const convert = await createConverter({ from: "cn", to: "twp" });
17
- convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠打開影片
17
+ convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠開啟影片
18
18
  ```
19
19
 
20
20
  ## ✨ 特性
@@ -22,8 +22,8 @@ convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠打
22
22
  - **純 JavaScript** —— 無需編譯,瀏覽器 / Node.js / Deno 通用,零執行時相依
23
23
  - **`protectedDict` 硬保護字典** —— PUA 佔位符機制鎖定,不依賴資料巧合
24
24
  - **直接同步 OpenCC 官方字典** —— 上游漂移會中止同步,不靜默產出錯誤結果
25
- - **對齊 OpenCC 官方用例** —— 16 個 config、556 條期望全量比對,隨字典同步重新整理
26
- - **按方向載入** —— 繁→簡只拉 0.11 MB,不是整包 1.13 MB
25
+ - **對齊 OpenCC 官方用例** —— 19 個 config、583 條期望全量比對,隨字典同步重新整理
26
+ - **按方向載入** —— 繁→簡只拉 0.11 MB,不是整包 1.35 MB
27
27
  - **TypeScript 原生支援 · UMD + ESM** —— 完整型別定義,CDN 與現代模組系統通用
28
28
 
29
29
  ## 支援的地區代碼
@@ -36,9 +36,12 @@ convert("出租车司机用鼠标打开视频"); // 計程車司機用滑鼠打
36
36
  | `hk` | 繁體中文(香港) |
37
37
  | `hkp` | 繁體中文(香港)+ 詞彙轉換(伍迪·艾伦 → 活地·亞倫) |
38
38
  | `jp` | 日本新字體 |
39
+ | `seal` | 小篆(Unicode 18.0 篆書區塊,實驗性) |
39
40
  | `t` | OpenCC 標準繁體 |
40
41
 
41
- 七個代碼任意組合,`from` 和 `to` 各取其一。
42
+ 八個代碼任意組合,`from` 和 `to` 各取其一。
43
+
44
+ `seal` 是上游在 2026-09 新加的小篆對照(`t2seal` / `seal2t` / `s2seal`),我們照單實作,也照上游的說法講清楚:它標為**實驗性、僅供探索性研究**,輸出落在 U+3D000–U+3FC3F,**沒有對應字型就是一片豆腐塊**。想做印章字形的視覺效果,這條路多半不是你要的(該找的是篆書字型或字形庫);要的是與 OpenCC 逐 config 對齊的行為,它就是。字典按需載入:只有真的轉小篆才會拉那 4 本,`js-opencc` 主入口的其他方向體積不變;UMD `full` bundle 是例外,帶了就是帶了(差值見下面的 Bundle 大小)。
42
45
 
43
46
  **執行環境**:Node.js ≥ 22.12(需要 `require()` ESM 的支援,更低版本 CJS `require("js-opencc")` 會失敗);瀏覽器 / Deno 不受限。
44
47
 
@@ -58,11 +61,20 @@ cn2twp("软件"); // 軟體
58
61
 
59
62
  const hk2cn = await createConverter({ from: "hk", to: "cn" });
60
63
  hk2cn("軟件"); // 软件
64
+
65
+ // 小篆(實驗性):輸出落在 U+3D000–U+3FC3F,多數環境沒有字型,看到的是豆腐塊
66
+ const t2seal = await createConverter({ from: "t", to: "seal" });
67
+ t2seal("天地"); // U+3D003 U+3F85A
68
+
69
+ // 反向一次呼叫到位。上游只有 seal2t.json,簡體重寫要自己串 seal2t | t2s;
70
+ // 這裡 from/to 照常寫即可,兩段鏈在同一條管線裡跑完
71
+ const seal2cn = await createConverter({ from: "seal", to: "cn" });
72
+ seal2cn(String.fromCodePoint(0x3d003, 0x3f85a)); // 天地
61
73
  ```
62
74
 
63
75
  ### CDN(瀏覽器)
64
76
 
65
- 三個 bundle 都註冊全域 `OpenCC`,**同一頁面只引入其中一個**;每個 bundle 只接受自己支援的方向,傳別的方向會直接拋錯。
77
+ 三個 bundle 都註冊全域 `OpenCC`,**同一頁面只引入其中一個**;每個 bundle 只接受自己支援的方向,傳別的方向會直接拋錯(`seal` 只在完整版裡,`cn2t` / `t2cn` 傳它會拿到 `does not carry 'to: seal' — use the full bundle`)。
66
78
 
67
79
  ```html
68
80
  <!-- 完整版:任意方向 -->
@@ -162,11 +174,14 @@ OpenCC.Converter({ from: "cn", to: "tw" }, OpenCC.parseOpenCCDict(text));
162
174
 
163
175
  | 套件 | 大小(minified) | 說明 |
164
176
  | --- | --- | --- |
165
- | `full.min.js` | ~1.13 MB | 完整版,支援所有轉換方向 |
177
+ | `full.min.js` | ~1.35 MB | 完整版,支援所有轉換方向(含小篆那 4 本字典) |
166
178
  | `cn2t.min.js` | ~1.04 MB | 僅簡體 → 繁體 |
167
179
  | `t2cn.min.js` | ~100 KB | 僅繁體 → 簡體(絕大多數字典是簡→繁向,反向資料小) |
168
180
 
169
- npm 安裝後佔 **6.1 MB**(tarball 2.5 MB)。每個 bundle 同時發未壓縮和 `.min.js` 兩份;這些 bundle 有 97% 是詞典字串,壓縮前後只差 3%。
181
+ 收養小篆讓 `full.min.js` 從 ~1.13 MB 漲到 ~1.35 MB(gzip 後 +128 KB,即 +26%);`cn2t` / `t2cn` 按設計不帶小篆,體積不動,
182
+ 傳 `seal` 會拿到一條指向 `full` 的明確錯誤。
183
+
184
+ npm 安裝後佔 **6.6 MB**(tarball 2.8 MB)。每個 bundle 同時發未壓縮和 `.min.js` 兩份;這些 bundle 有 97% 是詞典字串,壓縮前後只差 3%。
170
185
 
171
186
  ## 和其他方案的關係
172
187
 
@@ -186,12 +201,13 @@ npm run build # 完整建置(含 sync + tsc + rollup)
186
201
  npm run build:dist # 跳過 sync,只跑 tsc + rollup
187
202
  ```
188
203
 
189
- `sync:opencc` 不只是下載,它同時做四道**會中止**的對帳——上游變了而我們沒跟上時,寧可讓同步失敗,也不要靜默產出錯誤結果:
204
+ `sync:opencc` 不只是下載,它同時做五道**會中止**的對帳——上游變了而我們沒跟上時,寧可讓同步失敗,也不要靜默產出錯誤結果:
190
205
 
191
206
  1. **字典檔案清單** —— 上游新增或刪除 `.txt` 且不在白名單裡,報錯要人裁決
192
- 2. **轉換鏈** —— 11 條鏈逐個比對上游 config 的 `conversion_chain`
193
- 3. **切分宣告** —— 16 個 config 的 `segmentation` 欄位**兩個方向都查**:我們切的上游不切了,以及上游新增了我們沒切的。後者尤其容易漏——什麼都不會報錯,只是從此少切一刀,地區詞彙又開始越界替換
194
- 4. **官方 testcases** —— fixture 與字典同一次快照重新整理,避免拿新字典去對舊用例
207
+ 2. **config 覆蓋面** —— 上游 `data/config` 裡每個 config 都必須落在「鏈比對名單」或「寫明理由的豁免名單」上,切段那兩份名單同樣要蓋全。這條單獨存在是因為下面兩道只按名單點名的 config 去取檔案:**名單少一條,執行照樣綠**,只是那條鏈從此沒人看(收養小篆時實測過——從名單刪掉 `s2seal`,套件毫無反應)。`test/upstream-contracts.test.ts` 離線盯同一件事,不連線也紅得下來
208
+ 3. **轉換鏈** —— 14 條鏈逐個比對上游 config 的 `conversion_chain`,按步比:一側佔幾步就比幾步(小篆兩側各兩步)
209
+ 4. **切段宣告** —— 19 個 config 的 `segmentation` 欄位**兩個方向都查**:我們切的上游不切了,以及上游新增了我們沒切的。後者尤其容易漏——什麼都不會報錯,只是從此少切一刀,地區詞彙又開始越界替換
210
+ 5. **官方 testcases** —— fixture 與字典同一次快照重新整理,避免拿新字典去對舊用例
195
211
 
196
212
  `STPhrases_GeneratedFromRegionalPhrases`(OpenCC 建置期產生的切分字典)由同步腳本按上游 `generate_st_phrases_from_regional_phrases.py` 的規則本地產生,不需要 OpenCC 的建置環境。
197
213
 
@@ -17,6 +17,16 @@ import HKVariantsPhrases from "../dict/HKVariantsPhrases.js";
17
17
  import HKPhrases from "../dict/HKPhrases.js";
18
18
  import JPShinjitaiCharactersRev from "../dict/JPShinjitaiCharactersRev.js";
19
19
  import CNTWPhrases from "../dict/CNTWPhrases.js";
20
+ /**
21
+ * The targets this bundle actually carries dictionaries for, as a list rather
22
+ * than only as the type above: `seal` is a `LocaleCode` and the full bundle
23
+ * ships it, but a "simplified → traditional, small download" bundle has no
24
+ * business carrying ~113 KB of seal data. JS callers bypass `TargetLocale`, so
25
+ * the gap needs a runtime answer — and it has to be a different message from
26
+ * "dictionary missing", which would accuse this bundle of a packaging bug that
27
+ * does not exist.
28
+ */
29
+ const BUNDLE_TARGETS = ["t", "tw", "twp", "hk", "hkp", "jp"];
20
30
  const dictMap = {
21
31
  STCharacters,
22
32
  STPhrases,
@@ -59,20 +69,27 @@ function Converter(options, protectedDict) {
59
69
  // from dictMap throw loudly — silently skipping a step would return
60
70
  // partially-converted text (JS callers bypass the TS type check).
61
71
  if (options.to !== "t") {
62
- const dictFiles = standard2variants[options.to];
63
- // Array.isArray, not truthiness: `standard2variants["constructor"]` is a
64
- // truthy prototype member that would fall through to an opaque TypeError.
65
- if (!Array.isArray(dictFiles))
72
+ const steps = standard2variants[options.to];
73
+ // Array.isArray on the step list AND its first step: `standard2variants` is
74
+ // keyed by string, so a prototype member like "constructor" is truthy and a
75
+ // non-array — either check alone lets something fall through to an opaque
76
+ // TypeError inside the map.
77
+ if (!Array.isArray(steps) || !Array.isArray(steps[0]))
66
78
  throw new Error(`Unknown 'to' locale: ${options.to}`);
67
- dictGroups.push(dictFiles.map((name) => {
68
- const d = dictMap[name];
69
- // typeof, not truthiness: a dict CAN legitimately optimize to "" (all
70
- // entries single-char identity pairs), and this also rejects prototype
71
- // members like "toString" that `in` would accept.
72
- if (typeof d !== "string")
73
- throw new Error(`Dictionary ${name} missing from cn2t bundle`);
74
- return d;
75
- }));
79
+ if (!BUNDLE_TARGETS.includes(options.to)) {
80
+ throw new Error(`cn2t bundle does not carry 'to: ${options.to}' — use the full bundle`);
81
+ }
82
+ for (const step of steps) {
83
+ dictGroups.push(step.map((name) => {
84
+ const d = dictMap[name];
85
+ // typeof, not truthiness: a dict CAN legitimately optimize to "" (all
86
+ // entries single-char identity pairs), and this also rejects prototype
87
+ // members like "toString" that `in` would accept.
88
+ if (typeof d !== "string")
89
+ throw new Error(`Dictionary ${name} missing from cn2t bundle`);
90
+ return d;
91
+ }));
92
+ }
76
93
  }
77
94
  // Cut the input before converting: without it the second step's regional
78
95
  // vocabulary table matches across word boundaries the first step set, and
@@ -30,10 +30,10 @@ interface ConverterOptions {
30
30
  declare function Converter(options: ConverterOptions, protectedDict?: DictLike): (input: string) => string;
31
31
  declare const Locale: {
32
32
  from: {
33
- [k: string]: string[];
33
+ [k: string]: string[][];
34
34
  };
35
35
  to: {
36
- [k: string]: string[];
36
+ [k: string]: string[][];
37
37
  };
38
38
  };
39
39
  export { Converter, CustomConverter, ConverterFactory, ConverterFactoryWithSegmentation, ProtectedConverter, normalizeCompatibilityIdeographs, parseOpenCCDict, HTMLConverter, Locale, Trie, };
@@ -26,6 +26,10 @@ import TWPhrasesRev from "../dict/TWPhrasesRev.js";
26
26
  import JPShinjitaiCharacters from "../dict/JPShinjitaiCharacters.js";
27
27
  import JPShinjitaiCharactersRev from "../dict/JPShinjitaiCharactersRev.js";
28
28
  import JPShinjitaiPhrases from "../dict/JPShinjitaiPhrases.js";
29
+ import SealCharacters from "../dict/SealCharacters.js";
30
+ import SealCharactersRev from "../dict/SealCharactersRev.js";
31
+ import SealVariants from "../dict/SealVariants.js";
32
+ import SealVariantsRev from "../dict/SealVariantsRev.js";
29
33
  import CNTWPhrases from "../dict/CNTWPhrases.js";
30
34
  const dict = {
31
35
  STCharacters,
@@ -48,6 +52,10 @@ const dict = {
48
52
  JPShinjitaiCharacters,
49
53
  JPShinjitaiCharactersRev,
50
54
  JPShinjitaiPhrases,
55
+ SealCharacters,
56
+ SealCharactersRev,
57
+ SealVariants,
58
+ SealVariantsRev,
51
59
  };
52
60
  /**
53
61
  * Create a converter with the specified locales.
@@ -73,13 +81,17 @@ function Converter(options, protectedDict) {
73
81
  throw new Error(`Unknown 'to' locale: ${options.to}`);
74
82
  }
75
83
  const dictGroups = [];
76
- // From variant to standard
84
+ // From variant to standard, one group per step
77
85
  if (options.from !== "t") {
78
- dictGroups.push(variants2standard[options.from].map((name) => dict[name]));
86
+ for (const step of variants2standard[options.from]) {
87
+ dictGroups.push(step.map((name) => dict[name]));
88
+ }
79
89
  }
80
- // From standard to variant
90
+ // From standard to variant, one group per step
81
91
  if (options.to !== "t") {
82
- dictGroups.push(standard2variants[options.to].map((name) => dict[name]));
92
+ for (const step of standard2variants[options.to]) {
93
+ dictGroups.push(step.map((name) => dict[name]));
94
+ }
83
95
  }
84
96
  // Cut the input before converting: without it the second step's regional
85
97
  // vocabulary table matches across word boundaries the first step set, and
@@ -105,10 +117,11 @@ function Converter(options, protectedDict) {
105
117
  }
106
118
  return convert;
107
119
  }
108
- // Locale data for ConverterBuilder compatibility
120
+ // Locale data for ConverterBuilder compatibility — 每个 locale 是一串步骤,
121
+ // 与 presets 的 `string[][]` 同形(DictGroup[]),不是单个 DictGroup。
109
122
  const Locale = {
110
- from: Object.fromEntries(Object.entries(variants2standard).map(([locale, files]) => [locale, files.map((name) => dict[name])])),
111
- to: Object.fromEntries(Object.entries(standard2variants).map(([locale, files]) => [locale, files.map((name) => dict[name])])),
123
+ from: Object.fromEntries(Object.entries(variants2standard).map(([locale, steps]) => [locale, steps.map((step) => step.map((name) => dict[name]))])),
124
+ to: Object.fromEntries(Object.entries(standard2variants).map(([locale, steps]) => [locale, steps.map((step) => step.map((name) => dict[name]))])),
112
125
  };
113
126
  // // 带切段的工厂也导出:只给不带切段的那个,自己拼链的人会静默丢掉地区词边界处理
114
127
  export { Converter, CustomConverter, ConverterFactory, ConverterFactoryWithSegmentation, ProtectedConverter, normalizeCompatibilityIdeographs, parseOpenCCDict, HTMLConverter, Locale, Trie, };
@@ -17,6 +17,8 @@ import HKPhrasesRev from "../dict/HKPhrasesRev.js";
17
17
  import JPShinjitaiCharacters from "../dict/JPShinjitaiCharacters.js";
18
18
  import JPShinjitaiPhrases from "../dict/JPShinjitaiPhrases.js";
19
19
  import CNTWPhrases from "../dict/CNTWPhrases.js";
20
+ /** The sources this bundle carries dictionaries for — see cn2t's BUNDLE_TARGETS. */
21
+ const BUNDLE_SOURCES = ["t", "tw", "twp", "hk", "hkp", "jp"];
20
22
  const dictMap = {
21
23
  TSCharacters,
22
24
  TSPhrases,
@@ -51,20 +53,30 @@ function Converter(options, protectedDict) {
51
53
  // from dictMap throw loudly — silently skipping a step would return
52
54
  // partially-converted text (JS callers bypass the TS type check).
53
55
  if (options.from !== "t") {
54
- const dictFiles = variants2standard[options.from];
55
- // Array.isArray, not truthiness: `variants2standard["constructor"]` is a
56
- // truthy prototype member that would fall through to an opaque TypeError.
57
- if (!Array.isArray(dictFiles))
56
+ const steps = variants2standard[options.from];
57
+ // Array.isArray on the step list AND its first step: `variants2standard` is
58
+ // keyed by string, so a prototype member like "constructor" is truthy and a
59
+ // non-array — either check alone lets something fall through to an opaque
60
+ // TypeError inside the map.
61
+ if (!Array.isArray(steps) || !Array.isArray(steps[0]))
58
62
  throw new Error(`Unknown 'from' locale: ${options.from}`);
59
- dictGroups.push(dictFiles.map((name) => {
60
- const d = dictMap[name];
61
- // typeof, not truthiness: a dict CAN legitimately optimize to "" (all
62
- // entries single-char identity pairs), and this also rejects prototype
63
- // members like "toString" that `in` would accept.
64
- if (typeof d !== "string")
65
- throw new Error(`Dictionary ${name} missing from t2cn bundle`);
66
- return d;
67
- }));
63
+ // `seal` is a LocaleCode the full bundle serves; this one does not carry its
64
+ // ~113 KB of data. Say so instead of letting the dictMap lookup report a
65
+ // "dictionary missing" packaging bug that does not exist.
66
+ if (!BUNDLE_SOURCES.includes(options.from)) {
67
+ throw new Error(`t2cn bundle does not carry 'from: ${options.from}' — use the full bundle`);
68
+ }
69
+ for (const step of steps) {
70
+ dictGroups.push(step.map((name) => {
71
+ const d = dictMap[name];
72
+ // typeof, not truthiness: a dict CAN legitimately optimize to "" (all
73
+ // entries single-char identity pairs), and this also rejects prototype
74
+ // members like "toString" that `in` would accept.
75
+ if (typeof d !== "string")
76
+ throw new Error(`Dictionary ${name} missing from t2cn bundle`);
77
+ return d;
78
+ }));
79
+ }
68
80
  }
69
81
  // From standard to cn (always needed)
70
82
  dictGroups.push([TSCharacters, TSPhrases]);
@@ -23,8 +23,9 @@ export interface ConverterOptions {
23
23
  * Locale preset data containing dictionary groups
24
24
  */
25
25
  export interface LocalePreset {
26
- from: Record<string, DictGroup>;
27
- to: Record<string, DictGroup>;
26
+ /** 每个 locale = 一串转换步骤,每步是一个合并 trie 的字典名单(见 presets.ts) */
27
+ from: Record<string, DictGroup[]>;
28
+ to: Record<string, DictGroup[]>;
28
29
  /**
29
30
  * Dictionaries available to cut the input on, keyed by dict file name (the
30
31
  * names `segmentationDictsFor` returns, e.g. `STPhrases` / `TSPhrases`).
@@ -41,10 +42,11 @@ export declare function ConverterBuilder(localePreset: LocalePreset): (options:
41
42
  /**
42
43
  * Dictionary files for a conversion, GROUPED BY CONVERSION STEP.
43
44
  *
44
- * Returns `string[][]`: each inner array is one conversion step
45
- * (variant→standard, then standard→variant). Each step MUST be loaded into a
46
- * SINGLE merged trie so the trie's longest-match lets phrase dictionaries
47
- * (STPhrases, *RevPhrases) win over single-character dictionaries.
45
+ * Returns `string[][]`: each inner array is one conversion step (a variant's
46
+ * side may contribute more than one — the seal chains are two steps). Each step
47
+ * MUST be loaded into a SINGLE merged trie so the trie's longest-match lets
48
+ * phrase dictionaries (STPhrases, *RevPhrases) win over single-character
49
+ * dictionaries.
48
50
  *
49
51
  * Correct usage:
50
52
  * ConverterFactory(...getDictFiles(from, to).map(group => buildTrieFromGroup(group)))
@@ -56,6 +58,11 @@ export declare function ConverterBuilder(localePreset: LocalePreset): (options:
56
58
  * only need the flat file list (e.g. to know which dict files to bundle), call
57
59
  * `getDictFiles(from, to).flat()`.
58
60
  *
61
+ * The opposite mistake is equally silent: folding two *separate* steps into one
62
+ * trie. Steps run in sequence, so step two reads what step one wrote (年 →秊→小篆);
63
+ * a single pass over the merged dictionary never sees 秊. Two steps merged are not
64
+ * one step, however many entries they share.
65
+ *
59
66
  * @throws {Error} if `from` or `to` is an unknown locale (i.e. not `'t'` and not
60
67
  * a key of `variants2standard` / `standard2variants`).
61
68
  */
package/dist/converter.js CHANGED
@@ -16,13 +16,15 @@ import { dictLoaders } from "./dict/index.js";
16
16
  export function ConverterBuilder(localePreset) {
17
17
  return function Converter(options) {
18
18
  const dictGroups = [];
19
- // Add 'from' dictionaries (variant -> standard)
20
- if (options.from !== "t" && localePreset.from[options.from]) {
21
- dictGroups.push(localePreset.from[options.from]);
19
+ // Add 'from' dictionaries (variant -> standard), one group per step
20
+ if (options.from !== "t") {
21
+ for (const step of localePreset.from[options.from] ?? [])
22
+ dictGroups.push(step);
22
23
  }
23
- // Add 'to' dictionaries (standard -> variant)
24
- if (options.to !== "t" && localePreset.to[options.to]) {
25
- dictGroups.push(localePreset.to[options.to]);
24
+ // Add 'to' dictionaries (standard -> variant), one group per step
25
+ if (options.to !== "t") {
26
+ for (const step of localePreset.to[options.to] ?? [])
27
+ dictGroups.push(step);
26
28
  }
27
29
  // Segmentation needs a dictionary keyed in the INPUT's script, which a
28
30
  // caller-supplied preset may not carry. Cut only when the preset actually
@@ -36,10 +38,11 @@ export function ConverterBuilder(localePreset) {
36
38
  /**
37
39
  * Dictionary files for a conversion, GROUPED BY CONVERSION STEP.
38
40
  *
39
- * Returns `string[][]`: each inner array is one conversion step
40
- * (variant→standard, then standard→variant). Each step MUST be loaded into a
41
- * SINGLE merged trie so the trie's longest-match lets phrase dictionaries
42
- * (STPhrases, *RevPhrases) win over single-character dictionaries.
41
+ * Returns `string[][]`: each inner array is one conversion step (a variant's
42
+ * side may contribute more than one — the seal chains are two steps). Each step
43
+ * MUST be loaded into a SINGLE merged trie so the trie's longest-match lets
44
+ * phrase dictionaries (STPhrases, *RevPhrases) win over single-character
45
+ * dictionaries.
43
46
  *
44
47
  * Correct usage:
45
48
  * ConverterFactory(...getDictFiles(from, to).map(group => buildTrieFromGroup(group)))
@@ -51,26 +54,33 @@ export function ConverterBuilder(localePreset) {
51
54
  * only need the flat file list (e.g. to know which dict files to bundle), call
52
55
  * `getDictFiles(from, to).flat()`.
53
56
  *
57
+ * The opposite mistake is equally silent: folding two *separate* steps into one
58
+ * trie. Steps run in sequence, so step two reads what step one wrote (年 →秊→小篆);
59
+ * a single pass over the merged dictionary never sees 秊. Two steps merged are not
60
+ * one step, however many entries they share.
61
+ *
54
62
  * @throws {Error} if `from` or `to` is an unknown locale (i.e. not `'t'` and not
55
63
  * a key of `variants2standard` / `standard2variants`).
56
64
  */
57
65
  export function getDictFiles(from, to) {
58
66
  const groups = [];
59
67
  if (from !== "t") {
60
- const fromFiles = variants2standard[from];
68
+ const steps = variants2standard[from];
61
69
  // Reject unknown locales loudly instead of silently producing a converter
62
70
  // that skips the step (which would return partially/un-converted text).
63
- if (!fromFiles)
71
+ if (!steps)
64
72
  throw new Error(`Unknown 'from' locale: ${from}`);
65
- if (fromFiles.length)
66
- groups.push(fromFiles);
73
+ for (const step of steps)
74
+ if (step.length)
75
+ groups.push(step);
67
76
  }
68
77
  if (to !== "t") {
69
- const toFiles = standard2variants[to];
70
- if (!toFiles)
78
+ const steps = standard2variants[to];
79
+ if (!steps)
71
80
  throw new Error(`Unknown 'to' locale: ${to}`);
72
- if (toFiles.length)
73
- groups.push(toFiles);
81
+ for (const step of steps)
82
+ if (step.length)
83
+ groups.push(step);
74
84
  }
75
85
  return groups;
76
86
  }
package/dist/core.d.ts CHANGED
@@ -179,11 +179,15 @@ export declare function ProtectedConverter(protectedDict: DictLike, innerConvert
179
179
  * The value is everything after the FIRST space (values may contain spaces,
180
180
  * e.g. 二维码 → "QR Code") — same rule as `Trie.loadDict`'s string form.
181
181
  *
182
- * Collision policy, identical to `reverseEntries` in scripts/sync-opencc.ts:
182
+ * Collision policy, same first-wins + identity-outranks as `reverseEntries` in
183
+ * scripts/lib/reverse-dict.ts:
183
184
  * when several keys share one value (U盘/优盘 → 隨身碟) the FIRST key wins,
184
185
  * because dicts list the preferred term first and the trie is last-wins — so
185
186
  * without this the trailing synonym takes over (隨身碟 → 优盘). An identity pair
186
187
  * outranks that, leaving the term untouched rather than guessing a synonym.
188
+ * (The generator has one rule this runtime path cannot know: upstream's
189
+ * `# @reverse-prefer:` comments name a winner by hand, and a packed dict string
190
+ * has lost them by the time this runs.)
187
191
  *
188
192
  * Entries with no separator are skipped, as `Trie.loadDict` does.
189
193
  */
package/dist/core.js CHANGED
@@ -516,11 +516,15 @@ export function ProtectedConverter(protectedDict, innerConvert) {
516
516
  * The value is everything after the FIRST space (values may contain spaces,
517
517
  * e.g. 二维码 → "QR Code") — same rule as `Trie.loadDict`'s string form.
518
518
  *
519
- * Collision policy, identical to `reverseEntries` in scripts/sync-opencc.ts:
519
+ * Collision policy, same first-wins + identity-outranks as `reverseEntries` in
520
+ * scripts/lib/reverse-dict.ts:
520
521
  * when several keys share one value (U盘/优盘 → 隨身碟) the FIRST key wins,
521
522
  * because dicts list the preferred term first and the trie is last-wins — so
522
523
  * without this the trailing synonym takes over (隨身碟 → 优盘). An identity pair
523
524
  * outranks that, leaving the term untouched rather than guessing a synonym.
525
+ * (The generator has one rule this runtime path cannot know: upstream's
526
+ * `# @reverse-prefer:` comments name a winner by hand, and a packed dict string
527
+ * has lost them by the time this runs.)
524
528
  *
525
529
  * Entries with no separator are skipped, as `Trie.loadDict` does.
526
530
  */
@@ -1,2 +1,2 @@
1
- const dict = "一幻拉麪 一幻拉麵|一粥麪 一粥麵|三田製麪所 三田製麵所|仙姑峯 仙姑峰|何芷姍 何芷姗|佛教茂峯法師紀念中學 佛教茂峰法師紀念中學|儒林台 儒林臺|儒林臺 儒林臺|光明台 光明臺|光明臺 光明臺|光景台 光景臺|光景臺 光景臺|光漢台 光漢臺|光漢臺 光漢臺|冠冕台 冠冕臺|冠冕臺 冠冕臺|冠峯街 冠峰街|冼靖峯 冼靖峰|列拿士地台 列拿士地臺|列拿士地臺 列拿士地臺|利羣道 利群道|利舞台廣場 利舞臺廣場|利舞臺廣場 利舞臺廣場|劉利羣 劉利群|加倫台 加倫臺|加倫臺 加倫臺|加冕台 加冕臺|加冕臺 加冕臺|北港島線 北港島綫|北環線 北環綫|北角台 北角臺|北角臺 北角臺|匯基書院 滙基書院|匯豐 滙豐|匯豐銀行 滙豐銀行|南港島線 南港島綫|南記粉麪 南記粉麵|吃茶舍 喫茶舍|合羣街 合群街|吳子沖 吳子冲|味千拉麪 味千拉麵|啟思中學 啓思中學|喫茶小舖 喫茶小舖|喫茶舍 喫茶舍|大埔循道衛理小學 大埔循道衛理小學|大埔循道衞理小學 大埔循道衛理小學|大學教育資助委員會祕書處 大學教育資助委員會秘書處|大安台 大安臺|大安臺 大安臺|大班麪包西餅 大班麵包西餅|天文台圍 天文臺圍|天文台道 天文臺道|天文臺圍 天文臺圍|天文臺道 天文臺道|姜詠鑫 姜咏鑫|孖峯嶺路 孖峰嶺路|安慶台 安慶臺|安慶臺 安慶臺|安羣街 安群街|宋皇台 宋皇臺|宋皇台道 宋皇臺道|宋皇臺 宋皇臺|宋皇臺道 宋皇臺道|宏豐台 宏豐臺|宏豐臺 宏豐臺|寧漢豪 甯漢豪|寶峯徑 寶峰徑|將軍澳循道衛理小學 將軍澳循道衛理小學|將軍澳循道衞理小學 將軍澳循道衛理小學|將軍澳線 將軍澳綫|尖尾峯 尖尾峰|尖峯山 尖峰山|尚麪 尚麵|屯馬線 屯馬綫|山坡台 山坡臺|山坡臺 山坡臺|山城小麪 山城小麵|山崎麪飽 山崎麵飽|山村台 山村臺|山村臺 山村臺|山邊台 山邊臺|山邊臺 山邊臺|峯華邨 峰華邨|峯霞道 峰霞道|巷仔見麪館 巷仔見麵館|幺鳳士多 么鳳士多|康福台 康福臺|康福臺 康福臺|建羣街 建群街|張柏芝 張柏芝|張栢芝 張栢芝|張穎康 張頴康|張華峯 張華峰|張衛健 張衛健|張衞健 張衛健|循道衛理 循道衛理|循道衞理 循道衛理|恆大 恒大|恆指 恒指|恆生 恒生|恆生大學 恒生大學|恆生指數 恒生指數|愉峯道 愉峰道|愛羣道 愛群道|截取通訊及監察事務專員祕書處 截取通訊及監察事務專員秘書處|摩頓台 摩頓臺|摩頓臺 摩頓臺|春暉台 春暉臺|春暉臺 春暉臺|景峯 景峰|景峯徑 景峰徑|朱匯林 朱滙林|朱柏康 朱栢康|朱柏謙 朱栢謙|李啟傑 李啓傑|李鉅峯 李鉅峰|杜琪峯 杜琪峰|東九龍線 東九龍綫|東山台 東山臺|東山臺 東山臺|東涌線 東涌綫|東鐵線 東鐵綫|林一峯 林一峰|林曉峯 林曉峰|林正峯 林正峰|林海峯 林海峰|林逸峯 林逸峰|桃李台 桃李臺|桃李臺 桃李臺|梁季彝中學 梁季彜中學|梁證嘉 梁証嘉|梁輝台 梁輝臺|梁輝臺 梁輝臺|梁釗峯 梁釗峰|梅豔芳 梅艷芳|榮華台 榮華臺|榮華臺 榮華臺|樂景台 樂景臺|樂景臺 樂景臺|樂羣街 樂群街|樓梯台 樓梯臺|樓梯臺 樓梯臺|機場快線 機場快綫|正斗粥麪專家 正斗粥麵專家|沙中線 沙中綫|沙田循道衛理小學 沙田循道衛理小學|沙田循道衞理小學 沙田循道衛理小學|河上鄉排峯路 河上鄉排峰路|活倫台 活倫臺|活倫臺 活倫臺|温兆倫 溫兆倫|温碧霞 溫碧霞|港島線 港島綫|溫兆倫 溫兆倫|溫碧霞 溫碧霞|潘雲峯 潘雲峰|澳美斯牀褥 澳美斯床褥|炮台山循道衛理中學 炮台山循道衛理中學|炮台山循道衞理中學 炮台山循道衛理中學|無線新聞 無綫新聞|無線新聞台 無綫新聞台|爐峯峽 爐峰峽|牛驥同一皁 牛驥同一皁|牛驥同皁 牛驥同皁|王家衛 王家衛|王家衞 王家衛|璧峯路 璧峰路|白石台 白石臺|白石台路 白石臺路|白石臺 白石臺|白石臺路 白石臺路|白臘 白腊|白臘仔 白腊仔|白臘灣 白腊灣|百老匯 百老滙|益羣道 益群道|福羣道 福群道|純喫茶 純喫茶|純陽峯 純陽峰|緬甸台 緬甸臺|緬甸臺 緬甸臺|繼園台 繼園臺|繼園臺 繼園臺|翠羣徑 翠群徑|翡翠拉麪小籠包 翡翠拉麵小籠包|老媽拌麪 老媽拌麵|聯合祕書處 聯合秘書處|肇輝台 肇輝臺|肇輝臺 肇輝臺|育羣街 育群街|脣茶 唇茶|芝古台 芝古臺|芝古臺 芝古臺|英王麪包 英王麵包|英華台 英華臺|英華臺 英華臺|茂峯 茂峰|荃灣線 荃灣綫|荔峯街 荔峰街|萬茂台 萬茂臺|萬茂臺 萬茂臺|葉藴儀 葉蘊儀|葉蘊儀 葉蘊儀|蔡曉峯 蔡曉峰|薪諮會聯合祕書處 薪諮會聯合秘書處|衛志豪 衛志豪|衛蘭 衛蘭|衛訊 衛訊|衛詩 衛詩|衛詩雅 衛詩雅|衞志豪 衛志豪|衞蘭 衛蘭|衞訊 衛訊|衞詩 衛詩|衞詩雅 衛詩雅|西摩台 西摩臺|西摩臺 西摩臺|西灣台 西灣臺|西灣臺 西灣臺|西鐵線 西鐵綫|觀塘線 觀塘綫|諾士佛台 諾士佛臺|諾士佛臺 諾士佛臺|謝詠欣 謝咏欣|豔馬道 艷馬道|迪士尼線 迪士尼綫|郭偉強 郭偉强|郭柏妍 郭柏姸|鄧梓峯 鄧梓峰|鄭恕峯 鄭恕峰|鄭衍峯 鄭衍峰|金龍台 金龍臺|金龍臺 金龍臺|鉛礦坳 鉛鑛坳|銀台路 銀臺路|銀礦灣 銀鑛灣|銀礦灣路 銀鑛灣路|銀線灣道 銀綫灣道|銀臺路 銀臺路|鋼線灣道 鋼綫灣道|錦繡大道 錦綉大道|錦繡花園 錦綉花園|阮政峯 阮政峰|陳柏緯 陳栢緯|雅芳婷牀褥 雅芳婷床褥|雅蘭牀褥 雅蘭床褥|青蓮台 青蓮臺|青蓮臺 青蓮臺|馬鞍山循道衛理小學 馬鞍山循道衛理小學|馬鞍山循道衞理小學 馬鞍山循道衛理小學|馬頭峯 馬頭峰|駿羣路 駿群路|騰龍台 騰龍臺|騰龍臺 騰龍臺|高盛台 高盛臺|高盛臺 高盛臺|魏韻芝 魏韵芝|鳳凰台 鳳凰臺|鳳凰臺 鳳凰臺|鳳羣徑 鳳群徑|鳳羣街 鳳群街|鳳輝台 鳳輝臺|鳳輝臺 鳳輝臺|麪房街 麵房街|麪房里 麵房里|黃成 黃成|黃柏文 黃栢文|黃柏鳴 黃栢鳴|鼇磡 鰲磡|鼇磡沙 鰲磡沙|鼇磡石 鰲磡石|鼇魚頭 鰲魚頭";
1
+ const dict = "一幻拉麪 一幻拉麵|一粥麪 一粥麵|三田製麪所 三田製麵所|仙姑峯 仙姑峰|何芷姍 何芷姗|佛教茂峯法師紀念中學 佛教茂峰法師紀念中學|儒林台 儒林臺|儒林臺 儒林臺|光明台 光明臺|光明臺 光明臺|光景台 光景臺|光景臺 光景臺|光漢台 光漢臺|光漢臺 光漢臺|冠冕台 冠冕臺|冠冕臺 冠冕臺|冠峯街 冠峰街|冼靖峯 冼靖峰|列拿士地台 列拿士地臺|列拿士地臺 列拿士地臺|利羣道 利群道|利舞台廣場 利舞臺廣場|利舞臺廣場 利舞臺廣場|劉利羣 劉利群|加倫台 加倫臺|加倫臺 加倫臺|加冕台 加冕臺|加冕臺 加冕臺|北港島線 北港島綫|北環線 北環綫|北角台 北角臺|北角臺 北角臺|匯基書院 滙基書院|匯豐 滙豐|匯豐銀行 滙豐銀行|南港島線 南港島綫|南記粉麪 南記粉麵|吃茶舍 喫茶舍|合羣街 合群街|吳子沖 吳子冲|味千拉麪 味千拉麵|啟思中學 啓思中學|喫茶小舖 喫茶小舖|喫茶舍 喫茶舍|大埔循道衛理小學 大埔循道衛理小學|大埔循道衞理小學 大埔循道衛理小學|大學教育資助委員會祕書處 大學教育資助委員會秘書處|大安台 大安臺|大安臺 大安臺|大班麪包西餅 大班麵包西餅|天文台圍 天文臺圍|天文台道 天文臺道|天文臺圍 天文臺圍|天文臺道 天文臺道|姜詠鑫 姜咏鑫|孖峯嶺路 孖峰嶺路|安慶台 安慶臺|安慶臺 安慶臺|安羣街 安群街|宋皇台 宋皇臺|宋皇台道 宋皇臺道|宋皇臺 宋皇臺|宋皇臺道 宋皇臺道|宏豐台 宏豐臺|宏豐臺 宏豐臺|寧漢豪 甯漢豪|寶峯徑 寶峰徑|將軍澳循道衛理小學 將軍澳循道衛理小學|將軍澳循道衞理小學 將軍澳循道衛理小學|將軍澳線 將軍澳綫|尖尾峯 尖尾峰|尖峯山 尖峰山|尚麪 尚麵|屯馬線 屯馬綫|山坡台 山坡臺|山坡臺 山坡臺|山城小麪 山城小麵|山崎麪飽 山崎麵飽|山村台 山村臺|山村臺 山村臺|山邊台 山邊臺|山邊臺 山邊臺|峯華邨 峰華邨|峯霞道 峰霞道|巷仔見麪館 巷仔見麵館|幺鳳士多 么鳳士多|康福台 康福臺|康福臺 康福臺|建羣街 建群街|張柏芝 張柏芝|張栢芝 張栢芝|張穎康 張頴康|張華峯 張華峰|張衛健 張衛健|張衞健 張衛健|循道衛理 循道衛理|循道衞理 循道衛理|恆大 恒大|恆指 恒指|恆生 恒生|恆生大學 恒生大學|恆生指數 恒生指數|愉峯道 愉峰道|愛羣道 愛群道|截取通訊及監察事務專員祕書處 截取通訊及監察事務專員秘書處|摩頓台 摩頓臺|摩頓臺 摩頓臺|春暉台 春暉臺|春暉臺 春暉臺|景峯 景峰|景峯徑 景峰徑|朱匯林 朱滙林|朱柏康 朱栢康|朱柏謙 朱栢謙|李啟傑 李啓傑|李鉅峯 李鉅峰|杜琪峯 杜琪峰|東九龍線 東九龍綫|東山台 東山臺|東山臺 東山臺|東涌線 東涌綫|東鐵線 東鐵綫|林一峯 林一峰|林曉峯 林曉峰|林正峯 林正峰|林海峯 林海峰|林逸峯 林逸峰|桃李台 桃李臺|桃李臺 桃李臺|梁季彝中學 梁季彜中學|梁證嘉 梁証嘉|梁輝台 梁輝臺|梁輝臺 梁輝臺|梁釗峯 梁釗峰|梅豔芳 梅艷芳|榮華台 榮華臺|榮華臺 榮華臺|樂景台 樂景臺|樂景臺 樂景臺|樂羣街 樂群街|樓梯台 樓梯臺|樓梯臺 樓梯臺|機場快線 機場快綫|正斗粥麪專家 正斗粥麵專家|沙中線 沙中綫|沙田循道衛理小學 沙田循道衛理小學|沙田循道衞理小學 沙田循道衛理小學|河上鄉排峯路 河上鄉排峰路|活倫台 活倫臺|活倫臺 活倫臺|温兆倫 溫兆倫|温碧霞 溫碧霞|港島線 港島綫|溫兆倫 溫兆倫|溫碧霞 溫碧霞|潘雲峯 潘雲峰|澳美斯牀褥 澳美斯床褥|炮台山循道衛理中學 炮台山循道衛理中學|炮台山循道衞理中學 炮台山循道衛理中學|無線新聞 無綫新聞|無線新聞台 無綫新聞台|爐峯峽 爐峰峽|牛驥同一皁 牛驥同一皁|牛驥同皁 牛驥同皁|王家衛 王家衛|王家衞 王家衛|璧峯路 璧峰路|白石台 白石臺|白石台路 白石臺路|白石臺 白石臺|白石臺路 白石臺路|白臘 白腊|白臘仔 白腊仔|白臘灣 白腊灣|百老匯 百老滙|益羣道 益群道|福羣道 福群道|純喫茶 純喫茶|純陽峯 純陽峰|緬甸台 緬甸臺|緬甸臺 緬甸臺|繼園台 繼園臺|繼園臺 繼園臺|翠羣徑 翠群徑|翡翠拉麪小籠包 翡翠拉麵小籠包|老媽拌麪 老媽拌麵|聯合祕書處 聯合秘書處|肇輝台 肇輝臺|肇輝臺 肇輝臺|育羣街 育群街|脣茶 唇茶|芝古台 芝古臺|芝古臺 芝古臺|英王麪包 英王麵包|英華台 英華臺|英華臺 英華臺|茂峯 茂峰|荃灣線 荃灣綫|荔峯街 荔峰街|萬茂台 萬茂臺|萬茂臺 萬茂臺|葉藴儀 葉蘊儀|葉蘊儀 葉蘊儀|蔡曉峯 蔡曉峰|薪諮會聯合祕書處 薪諮會聯合秘書處|衛志豪 衛志豪|衛蘭 衛蘭|衛訊 衛訊|衛詩 衛詩|衛詩雅 衛詩雅|衞志豪 衛志豪|衞蘭 衛蘭|衞訊 衛訊|衞詩 衛詩|衞詩雅 衛詩雅|西摩台 西摩臺|西摩臺 西摩臺|西灣台 西灣臺|西灣臺 西灣臺|西鐵線 西鐵綫|觀塘線 觀塘綫|諾士佛台 諾士佛臺|諾士佛臺 諾士佛臺|謝詠欣 謝咏欣|豔馬道 艷馬道|迪士尼線 迪士尼綫|郭偉強 郭偉强|郭柏妍 郭柏姸|鄧梓峯 鄧梓峰|鄭恕峯 鄭恕峰|鄭衍峯 鄭衍峰|金龍台 金龍臺|金龍臺 金龍臺|鉛礦坳 鉛鑛坳|銀台路 銀臺路|銀礦灣 銀鑛灣|銀礦灣路 銀鑛灣路|銀線灣道 銀綫灣道|銀臺路 銀臺路|鋼線灣道 鋼綫灣道|錦繡大道 錦綉大道|錦繡花園 錦綉花園|阮政峯 阮政峰|陳柏緯 陳栢緯|陽光衛視 陽光衛視|雅芳婷牀褥 雅芳婷床褥|雅蘭牀褥 雅蘭床褥|青蓮台 青蓮臺|青蓮臺 青蓮臺|馬鞍山循道衛理小學 馬鞍山循道衛理小學|馬鞍山循道衞理小學 馬鞍山循道衛理小學|馬頭峯 馬頭峰|駿羣路 駿群路|騰龍台 騰龍臺|騰龍臺 騰龍臺|高盛台 高盛臺|高盛臺 高盛臺|魏韻芝 魏韵芝|鳳凰台 鳳凰臺|鳳凰臺 鳳凰臺|鳳凰衛視 鳳凰衛視|鳳羣徑 鳳群徑|鳳羣街 鳳群街|鳳輝台 鳳輝臺|鳳輝臺 鳳輝臺|麪房街 麵房街|麪房里 麵房里|黃成 黃成|黃柏文 黃栢文|黃柏鳴 黃栢鳴|鼇磡 鰲磡|鼇磡沙 鰲磡沙|鼇磡石 鰲磡石|鼇魚頭 鰲魚頭";
2
2
  export default dict;
@@ -1,2 +1,2 @@
1
- const dict = "鹽 䀋|萬 万|與 与|兩 両|竝 並|乘 乗|亂 乱|龜 亀|豫 予|爭 争|亙 亘|亞 亜|佛 仏|假 仮|會 会|傳 伝|體 体|餘 余|倂 併|俠 侠|價 価|值 値|俱 倶|儉 倹|僞 偽|兔 兎|兒 児|黨 党|內 内|圓 円|寫 写|凛 凜|處 処|剎 刹|劍 剣|劑 剤|剩 剰|勵 励|勞 労|效 効|敕 勅|勸 勧|勳 勲|勻 匀|區 区|醫 医|單 単|卽 即|卻 却|廁 厠|嚴 厳|參 参|雙 双|收 収|敍 叙|敘 叙|臺 台|號 号|吳 呉|咒 呪|脣 唇|啞 唖|營 営|噓 嘘|囑 嘱|嚙 噛|團 団|圍 囲|圖 図|國 国|圈 圏|壓 圧|墮 堕|壘 塁|填 塡|增 増|壞 壊|壤 壌|壯 壮|聲 声|壹 壱|賣 売|變 変|奧 奥|奬 奨|獎 奨|姊 姉|姬 姫|孃 嬢|學 学|寶 宝|實 実|寬 寛|寢 寝|對 対|壽 寿|專 専|將 将|堯 尭|盡 尽|屆 届|屬 属|嶽 岳|峽 峡|峯 峰|巖 巌|巢 巣|卷 巻|帶 帯|歸 帰|廳 庁|廣 広|莊 庄|牀 床|廢 廃|辨 弁|辯 弁|瓣 弁|貳 弐|彌 弥|彎 弯|彈 弾|當 当|彥 彦|徑 径|從 従|禦 御|德 徳|徵 徴|應 応|戀 恋|恆 恒|惠 恵|悅 悦|惱 悩|惡 悪|慘 惨|愼 慎|懷 懐|戰 戦|戲 戯|戶 戸|戾 戻|纔 才|拂 払|拔 抜|擇 択|擔 担|拜 拝|據 拠|擴 拡|擧 挙|舉 挙|挾 挟|插 挿|搜 捜|揭 掲|摑 掴|搔 掻|搖 揺|攝 摂|擊 撃|攪 撹|數 数|齊 斉|齋 斎|斷 断|舊 旧|晝 昼|晄 晃|晉 晋|晚 晩|曉 暁|曆 暦|暨 曁|曾 曽|條 条|來 来|樞 枢|查 査|榮 栄|櫻 桜|枡 桝|棧 桟|檜 桧|檢 検|榆 楡|樓 楼|樂 楽|槪 概|樣 様|槇 槙|權 権|橫 横|缺 欠|歐 欧|歡 歓|步 歩|齒 歯|歲 歳|歷 歴|殘 残|毆 殴|殼 殻|每 毎|氣 気|冰 氷|污 汚|沒 没|澤 沢|濾 沪|淨 浄|淺 浅|濱 浜|淚 涙|濤 涛|渴 渇|濟 済|涉 渉|澁 渋|澀 渋|溪 渓|溫 温|灣 湾|濕 湿|溼 湿|滿 満|潑 溌|瀧 滝|滯 滞|潛 潜|瀨 瀬|燈 灯|爐 炉|點 点|爲 為|焰 焔|燒 焼|菸 煙|犧 犠|狀 状|獨 独|狹 狭|獵 猟|貓 猫|獻 献|獸 獣|甁 瓶|產 産|畫 画|疊 畳|瘦 痩|癡 痴|痹 痺|發 発|皋 皐|盜 盗|縣 県|眞 真|硏 研|碎 砕|礪 砺|禮 礼|禰 祢|禱 祷|祿 禄|禪 禅|祕 秘|稱 称|稅 税|棱 稜|稻 稲|穗 穂|穩 穏|穰 穣|竊 窃|竈 竃|龍 竜|粹 粋|肅 粛|妝 粧|糉 粽|絲 糸|經 経|繪 絵|絕 絶|繼 継|續 続|總 総|綠 緑|緖 緒|緣 縁|繩 縄|縱 縦|纖 繊|繫 繋|繡 繍|罐 缶|羣 群|飜 翻|聰 聡|聽 聴|膽 胆|腳 脚|脫 脱|腦 脳|臟 臓|舍 舎|鋪 舖|艷 艶|蘆 芦|藝 芸|莖 茎|荔 茘|萊 莱|萠 萌|蔥 葱|蔣 蒋|藏 蔵|薰 薫|藥 薬|虛 虚|蟲 虫|蠶 蚕|螢 蛍|蠻 蛮|蟬 蝉|蠟 蝋|衞 衛|裝 装|襃 褒|霸 覇|覺 覚|覽 覧|觀 観|觸 触|譯 訳|證 証|譽 誉|說 説|讀 読|謠 謡|讓 譲|豐 豊|贊 賛|贗 贋|踐 践|轉 転|輕 軽|輛 輌|辭 辞|邊 辺|遞 逓|聯 連|遲 遅|遙 遥|郞 郎|鄕 郷|鄉 郷|醉 酔|醱 醗|醬 醤|釀 醸|釋 釈|鐵 鉄|鑛 鉱|錢 銭|銳 鋭|鑄 鋳|鍊 錬|錄 録|鎭 鎮|關 関|閱 閲|鬭 闘|鬥 闘|陷 陥|險 険|隨 随|隱 隠|鄰 隣|雜 雑|靈 霊|靜 静|穎 頴|賴 頼|顏 顔|顯 顕|餠 餅|驛 駅|驅 駆|騷 騒|驗 験|髓 髄|髮 髪|鷗 鴎|鷄 鶏|雞 鶏|鹼 鹸|麥 麦|麴 麹|麵 麺|麪 麺|黃 黄|黑 黒|默 黙|鱉 鼈|齡 齢";
1
+ const dict = "鹽 塩|萬 万|與 与|兩 両|竝 並|乘 乗|亂 乱|龜 亀|豫 予|爭 争|亙 亘|亞 亜|佛 仏|假 仮|會 会|傳 伝|體 体|餘 余|倂 併|俠 侠|價 価|值 値|俱 倶|儉 倹|僞 偽|兔 兎|兒 児|黨 党|內 内|圓 円|寫 写|凛 凜|處 処|剎 刹|劍 剣|劑 剤|剩 剰|勵 励|勞 労|效 効|敕 勅|勸 勧|勳 勲|勻 匀|區 区|醫 医|單 単|卽 即|卻 却|廁 厠|嚴 厳|參 参|雙 双|收 収|敍 叙|敘 叙|臺 台|號 号|吳 呉|咒 呪|脣 唇|啞 唖|營 営|噓 嘘|囑 嘱|嚙 噛|團 団|圍 囲|圖 図|國 国|圈 圏|壓 圧|墮 堕|壘 塁|填 塡|增 増|壞 壊|壤 壌|壯 壮|聲 声|壹 壱|賣 売|變 変|奧 奥|奬 奨|獎 奨|姊 姉|姬 姫|孃 嬢|學 学|寶 宝|實 実|寬 寛|寢 寝|對 対|壽 寿|專 専|將 将|堯 尭|盡 尽|屆 届|屬 属|嶽 岳|峽 峡|峯 峰|巖 巌|巢 巣|卷 巻|帶 帯|歸 帰|廳 庁|廣 広|莊 荘|牀 床|廢 廃|辨 弁|辯 弁|瓣 弁|貳 弐|彌 弥|彎 弯|彈 弾|當 当|彥 彦|徑 径|從 従|禦 御|德 徳|徵 徴|應 応|戀 恋|恆 恒|惠 恵|悅 悦|惱 悩|惡 悪|慘 惨|愼 慎|懷 懐|戰 戦|戲 戯|戶 戸|戾 戻|纔 才|拂 払|拔 抜|擇 択|擔 担|拜 拝|據 拠|擴 拡|擧 挙|舉 挙|挾 挟|插 挿|搜 捜|揭 掲|摑 掴|搔 掻|搖 揺|攝 摂|擊 撃|攪 撹|數 数|齊 斉|齋 斎|斷 断|舊 旧|晝 昼|晄 晃|晉 晋|晚 晩|曉 暁|曆 暦|暨 曁|曾 曽|條 条|來 来|樞 枢|查 査|榮 栄|櫻 桜|枡 桝|棧 桟|檜 桧|檢 検|榆 楡|樓 楼|樂 楽|槪 概|樣 様|槇 槙|權 権|橫 横|缺 欠|歐 欧|歡 歓|步 歩|齒 歯|歲 歳|歷 歴|殘 残|毆 殴|殼 殻|每 毎|氣 気|冰 氷|污 汚|沒 没|澤 沢|濾 沪|淨 浄|淺 浅|濱 浜|淚 涙|濤 涛|渴 渇|濟 済|涉 渉|澁 渋|澀 渋|溪 渓|溫 温|灣 湾|濕 湿|溼 湿|滿 満|潑 溌|瀧 滝|滯 滞|潛 潜|瀨 瀬|燈 灯|爐 炉|點 点|爲 為|焰 焔|燒 焼|菸 煙|犧 犠|狀 状|獨 独|狹 狭|獵 猟|貓 猫|獻 献|獸 獣|甁 瓶|產 産|畫 画|疊 畳|瘦 痩|癡 痴|痹 痺|發 発|皋 皐|盜 盗|縣 県|眞 真|硏 研|碎 砕|礪 砺|禮 礼|禰 祢|禱 祷|祿 禄|禪 禅|祕 秘|稱 称|稅 税|棱 稜|稻 稲|穗 穂|穩 穏|穰 穣|竊 窃|竈 竃|龍 竜|粹 粋|肅 粛|妝 粧|糉 粽|絲 糸|經 経|繪 絵|絕 絶|繼 継|續 続|總 総|綠 緑|緖 緒|緣 縁|繩 縄|縱 縦|纖 繊|繫 繋|繡 繍|罐 缶|羣 群|飜 翻|聰 聡|聽 聴|膽 胆|腳 脚|脫 脱|腦 脳|臟 臓|舍 舎|鋪 舗|艷 艶|蘆 芦|藝 芸|莖 茎|荔 茘|萊 莱|萠 萌|蔥 葱|蔣 蒋|藏 蔵|薰 薫|藥 薬|虛 虚|蟲 虫|蠶 蚕|螢 蛍|蠻 蛮|蟬 蝉|蠟 蝋|衞 衛|裝 装|襃 褒|霸 覇|覺 覚|覽 覧|觀 観|觸 触|譯 訳|證 証|譽 誉|說 説|讀 読|謠 謡|讓 譲|豐 豊|贊 賛|贗 贋|踐 践|轉 転|輕 軽|輛 輌|辭 辞|邊 辺|遞 逓|聯 連|遲 遅|遙 遥|郞 郎|鄕 郷|鄉 郷|醉 酔|醱 醗|醬 醤|釀 醸|釋 釈|鐵 鉄|鑛 鉱|錢 銭|銳 鋭|鑄 鋳|鍊 錬|錄 録|鎭 鎮|關 関|閱 閲|鬭 闘|鬥 闘|陷 陥|險 険|隨 随|隱 隠|鄰 隣|雜 雑|靈 霊|靜 静|穎 頴|賴 頼|顏 顔|顯 顕|餠 餅|驛 駅|驅 駆|騷 騒|驗 験|髓 髄|髮 髪|鷗 鴎|鷄 鶏|雞 鶏|鹼 鹸|麥 麦|麴 麹|麵 麺|麪 麺|黃 黄|黑 黒|默 黙|鱉 鼈|齡 齢";
2
2
  export default dict;
@@ -0,0 +1,2 @@
1
+ declare const dict: string;
2
+ export default dict;