js-opencc 1.4.1 → 1.4.3
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.
- package/README.md +111 -129
- package/README.zh-Hant.md +222 -0
- package/data/custom/CNTWPhrases.txt +6 -0
- package/dist/bundles/cn2t.d.ts +2 -3
- package/dist/bundles/cn2t.js +36 -11
- package/dist/bundles/full.d.ts +2 -3
- package/dist/bundles/full.js +22 -8
- package/dist/bundles/t2cn.d.ts +2 -3
- package/dist/bundles/t2cn.js +28 -9
- package/dist/converter.d.ts +6 -1
- package/dist/converter.js +43 -10
- package/dist/core.d.ts +107 -17
- package/dist/core.js +377 -51
- package/dist/dict/CNTWPhrases.d.ts +2 -3
- package/dist/dict/CNTWPhrases.js +2 -2
- package/dist/dict/HKPhrases.d.ts +2 -3
- package/dist/dict/HKPhrases.js +2 -2
- package/dist/dict/HKPhrasesRev.d.ts +2 -3
- package/dist/dict/HKPhrasesRev.js +2 -2
- package/dist/dict/HKVariants.d.ts +2 -3
- package/dist/dict/HKVariants.js +2 -2
- package/dist/dict/HKVariantsPhrases.d.ts +2 -3
- package/dist/dict/HKVariantsPhrases.js +2 -2
- package/dist/dict/HKVariantsRev.d.ts +2 -3
- package/dist/dict/HKVariantsRev.js +2 -2
- package/dist/dict/HKVariantsRevPhrases.d.ts +2 -3
- package/dist/dict/HKVariantsRevPhrases.js +2 -2
- package/dist/dict/JPShinjitaiCharacters.d.ts +2 -3
- package/dist/dict/JPShinjitaiCharacters.js +2 -2
- package/dist/dict/JPShinjitaiCharactersRev.d.ts +2 -3
- package/dist/dict/JPShinjitaiCharactersRev.js +2 -2
- package/dist/dict/JPShinjitaiPhrases.d.ts +2 -3
- package/dist/dict/JPShinjitaiPhrases.js +2 -2
- package/dist/dict/STCharacters.d.ts +2 -3
- package/dist/dict/STCharacters.js +2 -2
- package/dist/dict/STPhrases.d.ts +2 -3
- package/dist/dict/STPhrases.js +2 -2
- package/dist/dict/STPhrases_GeneratedFromRegionalPhrases.d.ts +2 -0
- package/dist/dict/STPhrases_GeneratedFromRegionalPhrases.js +2 -0
- package/dist/dict/TSCharacters.d.ts +2 -3
- package/dist/dict/TSCharacters.js +2 -2
- package/dist/dict/TSPhrases.d.ts +2 -3
- package/dist/dict/TSPhrases.js +2 -2
- package/dist/dict/TWPhrases.d.ts +2 -3
- package/dist/dict/TWPhrases.js +2 -2
- package/dist/dict/TWPhrasesRev.d.ts +2 -3
- package/dist/dict/TWPhrasesRev.js +2 -2
- package/dist/dict/TWVariants.d.ts +2 -3
- package/dist/dict/TWVariants.js +2 -2
- package/dist/dict/TWVariantsPhrases.d.ts +2 -3
- package/dist/dict/TWVariantsPhrases.js +2 -2
- package/dist/dict/TWVariantsRev.d.ts +2 -3
- package/dist/dict/TWVariantsRev.js +2 -2
- package/dist/dict/TWVariantsRevPhrases.d.ts +2 -3
- package/dist/dict/TWVariantsRevPhrases.js +2 -2
- package/dist/dict/index.d.ts +0 -1
- package/dist/dict/index.js +1 -1
- package/dist/html-converter.d.ts +0 -1
- package/dist/html-converter.js +65 -26
- package/dist/index.d.ts +2 -3
- package/dist/index.js +14 -5
- package/dist/presets.d.ts +44 -1
- package/dist/presets.js +58 -2
- package/dist/umd/cn2t.js +554 -102
- package/dist/umd/cn2t.js.map +1 -1
- package/dist/umd/cn2t.min.js +1 -1
- package/dist/umd/cn2t.min.js.map +1 -1
- package/dist/umd/full.js +560 -119
- package/dist/umd/full.js.map +1 -1
- package/dist/umd/full.min.js +1 -1
- package/dist/umd/full.min.js.map +1 -1
- package/dist/umd/t2cn.js +548 -103
- package/dist/umd/t2cn.js.map +1 -1
- package/dist/umd/t2cn.min.js +1 -1
- package/dist/umd/t2cn.min.js.map +1 -1
- package/package.json +2 -1
- package/dist/bundles/cn2t.d.ts.map +0 -1
- package/dist/bundles/cn2t.js.map +0 -1
- package/dist/bundles/full.d.ts.map +0 -1
- package/dist/bundles/full.js.map +0 -1
- package/dist/bundles/t2cn.d.ts.map +0 -1
- package/dist/bundles/t2cn.js.map +0 -1
- package/dist/converter.d.ts.map +0 -1
- package/dist/converter.js.map +0 -1
- package/dist/core.d.ts.map +0 -1
- package/dist/core.js.map +0 -1
- package/dist/dict/CNTWPhrases.d.ts.map +0 -1
- package/dist/dict/CNTWPhrases.js.map +0 -1
- package/dist/dict/HKPhrases.d.ts.map +0 -1
- package/dist/dict/HKPhrases.js.map +0 -1
- package/dist/dict/HKPhrasesRev.d.ts.map +0 -1
- package/dist/dict/HKPhrasesRev.js.map +0 -1
- package/dist/dict/HKVariants.d.ts.map +0 -1
- package/dist/dict/HKVariants.js.map +0 -1
- package/dist/dict/HKVariantsPhrases.d.ts.map +0 -1
- package/dist/dict/HKVariantsPhrases.js.map +0 -1
- package/dist/dict/HKVariantsRev.d.ts.map +0 -1
- package/dist/dict/HKVariantsRev.js.map +0 -1
- package/dist/dict/HKVariantsRevPhrases.d.ts.map +0 -1
- package/dist/dict/HKVariantsRevPhrases.js.map +0 -1
- package/dist/dict/JPShinjitaiCharacters.d.ts.map +0 -1
- package/dist/dict/JPShinjitaiCharacters.js.map +0 -1
- package/dist/dict/JPShinjitaiCharactersRev.d.ts.map +0 -1
- package/dist/dict/JPShinjitaiCharactersRev.js.map +0 -1
- package/dist/dict/JPShinjitaiPhrases.d.ts.map +0 -1
- package/dist/dict/JPShinjitaiPhrases.js.map +0 -1
- package/dist/dict/STCharacters.d.ts.map +0 -1
- package/dist/dict/STCharacters.js.map +0 -1
- package/dist/dict/STPhrases.d.ts.map +0 -1
- package/dist/dict/STPhrases.js.map +0 -1
- package/dist/dict/TSCharacters.d.ts.map +0 -1
- package/dist/dict/TSCharacters.js.map +0 -1
- package/dist/dict/TSPhrases.d.ts.map +0 -1
- package/dist/dict/TSPhrases.js.map +0 -1
- package/dist/dict/TWPhrases.d.ts.map +0 -1
- package/dist/dict/TWPhrases.js.map +0 -1
- package/dist/dict/TWPhrasesRev.d.ts.map +0 -1
- package/dist/dict/TWPhrasesRev.js.map +0 -1
- package/dist/dict/TWVariants.d.ts.map +0 -1
- package/dist/dict/TWVariants.js.map +0 -1
- package/dist/dict/TWVariantsPhrases.d.ts.map +0 -1
- package/dist/dict/TWVariantsPhrases.js.map +0 -1
- package/dist/dict/TWVariantsRev.d.ts.map +0 -1
- package/dist/dict/TWVariantsRev.js.map +0 -1
- package/dist/dict/TWVariantsRevPhrases.d.ts.map +0 -1
- package/dist/dict/TWVariantsRevPhrases.js.map +0 -1
- package/dist/dict/index.d.ts.map +0 -1
- package/dist/dict/index.js.map +0 -1
- package/dist/html-converter.d.ts.map +0 -1
- package/dist/html-converter.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/presets.d.ts.map +0 -1
- package/dist/presets.js.map +0 -1
package/dist/core.js
CHANGED
|
@@ -2,27 +2,57 @@
|
|
|
2
2
|
* OpenCC JS - Core Conversion Engine
|
|
3
3
|
* Based on Trie data structure for efficient longest-match conversion
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* `input[i]` 起是不是一个合法的代理对(高代理后面真的跟着低代理)。
|
|
7
|
+
*
|
|
8
|
+
* 存在的唯一理由是防一类静默错误:热循环从 `codePointAt` 换成 `charCodeAt` 之后,
|
|
9
|
+
* 「孤立高代理」不再天然按一个单元处理——只判高代理就跳 2 会**吞掉它后面那个
|
|
10
|
+
* 字符**,那个字符于是永远参与不了匹配,输出少转一处且不报错。真实词典里没有
|
|
11
|
+
* 孤立代理,所以 556 官方用例和整段语料对拍都发现不了,只有专门造畸形 UTF-16
|
|
12
|
+
* 才暴露。
|
|
13
|
+
*
|
|
14
|
+
* 三处不匹配步进(Trie.convert / Trie.segment / maskWithTrie)共用它。
|
|
15
|
+
*/
|
|
16
|
+
function isSurrogatePair(input, i, length) {
|
|
17
|
+
const hi = input.charCodeAt(i);
|
|
18
|
+
if (hi < 0xd800 || hi > 0xdbff || i + 1 >= length)
|
|
19
|
+
return false;
|
|
20
|
+
const lo = input.charCodeAt(i + 1);
|
|
21
|
+
return lo >= 0xdc00 && lo <= 0xdfff;
|
|
22
|
+
}
|
|
5
23
|
/**
|
|
6
24
|
* Trie tree for efficient string matching and conversion
|
|
7
25
|
*/
|
|
8
26
|
export class Trie {
|
|
9
|
-
constructor() {
|
|
10
|
-
this.map = new Map();
|
|
11
|
-
}
|
|
12
27
|
/**
|
|
13
28
|
* Add a word to the trie
|
|
14
29
|
* @param key - The string to match
|
|
15
30
|
* @param value - The replacement string
|
|
16
31
|
*/
|
|
17
32
|
addWord(key, value) {
|
|
33
|
+
// charCodeAt + 手动代理对配对,不走 for..of 迭代器/codePointAt:构建整棵
|
|
34
|
+
// STPhrases 树实测 1.72×(10.3 → 6.0 ms)。五个走 trie 的循环(addWord /
|
|
35
|
+
// findLongestMatch / matchLongestInto / convert / segment)统一这一种写法,
|
|
36
|
+
// 改其一记得同步其余。
|
|
18
37
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
19
38
|
let node = this;
|
|
20
|
-
for (
|
|
21
|
-
|
|
22
|
-
|
|
39
|
+
for (let i = 0; i < key.length;) {
|
|
40
|
+
let codePoint = key.charCodeAt(i);
|
|
41
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff && i + 1 < key.length) {
|
|
42
|
+
const lo = key.charCodeAt(i + 1);
|
|
43
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
44
|
+
codePoint = (codePoint - 0xd800) * 0x400 + (lo - 0xdc00) + 0x10000;
|
|
45
|
+
i += 2;
|
|
46
|
+
}
|
|
47
|
+
else
|
|
48
|
+
i += 1; // 孤立高代理,按单元收——与 codePointAt 行为一致
|
|
49
|
+
}
|
|
50
|
+
else
|
|
51
|
+
i += 1;
|
|
52
|
+
let nextNode = node.map?.get(codePoint);
|
|
23
53
|
if (!nextNode) {
|
|
24
54
|
nextNode = new Trie();
|
|
25
|
-
node.map.set(codePoint, nextNode);
|
|
55
|
+
(node.map ?? (node.map = new Map())).set(codePoint, nextNode);
|
|
26
56
|
}
|
|
27
57
|
node = nextNode;
|
|
28
58
|
}
|
|
@@ -75,17 +105,27 @@ export class Trie {
|
|
|
75
105
|
* not relative to `start`. Callers should check `end > start`.
|
|
76
106
|
* @param input - The string to search
|
|
77
107
|
* @param start - The index to start matching from
|
|
108
|
+
*
|
|
109
|
+
* 热路径请用 {@link matchLongestInto}(免分配变体,语义一致)——两边改其一必同步另一个。
|
|
78
110
|
*/
|
|
79
111
|
findLongestMatch(input, start) {
|
|
112
|
+
// 同 addWord:charCodeAt + 手动配对(热循环写法统一,见 addWord 注释)。
|
|
80
113
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
81
114
|
let node = this;
|
|
82
115
|
let matchEnd = 0;
|
|
83
116
|
let matchValue;
|
|
84
117
|
for (let j = start; j < input.length && node;) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
j
|
|
88
|
-
|
|
118
|
+
let codePoint = input.charCodeAt(j);
|
|
119
|
+
let step = 1;
|
|
120
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff && j + 1 < input.length) {
|
|
121
|
+
const lo = input.charCodeAt(j + 1);
|
|
122
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
123
|
+
codePoint = (codePoint - 0xd800) * 0x400 + (lo - 0xdc00) + 0x10000;
|
|
124
|
+
step = 2;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
j += step;
|
|
128
|
+
const nextNode = node.map?.get(codePoint);
|
|
89
129
|
if (!nextNode)
|
|
90
130
|
break;
|
|
91
131
|
node = nextNode;
|
|
@@ -96,6 +136,39 @@ export class Trie {
|
|
|
96
136
|
}
|
|
97
137
|
return { end: matchEnd, value: matchValue };
|
|
98
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* findLongestMatch 的免分配变体:结果写进调用方复用的 `out`,不造对象。
|
|
141
|
+
* 给每个位置都要探一次的热调用方用(maskWithTrie 一个位置一次——对象版
|
|
142
|
+
* 在 4 万字语料上就是 4 万次 {end,value} 分配)。语义与 findLongestMatch
|
|
143
|
+
* 完全一致,改其一必同步另一个。
|
|
144
|
+
*/
|
|
145
|
+
matchLongestInto(input, start, out) {
|
|
146
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
147
|
+
let node = this;
|
|
148
|
+
out.end = 0;
|
|
149
|
+
out.value = undefined;
|
|
150
|
+
const length = input.length;
|
|
151
|
+
for (let j = start; j < length && node;) {
|
|
152
|
+
let codePoint = input.charCodeAt(j);
|
|
153
|
+
let step = 1;
|
|
154
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff && j + 1 < length) {
|
|
155
|
+
const lo = input.charCodeAt(j + 1);
|
|
156
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
157
|
+
codePoint = (codePoint - 0xd800) * 0x400 + (lo - 0xdc00) + 0x10000;
|
|
158
|
+
step = 2;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
j += step;
|
|
162
|
+
const nextNode = node.map?.get(codePoint);
|
|
163
|
+
if (!nextNode)
|
|
164
|
+
break;
|
|
165
|
+
node = nextNode;
|
|
166
|
+
if (node.value !== undefined) {
|
|
167
|
+
out.end = j;
|
|
168
|
+
out.value = node.value;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
99
172
|
/**
|
|
100
173
|
* Convert a string using the trie
|
|
101
174
|
* Uses longest match algorithm for optimal conversion
|
|
@@ -112,11 +185,19 @@ export class Trie {
|
|
|
112
185
|
let matchEnd = 0;
|
|
113
186
|
let matchValue;
|
|
114
187
|
// Find the longest match starting at position i
|
|
188
|
+
// (charCodeAt + 手动配对,写法统一见 addWord 注释;实测 convert 1.30×)
|
|
115
189
|
for (let j = i; j < length && currentNode;) {
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
j
|
|
119
|
-
|
|
190
|
+
let codePoint = input.charCodeAt(j);
|
|
191
|
+
let step = 1;
|
|
192
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff && j + 1 < length) {
|
|
193
|
+
const lo = input.charCodeAt(j + 1);
|
|
194
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
195
|
+
codePoint = (codePoint - 0xd800) * 0x400 + (lo - 0xdc00) + 0x10000;
|
|
196
|
+
step = 2;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
j += step;
|
|
200
|
+
const nextNode = currentNode.map?.get(codePoint);
|
|
120
201
|
if (!nextNode) {
|
|
121
202
|
break;
|
|
122
203
|
}
|
|
@@ -140,8 +221,7 @@ export class Trie {
|
|
|
140
221
|
if (originalStart === null) {
|
|
141
222
|
originalStart = i;
|
|
142
223
|
}
|
|
143
|
-
|
|
144
|
-
i += codePoint > 0xffff ? 2 : 1;
|
|
224
|
+
i += isSurrogatePair(input, i, length) ? 2 : 1;
|
|
145
225
|
}
|
|
146
226
|
}
|
|
147
227
|
// Flush remaining original text
|
|
@@ -150,6 +230,131 @@ export class Trie {
|
|
|
150
230
|
}
|
|
151
231
|
return result.join("");
|
|
152
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Split input into segments on this trie's entries, longest match first.
|
|
235
|
+
*
|
|
236
|
+
* Every matched entry becomes its own segment, and the runs between them are
|
|
237
|
+
* emitted as segments too, so `segments.join("")` reconstructs the input
|
|
238
|
+
* exactly. Nothing is converted here — only cut.
|
|
239
|
+
*
|
|
240
|
+
* Exists for {@link ConverterFactoryWithSegmentation}; see there for why the
|
|
241
|
+
* cut changes results.
|
|
242
|
+
*
|
|
243
|
+
* @param input - The string to split
|
|
244
|
+
* @returns Segments whose concatenation equals `input`
|
|
245
|
+
*/
|
|
246
|
+
segment(input) {
|
|
247
|
+
const segments = [];
|
|
248
|
+
const length = input.length;
|
|
249
|
+
let originalStart = null;
|
|
250
|
+
for (let i = 0; i < length;) {
|
|
251
|
+
// Inlined longest-match walk, same as `convert`. Calling
|
|
252
|
+
// `findLongestMatch` here instead would allocate a `{ end, value }`
|
|
253
|
+
// object at every position — on Chinese text that is roughly one
|
|
254
|
+
// short-lived object per character, and segmentation already runs an
|
|
255
|
+
// extra full pass. Measured worth keeping inline.
|
|
256
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
257
|
+
let node = this;
|
|
258
|
+
let end = 0;
|
|
259
|
+
for (let j = i; j < length && node;) {
|
|
260
|
+
let codePoint = input.charCodeAt(j);
|
|
261
|
+
let step = 1;
|
|
262
|
+
if (codePoint >= 0xd800 && codePoint <= 0xdbff && j + 1 < length) {
|
|
263
|
+
const lo = input.charCodeAt(j + 1);
|
|
264
|
+
if (lo >= 0xdc00 && lo <= 0xdfff) {
|
|
265
|
+
codePoint = (codePoint - 0xd800) * 0x400 + (lo - 0xdc00) + 0x10000;
|
|
266
|
+
step = 2;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
j += step;
|
|
270
|
+
const nextNode = node.map?.get(codePoint);
|
|
271
|
+
if (!nextNode)
|
|
272
|
+
break;
|
|
273
|
+
node = nextNode;
|
|
274
|
+
if (node.value !== undefined)
|
|
275
|
+
end = j;
|
|
276
|
+
}
|
|
277
|
+
if (end > i) {
|
|
278
|
+
if (originalStart !== null) {
|
|
279
|
+
segments.push(input.slice(originalStart, i));
|
|
280
|
+
originalStart = null;
|
|
281
|
+
}
|
|
282
|
+
segments.push(input.slice(i, end));
|
|
283
|
+
i = end;
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
if (originalStart === null) {
|
|
287
|
+
originalStart = i;
|
|
288
|
+
}
|
|
289
|
+
i += isSurrogatePair(input, i, length) ? 2 : 1;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
if (originalStart !== null) {
|
|
293
|
+
segments.push(input.slice(originalStart, length));
|
|
294
|
+
}
|
|
295
|
+
return segments;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* CJK Compatibility Ideographs, both blocks: U+F900..U+FAFF and
|
|
300
|
+
* U+2F800..U+2FA1F. Characters here duplicate unified ideographs and exist
|
|
301
|
+
* only to round-trip legacy encodings — 類 U+F9D0 renders the same as
|
|
302
|
+
* 類 U+985E but is a different code point, so it misses dictionary lookups,
|
|
303
|
+
* searches and string comparisons.
|
|
304
|
+
*/
|
|
305
|
+
// ⚠ 端点一律写转义,不要写字面字符。这里原来是字面的「豈」,本意 U+F900
|
|
306
|
+
// (CJK 兼容汉字),但它和 U+8C48(普通汉字)**字形完全一样**,某次被 NFC
|
|
307
|
+
// 归一化悄悄换掉了——范围于是从 [F900,FAFF] 变成 [8C48,FAFF],覆盖了大半常用
|
|
308
|
+
// 汉字和整个 PUA。输出仍然正确(normalize 对普通字是恒等),只是每段中文都要
|
|
309
|
+
// 白跑一遍 replace。肉眼、grep、测试全都看不出来,只有把端点打成码位才现形。
|
|
310
|
+
const COMPATIBILITY_IDEOGRAPHS = /[\uF900-\uFAFF\u{2F800}-\u{2FA1F}]/gu;
|
|
311
|
+
/**
|
|
312
|
+
* Fold CJK Compatibility Ideographs to their unified equivalents.
|
|
313
|
+
*
|
|
314
|
+
* OpenCC does this with a 1002-entry dictionary
|
|
315
|
+
* (`CJK_Compatibility_Ideographs`) loaded as a normalization step by every
|
|
316
|
+
* config. **We ship no such table.** Those mappings are canonical singleton
|
|
317
|
+
* decompositions in the Unicode standard, which is precisely what
|
|
318
|
+
* `String.prototype.normalize` performs — checked entry by entry against
|
|
319
|
+
* opencc-js's copy: all 1002 agree, and NFC folds nothing the table misses.
|
|
320
|
+
* So ~8.7 KB of data becomes a call into the engine's own ICU, which has the
|
|
321
|
+
* side benefit of tracking new Unicode versions without a resync.
|
|
322
|
+
*
|
|
323
|
+
* Two deliberate details:
|
|
324
|
+
*
|
|
325
|
+
* 1. **NFC, not NFKC.** NFKC would also fold full-width forms (`,`→`,`,
|
|
326
|
+
* `A`→`A`) and enclosed characters (`㈱`→`(株)`). In Chinese prose that is
|
|
327
|
+
* destructive: full-width punctuation is correct typography, not a
|
|
328
|
+
* compatibility artifact.
|
|
329
|
+
* 2. **Only the two compatibility blocks are touched**, not the whole string.
|
|
330
|
+
* Whole-string NFC would also compose combining sequences the caller never
|
|
331
|
+
* asked us to touch. The pre-test means ordinary text — which has no
|
|
332
|
+
* compatibility ideographs at all — is returned as-is with no allocation.
|
|
333
|
+
*
|
|
334
|
+
* @param input - The string to normalize
|
|
335
|
+
* @returns The string with compatibility ideographs folded
|
|
336
|
+
*/
|
|
337
|
+
export function normalizeCompatibilityIdeographs(input) {
|
|
338
|
+
// 手写 charCodeAt 预扫描,正则 .test 的 5×(0.68 → 0.14 ms / 4 万字):
|
|
339
|
+
// 兼容区只有两段——BMP 的 U+F900–FAFF,和增补区 U+2F800–2FA1F(整段的高代理
|
|
340
|
+
// 恰好都是 U+D87E)。汉字主体 U+4E00–9FFF 一次比较出局。扫描判据是正则的
|
|
341
|
+
// 超集(D87E 也覆盖 U+2FA20–2FBFF),命中了才交给正则精确判——所以只会多走
|
|
342
|
+
// 慢路径,不会漏。
|
|
343
|
+
let hit = false;
|
|
344
|
+
for (let i = 0; i < input.length; i++) {
|
|
345
|
+
const c = input.charCodeAt(i);
|
|
346
|
+
if ((c >= 0xf900 && c <= 0xfaff) || c === 0xd87e) {
|
|
347
|
+
hit = true;
|
|
348
|
+
break;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
if (!hit)
|
|
352
|
+
return input;
|
|
353
|
+
COMPATIBILITY_IDEOGRAPHS.lastIndex = 0;
|
|
354
|
+
if (!COMPATIBILITY_IDEOGRAPHS.test(input))
|
|
355
|
+
return input;
|
|
356
|
+
COMPATIBILITY_IDEOGRAPHS.lastIndex = 0;
|
|
357
|
+
return input.replace(COMPATIBILITY_IDEOGRAPHS, (char) => char.normalize("NFC"));
|
|
153
358
|
}
|
|
154
359
|
/**
|
|
155
360
|
* Create a converter from multiple dictionary groups
|
|
@@ -164,7 +369,65 @@ export function ConverterFactory(...dictGroups) {
|
|
|
164
369
|
return trie;
|
|
165
370
|
});
|
|
166
371
|
return function convert(input) {
|
|
167
|
-
return tries.reduce((text, trie) => trie.convert(text), input);
|
|
372
|
+
return tries.reduce((text, trie) => trie.convert(text), normalizeCompatibilityIdeographs(input));
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Like {@link ConverterFactory}, but cuts the input into segments first and
|
|
377
|
+
* runs every conversion step **inside each segment** instead of across the
|
|
378
|
+
* whole string.
|
|
379
|
+
*
|
|
380
|
+
* ## What this is for
|
|
381
|
+
*
|
|
382
|
+
* With a two-step chain (`cn → t`, then `t → tw`), the second step sees text
|
|
383
|
+
* the first step produced. Without segmentation it can match across a word
|
|
384
|
+
* boundary the first step established, and the regional vocabulary tables
|
|
385
|
+
* (`TWPhrases`, `HKPhrases`) then fire in places OpenCC does not fire them.
|
|
386
|
+
* Measured against OpenCC's own output on 1707 phrases in context, dropping
|
|
387
|
+
* segmentation changes 21 of them — always by over-applying:
|
|
388
|
+
*
|
|
389
|
+
* ```text
|
|
390
|
+
* 他优化了 OpenCC 他優化了 no segmentation 他最佳化了
|
|
391
|
+
* 他函数了 OpenCC 他函數了 no segmentation 他函式了
|
|
392
|
+
* 他宽带了 OpenCC 他寬帶了 no segmentation 他寬頻了
|
|
393
|
+
* ```
|
|
394
|
+
*
|
|
395
|
+
* Note the bare phrase still converts (`优化` → `最佳化`) either way. It is
|
|
396
|
+
* only *in context* that the boundary matters, which is what makes the bug
|
|
397
|
+
* easy to miss with word-list tests.
|
|
398
|
+
*
|
|
399
|
+
* ## Which dictionary to cut on
|
|
400
|
+
*
|
|
401
|
+
* The segmentation dictionary must be keyed in the **input's** script, since
|
|
402
|
+
* it is the raw input being cut: OpenCC uses `STPhrases` for `s2*` and
|
|
403
|
+
* `TSPhrases` for `*2s`. {@link segmentationDictsFor} encodes that choice.
|
|
404
|
+
*
|
|
405
|
+
* ## Cost
|
|
406
|
+
*
|
|
407
|
+
* One extra trie walk plus per-segment string handling — roughly 2× the
|
|
408
|
+
* conversion time (0.73 ms → 1.45 ms on a 15 000-character chapter, which cut
|
|
409
|
+
* into ~5200 segments). Only chains with two or more steps need it, and
|
|
410
|
+
* {@link segmentationDictsFor} returns nothing for the rest, so single-step
|
|
411
|
+
* conversions keep the cheap path.
|
|
412
|
+
*
|
|
413
|
+
* @param segmentation - Dictionary group to cut on, or `null` for no cutting
|
|
414
|
+
* @param dictGroups - Conversion steps, applied in order within each segment
|
|
415
|
+
* @returns Converter function
|
|
416
|
+
*/
|
|
417
|
+
export function ConverterFactoryWithSegmentation(segmentation, ...dictGroups) {
|
|
418
|
+
if (!segmentation || segmentation.length === 0) {
|
|
419
|
+
return ConverterFactory(...dictGroups);
|
|
420
|
+
}
|
|
421
|
+
const segmenter = new Trie();
|
|
422
|
+
segmenter.loadDictGroup(segmentation);
|
|
423
|
+
const tries = dictGroups.map((group) => {
|
|
424
|
+
const trie = new Trie();
|
|
425
|
+
trie.loadDictGroup(group);
|
|
426
|
+
return trie;
|
|
427
|
+
});
|
|
428
|
+
return function convert(input) {
|
|
429
|
+
const segments = segmenter.segment(normalizeCompatibilityIdeographs(input));
|
|
430
|
+
return tries.reduce((current, trie) => current.map((segment) => trie.convert(segment)), segments).join("");
|
|
168
431
|
};
|
|
169
432
|
}
|
|
170
433
|
/**
|
|
@@ -195,10 +458,51 @@ const PROTECT_PLACEHOLDER_END = 0xf8ff;
|
|
|
195
458
|
* Safe to nest: each layer scans its input for existing PUA codepoints (from
|
|
196
459
|
* outer layers) and allocates around them. PUA chars from outer layers pass
|
|
197
460
|
* through unchanged.
|
|
461
|
+
*
|
|
462
|
+
* Rules must not contain PUA characters (U+E000..U+F8FF) — throws TypeError at
|
|
463
|
+
* build time. This was documented-but-unenforced for a while: a PUA char inside
|
|
464
|
+
* a rule VALUE can collide with an allocated placeholder and get swapped for a
|
|
465
|
+
* different rule's value at restore time. That failure needs two rules plus a
|
|
466
|
+
* specific allocation order, so it would surface as rare, unreproducible
|
|
467
|
+
* corruption — exactly the kind of bug a constructor throw is cheapest against.
|
|
468
|
+
* (PUA in user INPUT text is fine — the input scan routes around it.)
|
|
198
469
|
*/
|
|
470
|
+
/**
|
|
471
|
+
* PUA 字符(U+E000..U+F8FF)是 ProtectedConverter 的内部占位符段,规则里不能有它。
|
|
472
|
+
*
|
|
473
|
+
* 危害不是假设的:规则**值**里的 PUA 可能撞上分配出去的占位符,还原时被换成另一条
|
|
474
|
+
* 规则的值——要两条规则加特定分配顺序才触发,表现为罕见且无法复现的串词。
|
|
475
|
+
*
|
|
476
|
+
* 处理方式是**静默剥掉**,不是抛错。理由:这些字符肉眼不可见,用户看到的规则本来就是
|
|
477
|
+
* 剥掉之后那个样子;而规则常常来自最终用户(粘贴 / 导入 / localStorage 里的历史数据),
|
|
478
|
+
* 抛错等于把库的内部不变式变成每个调用方都要先洗一遍的负担。剥完为空的键值对整条跳过,
|
|
479
|
+
* 与 `Trie.loadDict` 对畸形条目的一贯宽容度一致。
|
|
480
|
+
*
|
|
481
|
+
* 用户**输入文本**里的 PUA 不受影响——那是数据,掩码分配器会绕开它们走。
|
|
482
|
+
*/
|
|
483
|
+
function stripPUA(text) {
|
|
484
|
+
// 转义写法,不写裸字符——裸 PUA 在多数编辑器里完全不可见。
|
|
485
|
+
return text.replace(/[\uE000-\uF8FF]/g, "");
|
|
486
|
+
}
|
|
487
|
+
function sanitizeRules(protectedDict) {
|
|
488
|
+
const entries = typeof protectedDict === "string"
|
|
489
|
+
? protectedDict.split("|").map((e) => {
|
|
490
|
+
const i = e.indexOf(" ");
|
|
491
|
+
return i < 0 ? [e] : [e.slice(0, i), e.slice(i + 1)];
|
|
492
|
+
})
|
|
493
|
+
: protectedDict;
|
|
494
|
+
const out = [];
|
|
495
|
+
for (const entry of entries) {
|
|
496
|
+
const key = stripPUA(entry[0] ?? "");
|
|
497
|
+
const value = stripPUA(entry[1] ?? "");
|
|
498
|
+
if (key && value)
|
|
499
|
+
out.push([key, value]);
|
|
500
|
+
}
|
|
501
|
+
return out;
|
|
502
|
+
}
|
|
199
503
|
export function ProtectedConverter(protectedDict, innerConvert) {
|
|
200
504
|
const trie = new Trie();
|
|
201
|
-
trie.loadDict(protectedDict);
|
|
505
|
+
trie.loadDict(sanitizeRules(protectedDict));
|
|
202
506
|
return function convert(input) {
|
|
203
507
|
const slotsByCode = new Map();
|
|
204
508
|
const valueToPlaceholder = new Map();
|
|
@@ -298,11 +602,14 @@ export function parseOpenCCDict(text) {
|
|
|
298
602
|
*/
|
|
299
603
|
function maskWithTrie(input, trie, slotsByCode, valueToPlaceholder) {
|
|
300
604
|
// Scan input for any existing PUA codepoints (from outer ProtectedConverter
|
|
301
|
-
// layers
|
|
302
|
-
//
|
|
605
|
+
// layers, or plain user data). Their ONLY consumer is allocateCode below —
|
|
606
|
+
// matching needs no per-char passthrough branch: the constructor guarantees
|
|
607
|
+
// rules contain no PUA, so no trie match can ever cover a PUA char and it
|
|
608
|
+
// falls into the unmatched run untouched. (PUA is Plane 0 → plain charCodeAt
|
|
609
|
+
// scan, no surrogate pairing needed; measured ~5× over the for..of version.)
|
|
303
610
|
const existingPUA = new Set();
|
|
304
|
-
for (
|
|
305
|
-
const cp =
|
|
611
|
+
for (let k = 0; k < input.length; k++) {
|
|
612
|
+
const cp = input.charCodeAt(k);
|
|
306
613
|
if (cp >= PROTECT_PLACEHOLDER_BASE && cp <= PROTECT_PLACEHOLDER_END) {
|
|
307
614
|
existingPUA.add(cp);
|
|
308
615
|
}
|
|
@@ -316,36 +623,43 @@ function maskWithTrie(input, trie, slotsByCode, valueToPlaceholder) {
|
|
|
316
623
|
}
|
|
317
624
|
return nextCode++;
|
|
318
625
|
};
|
|
626
|
+
// Inlined longest-match walk + run slicing, same shape as Trie.convert:
|
|
627
|
+
// the previous version called findLongestMatch per position (one {end,value}
|
|
628
|
+
// allocation per character) and pushed per-char substrings (one string per
|
|
629
|
+
// character even with zero matches). One PC layer cost +2.7 ms on a 40k-char
|
|
630
|
+
// corpus — nearly doubling the whole pipeline; this rewrite makes the
|
|
631
|
+
// no-match path allocation-free.
|
|
319
632
|
const result = [];
|
|
320
633
|
const length = input.length;
|
|
321
|
-
let
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
let placeholder = valueToPlaceholder.get(value);
|
|
634
|
+
let originalStart = null;
|
|
635
|
+
const hit = { end: 0, value: undefined };
|
|
636
|
+
for (let i = 0; i < length;) {
|
|
637
|
+
trie.matchLongestInto(input, i, hit);
|
|
638
|
+
const matchEnd = hit.end;
|
|
639
|
+
const matchValue = hit.value;
|
|
640
|
+
if (matchEnd > 0 && matchValue !== undefined) {
|
|
641
|
+
if (originalStart !== null) {
|
|
642
|
+
result.push(input.slice(originalStart, i));
|
|
643
|
+
originalStart = null;
|
|
644
|
+
}
|
|
645
|
+
let placeholder = valueToPlaceholder.get(matchValue);
|
|
334
646
|
if (placeholder === undefined) {
|
|
335
647
|
const code = allocateCode();
|
|
336
648
|
placeholder = String.fromCodePoint(code);
|
|
337
|
-
valueToPlaceholder.set(
|
|
338
|
-
slotsByCode.set(code,
|
|
649
|
+
valueToPlaceholder.set(matchValue, placeholder);
|
|
650
|
+
slotsByCode.set(code, matchValue);
|
|
339
651
|
}
|
|
340
652
|
result.push(placeholder);
|
|
341
|
-
i =
|
|
653
|
+
i = matchEnd;
|
|
342
654
|
}
|
|
343
655
|
else {
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
i +=
|
|
656
|
+
if (originalStart === null)
|
|
657
|
+
originalStart = i;
|
|
658
|
+
i += isSurrogatePair(input, i, length) ? 2 : 1;
|
|
347
659
|
}
|
|
348
660
|
}
|
|
661
|
+
if (originalStart !== null)
|
|
662
|
+
result.push(input.slice(originalStart, length));
|
|
349
663
|
return result.join("");
|
|
350
664
|
}
|
|
351
665
|
/**
|
|
@@ -357,17 +671,29 @@ function maskWithTrie(input, trie, slotsByCode, valueToPlaceholder) {
|
|
|
357
671
|
function restorePlaceholders(text, slotsByCode) {
|
|
358
672
|
if (slotsByCode.size === 0)
|
|
359
673
|
return text;
|
|
674
|
+
// Run slicing instead of one push per character: placeholders are Plane-0
|
|
675
|
+
// PUA, so a plain charCodeAt compare finds them and everything between two
|
|
676
|
+
// placeholders is emitted as a single slice. The per-char version allocated
|
|
677
|
+
// 40k single-char strings to restore 3 placeholders.
|
|
360
678
|
const result = [];
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
679
|
+
const length = text.length;
|
|
680
|
+
let runStart = 0;
|
|
681
|
+
for (let i = 0; i < length; i++) {
|
|
682
|
+
const cp = text.charCodeAt(i);
|
|
683
|
+
if (cp >= PROTECT_PLACEHOLDER_BASE && cp <= PROTECT_PLACEHOLDER_END) {
|
|
684
|
+
const restored = slotsByCode.get(cp);
|
|
685
|
+
if (restored !== undefined) {
|
|
686
|
+
if (runStart < i)
|
|
687
|
+
result.push(text.slice(runStart, i));
|
|
688
|
+
result.push(restored);
|
|
689
|
+
runStart = i + 1;
|
|
690
|
+
}
|
|
691
|
+
// 不在本层 map 里的 PUA(外层的占位符/用户数据)留在 run 里原样通过
|
|
369
692
|
}
|
|
370
693
|
}
|
|
694
|
+
if (runStart === 0)
|
|
695
|
+
return text;
|
|
696
|
+
if (runStart < length)
|
|
697
|
+
result.push(text.slice(runStart, length));
|
|
371
698
|
return result.join("");
|
|
372
699
|
}
|
|
373
|
-
//# sourceMappingURL=core.js.map
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
3
|
-
//# sourceMappingURL=CNTWPhrases.d.ts.map
|
|
1
|
+
declare const dict: string;
|
|
2
|
+
export default dict;
|
package/dist/dict/CNTWPhrases.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const dict = "视频 影片|内存 記憶體|鼠标 滑鼠|U盘 隨身碟|优盘 隨身碟|打印机 印表機|杀毒软件 防毒軟體|默认 預設|调制解调器 數據機|出租车 計程車|地铁 捷運|公交车 公車|摩托车 機車|航站楼 航廈|立交桥 交流道|盒饭 便當|酸奶 優格|芝士 起司|土豆 馬鈴薯|卷心菜 高麗菜|包菜 高麗菜|方便面 泡麵|薯片 洋芋片|雪糕 冰淇淋|幼儿园 幼稚園|小学 國小|初中 國中|高考 大學入學考試|简历 履歷|项目 專案|营销 行銷|合同 合約|空调 冷氣|物业 物業|二手房 中古屋|煤气 瓦斯|二维码 QR Code|人脸识别 人臉辨識|云计算 雲端運算|虚拟现实 虛擬實境|增强现实 擴增實境";
|
|
2
|
+
export default dict;
|
package/dist/dict/HKPhrases.d.ts
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
3
|
-
//# sourceMappingURL=HKPhrases.d.ts.map
|
|
1
|
+
declare const dict: string;
|
|
2
|
+
export default dict;
|
package/dist/dict/HKPhrases.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const dict = "丹尼·博伊爾 丹尼·波爾|亞歷杭德羅·岡薩雷斯·伊納裏圖 艾力謝路·高沙里斯·依拿力圖|伊利亞·卡贊 伊力·卡山|伊利諾伊 伊利諾|伊利諾伊州 伊利諾州|伍迪·艾倫 活地·亞倫|俄克拉何馬 奧克拉荷馬|俄克拉何馬州 奧克拉荷馬州|俄克拉荷馬 奧克拉荷馬|俄克拉荷馬州 奧克拉荷馬州|保羅·哈吉斯 保羅·夏傑斯|保羅·托馬斯·安德森 保羅·湯馬士·安德遜|光標 游標|克林特·伊斯特伍德 奇連·伊士活|克里斯托弗·諾蘭 基斯杜化·路蘭|內存條 記憶體模組|凱文·科斯特納 奇雲·高士拿|凱瑟琳·畢格羅 嘉芙蓮·碧格露|北卡羅來納 北卡羅萊納|北卡羅來納州 北卡羅萊納州|南卡羅來納 南卡羅萊納|南卡羅來納州 南卡羅萊納州|史蒂夫·麥奎因 史提夫·麥昆|吉列爾莫·德爾托羅 古利姆·迪托路|喬治·克魯尼 佐治·古尼|大衛·利恩 大衛·連|奧利弗·斯通 奧利華·史東|威廉·弗萊德金 威廉·佛烈金|密歇根 密芝根|密歇根州 密芝根州|寬帶 寬頻|山姆·曼德斯 森·曼特斯|布拉德·皮特 畢·彼特|幾率 機率|弗吉尼亞 維珍尼亞|弗吉尼亞州 維珍尼亞州|弗朗西絲·麥克多曼德 法蘭絲·麥杜雯|彼得·傑克遜 彼德·積遜|得克薩斯 德薩斯|得克薩斯州 德薩斯州|德克薩斯 德薩斯|德克薩斯州 德薩斯州|搜索 搜尋|操作系統 作業系統|文件夾 資料夾|斯蒂芬·斯皮爾伯格 史提芬·史匹堡|服務器 伺服器|朗·霍華德 朗·侯活|本·阿弗萊克 賓·艾佛力|查爾斯·羅文 查理士·路雲|梅爾·吉布森 米路·吉遜|概率 概率|沃倫·比蒂 華倫·比提|湯姆·霍伯 湯賀柏|硬盤 硬碟|科恩兄弟 高安兄弟|簡·坎皮恩 珍·甘比茵|米歇爾·阿扎納維西於斯 米高·哈薩拿維斯|約瑟夫·曼凱維奇 約瑟·曼基威士|編程語言 程式語言|羅伯特·懷斯 羅拔·淮斯|羅伯特·澤米吉斯 羅拔·湛米基斯|羅伯特·雷德福 羅拔·烈福|羅得島 羅德島|羅得島州 羅德島州|肖恩·貝克 辛·貝克|舒芙蕾 梳芙厘|艾瑪·托馬斯 愛瑪·湯馬士|西弗吉尼亞 西維珍尼亞|西弗吉尼亞州 西維珍尼亞州|詹姆斯·卡梅隆 占士·金馬倫|諾蘭 路蘭|賓夕法尼亞 賓夕凡尼亞|賓夕法尼亞州 賓夕凡尼亞州|邁克·尼科爾斯 米克·尼高斯|邁克爾·道格拉斯 米高·德格拉斯|阿黛爾·羅曼斯基 愛黛兒·羅曼斯基|隱私權 私隱權|馬丁·斯科塞斯 馬田·史高西斯|馬里蘭 馬利蘭|馬里蘭州 馬利蘭州|鼠標 滑鼠";
|
|
2
|
+
export default dict;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
3
|
-
//# sourceMappingURL=HKPhrasesRev.d.ts.map
|
|
1
|
+
declare const dict: string;
|
|
2
|
+
export default dict;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const dict = "丹尼·波爾 丹尼·博伊爾|伊利諾 伊利諾伊|伊利諾州 伊利諾伊州|伊力·卡山 伊利亞·卡贊|伺服器 服務器|佐治·古尼 喬治·克魯尼|作業系統 操作系統|保羅·夏傑斯 保羅·哈吉斯|保羅·湯馬士·安德遜 保羅·托馬斯·安德森|北卡羅萊納 北卡羅來納|北卡羅萊納州 北卡羅來納州|南卡羅萊納 南卡羅來納|南卡羅萊納州 南卡羅來納州|占士·金馬倫 詹姆斯·卡梅隆|古利姆·迪托路 吉列爾莫·德爾托羅|史提夫·麥昆 史蒂夫·麥奎因|史提芬·史匹堡 斯蒂芬·斯皮爾伯格|嘉芙蓮·碧格露 凱瑟琳·畢格羅|基斯杜化·路蘭 克里斯托弗·諾蘭|大衛·連 大衛·利恩|奇連·伊士活 克林特·伊斯特伍德|奇雲·高士拿 凱文·科斯特納|奧克拉荷馬 俄克拉何馬|奧克拉荷馬州 俄克拉何馬州|奧利華·史東 奧利弗·斯通|威廉·佛烈金 威廉·弗萊德金|密芝根 密歇根|密芝根州 密歇根州|寬頻 寬帶|彼德·積遜 彼得·傑克遜|德薩斯 得克薩斯|德薩斯州 得克薩斯州|愛瑪·湯馬士 艾瑪·托馬斯|愛黛兒·羅曼斯基 阿黛爾·羅曼斯基|搜尋 搜索|朗·侯活 朗·霍華德|查理士·路雲 查爾斯·羅文|梳芙厘 舒芙蕾|森·曼特斯 山姆·曼德斯|概率 概率|機會率 概率|機率 幾率|法蘭絲·麥杜雯 弗朗西絲·麥克多曼德|活地·亞倫 伍迪·艾倫|游標 光標|湯賀柏 湯姆·霍伯|滑鼠 鼠標|珍·甘比茵 簡·坎皮恩|畢·彼特 布拉德·皮特|硬碟 硬盤|私隱權 隱私權|程式語言 編程語言|米克·尼高斯 邁克·尼科爾斯|米路·吉遜 梅爾·吉布森|米高·哈薩拿維斯 米歇爾·阿扎納維西於斯|米高·德格拉斯 邁克爾·道格拉斯|約瑟·曼基威士 約瑟夫·曼凱維奇|維珍尼亞 弗吉尼亞|維珍尼亞州 弗吉尼亞州|羅德島 羅得島|羅德島州 羅得島州|羅拔·淮斯 羅伯特·懷斯|羅拔·湛米基斯 羅伯特·澤米吉斯|羅拔·烈福 羅伯特·雷德福|艾力謝路·高沙里斯·依拿力圖 亞歷杭德羅·岡薩雷斯·伊納裏圖|華倫·比提 沃倫·比蒂|西維珍尼亞 西弗吉尼亞|西維珍尼亞州 西弗吉尼亞州|記憶體模組 內存條|資料夾 文件夾|賓·艾佛力 本·阿弗萊克|賓夕凡尼亞 賓夕法尼亞|賓夕凡尼亞州 賓夕法尼亞州|路蘭 諾蘭|辛·貝克 肖恩·貝克|馬利蘭 馬里蘭|馬利蘭州 馬里蘭州|馬田·史高西斯 馬丁·斯科塞斯|高安兄弟 科恩兄弟";
|
|
2
|
+
export default dict;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
export default
|
|
3
|
-
//# sourceMappingURL=HKVariants.d.ts.map
|
|
1
|
+
declare const dict: string;
|
|
2
|
+
export default dict;
|
package/dist/dict/HKVariants.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
const dict = "僞 偽|兌 兑|叄 叁|喫 吃|囪 囱|媼 媪|嬀 媯|悅 悦|慍 愠|戶 户|挩 捝|搵 揾|敓 敚|敘 敍|柺 枴|梲 棁|棱 稜|榲 榅|檯 枱|氳 氲|涗 涚|溫 温|溼 濕|潙 溈|潨 潀|熅 煴|爲 為|癡 痴|皁 皂|祕 秘|稅 税|竈 灶|糉 粽|縕 緼|纔 才|脣 唇|脫 脱|膃 腽|臥 卧|臺 台|菸 煙|蒕 蒀|蔥 葱|蔿 蒍|蘊 藴|蛻 蜕|衆 眾|衛 衞|覈 核|說 説|踊 踴|轀 輼|醞 醖|鉢 缽|鉤 鈎|銳 鋭|鍼 針|閱 閲|鰮 鰛";
|
|
2
|
+
export default dict;
|