@kensio/pinyinjs 1.2.2 → 1.4.0
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/CHANGELOG.md +116 -3
- package/NOTICE +9 -0
- package/README.md +58 -9
- package/data/core.entries +1 -13
- package/data/core.freq +0 -0
- package/data/core.keys +1 -13
- package/data/full.entries +141 -131
- package/data/full.freq +0 -0
- package/data/full.keys +167 -157
- package/data/manifest.json +24 -9
- package/data/script.map +26543 -0
- package/data/standard.entries +1 -22
- package/data/standard.freq +0 -0
- package/data/standard.keys +2 -23
- package/dist/cli/arguments.d.ts +72 -0
- package/dist/cli/arguments.d.ts.map +1 -1
- package/dist/cli/arguments.js +110 -0
- package/dist/cli/arguments.js.map +1 -1
- package/dist/cli/commands.d.ts +11 -0
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +77 -1
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/environment.d.ts.map +1 -1
- package/dist/cli/environment.js +2 -1
- package/dist/cli/environment.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +21 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/cli/run.d.ts +8 -0
- package/dist/cli/run.d.ts.map +1 -1
- package/dist/cli/run.js +11 -1
- package/dist/cli/run.js.map +1 -1
- package/dist/decode/convert.d.ts +10 -0
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +12 -0
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/script.d.ts +108 -0
- package/dist/decode/script.d.ts.map +1 -0
- package/dist/decode/script.js +195 -0
- package/dist/decode/script.js.map +1 -0
- package/dist/dictionary/dictionary.d.ts +13 -1
- package/dist/dictionary/dictionary.d.ts.map +1 -1
- package/dist/dictionary/dictionary.js +18 -4
- package/dist/dictionary/dictionary.js.map +1 -1
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +23 -3
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/script-tables.d.ts +17 -0
- package/dist/dictionary/script-tables.d.ts.map +1 -0
- package/dist/dictionary/script-tables.js +275 -0
- package/dist/dictionary/script-tables.js.map +1 -0
- package/dist/dictionary/source.d.ts +18 -0
- package/dist/dictionary/source.d.ts.map +1 -1
- package/dist/dictionary/source.js +20 -0
- package/dist/dictionary/source.js.map +1 -1
- package/dist/format/slug.d.ts +156 -0
- package/dist/format/slug.d.ts.map +1 -0
- package/dist/format/slug.js +0 -0
- package/dist/format/slug.js.map +1 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/script/conversion.d.ts +102 -0
- package/dist/script/conversion.d.ts.map +1 -0
- package/dist/script/conversion.js +194 -0
- package/dist/script/conversion.js.map +1 -0
- package/dist/script/glyphs.d.ts +95 -0
- package/dist/script/glyphs.d.ts.map +1 -0
- package/dist/script/glyphs.js +236 -0
- package/dist/script/glyphs.js.map +1 -0
- package/dist/sources/opencc.d.ts +32 -0
- package/dist/sources/opencc.d.ts.map +1 -0
- package/dist/sources/opencc.js +50 -0
- package/dist/sources/opencc.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { toCharacters } from "../script/characters.js";
|
|
2
|
+
import { toCanonicalGlyphs } from "../script/glyphs.js";
|
|
3
|
+
import { conversionKey, convertCharacters, } from "../script/conversion.js";
|
|
4
|
+
/**
|
|
5
|
+
* The key standing for "at any reading".
|
|
6
|
+
*/
|
|
7
|
+
const ANY = "";
|
|
8
|
+
/**
|
|
9
|
+
* How much of a reading's evidence must agree before it overrides the default.
|
|
10
|
+
*
|
|
11
|
+
* A reading that disagrees with the default only earns a line in the table if
|
|
12
|
+
* the sources are reasonably united about it. Below this it is noise — one
|
|
13
|
+
* mis-aligned entry, or a spelling nobody else uses — and storing it would
|
|
14
|
+
* make the conversion worse at the cost of bytes.
|
|
15
|
+
*/
|
|
16
|
+
const READING_AGREEMENT = 0.8;
|
|
17
|
+
/**
|
|
18
|
+
* How much of a character's evidence a rival form needs to be worth reporting.
|
|
19
|
+
*
|
|
20
|
+
* This decides honesty rather than output: a form listed here makes the
|
|
21
|
+
* character *ambiguous*, so every conversion of it is reported as a guess
|
|
22
|
+
* unless a word or a reading settled it. Set too low and 和 is doubtful because
|
|
23
|
+
* Unihan knows 咊; set too high and 面 looks certain when only the word tells
|
|
24
|
+
* 面 from 麵. A twentieth of the evidence is enough to be a real spelling and
|
|
25
|
+
* far more than the one-off variants clear.
|
|
26
|
+
*/
|
|
27
|
+
const RIVAL_SHARE = 0.05;
|
|
28
|
+
/**
|
|
29
|
+
* The pairings an entry attests, character by character.
|
|
30
|
+
*
|
|
31
|
+
* Entries whose two scripts are written with a different number of characters
|
|
32
|
+
* are skipped rather than aligned by guesswork, for the same reason
|
|
33
|
+
* `pairScripts` skips them: an invented alignment is evidence for a pairing
|
|
34
|
+
* nobody wrote.
|
|
35
|
+
*/
|
|
36
|
+
function pairingsOf(entry) {
|
|
37
|
+
const hans = toCharacters(entry.hans);
|
|
38
|
+
const hant = toCharacters(entry.hant);
|
|
39
|
+
if (hans.length !== hant.length) {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
const reading = entry.readings.cn;
|
|
43
|
+
// Only a reading with one syllable per character lines up; anything else
|
|
44
|
+
// (儿化 covering two, or a source disagreeing about length) is used as
|
|
45
|
+
// evidence for the pairing but not for any particular reading.
|
|
46
|
+
const isAligned = reading.length === hans.length;
|
|
47
|
+
return hans.map((character, at) => ({
|
|
48
|
+
hans: character,
|
|
49
|
+
/* c8 ignore next -- the two forms are known to be the same length */
|
|
50
|
+
hant: hant[at] ?? character,
|
|
51
|
+
key: isAligned ? conversionKey(reading[at]) : ANY,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Tally one pairing under both its own reading and the any-reading key.
|
|
56
|
+
*/
|
|
57
|
+
function tally(observed, from, to, key, weight) {
|
|
58
|
+
const byReading = observed.get(from) ?? new Map();
|
|
59
|
+
const keys = new Set([ANY, key]);
|
|
60
|
+
for (const at of keys) {
|
|
61
|
+
const counts = byReading.get(at) ?? new Map();
|
|
62
|
+
counts.set(to, (counts.get(to) ?? 0) + weight);
|
|
63
|
+
byReading.set(at, counts);
|
|
64
|
+
}
|
|
65
|
+
observed.set(from, byReading);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The commonest form in a tally, and what share of the evidence it holds.
|
|
69
|
+
*
|
|
70
|
+
* A tie prefers a form other than the character itself, and that matters more
|
|
71
|
+
* than it looks. Every character has an entry of its own where both scripts are
|
|
72
|
+
* the same string, so a character attested in exactly one cross-script word
|
|
73
|
+
* arrives here tied one-all against its own identity — 儁 against 㑺. The real
|
|
74
|
+
* pairing is the one somebody wrote down; the identity is an artefact of how
|
|
75
|
+
* the dictionary is keyed. `TraditionalTable` breaks the same tie the same way.
|
|
76
|
+
*/
|
|
77
|
+
function commonest(from, counts) {
|
|
78
|
+
if (counts === undefined || counts.size === 0) {
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
let form = "";
|
|
82
|
+
let best = 0;
|
|
83
|
+
let total = 0;
|
|
84
|
+
for (const [candidate, count] of counts) {
|
|
85
|
+
total += count;
|
|
86
|
+
if (count > best ||
|
|
87
|
+
(count === best && form === from && candidate !== from)) {
|
|
88
|
+
form = candidate;
|
|
89
|
+
best = count;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
return { form, share: best / total };
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Reduce one character's observations to a default and its exceptions.
|
|
96
|
+
*
|
|
97
|
+
* A character with only one observed form needs no entry at all when that form
|
|
98
|
+
* is itself — simplification changed a minority of characters, and storing the
|
|
99
|
+
* other 40,000 as identities would be most of the file.
|
|
100
|
+
*/
|
|
101
|
+
function conversionOf(from, byReading) {
|
|
102
|
+
const overall = commonest(from, byReading.get(ANY));
|
|
103
|
+
if (overall === undefined) {
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
const exceptions = new Map();
|
|
107
|
+
for (const [key, counts] of byReading) {
|
|
108
|
+
const at = commonest(from, counts);
|
|
109
|
+
if (key !== ANY &&
|
|
110
|
+
at !== undefined &&
|
|
111
|
+
at.form !== overall.form &&
|
|
112
|
+
at.share >= READING_AGREEMENT) {
|
|
113
|
+
exceptions.set(key, at.form);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const also = rivalsOf(byReading.get(ANY), overall.form, exceptions);
|
|
117
|
+
if (overall.form === from && exceptions.size === 0 && also.length === 0) {
|
|
118
|
+
return undefined;
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
to: overall.form,
|
|
122
|
+
...(exceptions.size > 0 && { byReading: exceptions }),
|
|
123
|
+
...(also.length > 0 && { also }),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* The forms a character takes often enough to make it genuinely ambiguous.
|
|
128
|
+
*
|
|
129
|
+
* Forms a reading already accounts for are left out: those are settled evidence
|
|
130
|
+
* rather than open questions, and repeating them here would report 发 as a
|
|
131
|
+
* guess in 头发 when the reading decided it.
|
|
132
|
+
*/
|
|
133
|
+
function rivalsOf(counts, chosen, exceptions) {
|
|
134
|
+
if (counts === undefined) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
let total = 0;
|
|
138
|
+
for (const count of counts.values()) {
|
|
139
|
+
total += count;
|
|
140
|
+
}
|
|
141
|
+
const settled = new Set([chosen, ...exceptions.values()]);
|
|
142
|
+
return [...counts]
|
|
143
|
+
.filter(([form, count]) => !settled.has(form) && count / total >= RIVAL_SHARE)
|
|
144
|
+
.toSorted(([, left], [, right]) => right - left)
|
|
145
|
+
.map(([form]) => form);
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Reduce every character's observations into a table.
|
|
149
|
+
*/
|
|
150
|
+
function tableOf(observed) {
|
|
151
|
+
const table = new Map();
|
|
152
|
+
for (const [from, byReading] of observed) {
|
|
153
|
+
const conversion = conversionOf(from, byReading);
|
|
154
|
+
if (conversion !== undefined) {
|
|
155
|
+
table.set(from, conversion);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return table;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The readings a word is converted with, where they line up character by
|
|
162
|
+
* character.
|
|
163
|
+
*/
|
|
164
|
+
function alignedReadings(entry) {
|
|
165
|
+
const characters = toCharacters(entry.hans).length;
|
|
166
|
+
return entry.readings.cn.length === characters ? entry.readings.cn : [];
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Build the script conversion tables from the merged dictionary.
|
|
170
|
+
*
|
|
171
|
+
* The evidence is the merged entries rather than CC-CEDICT directly, which
|
|
172
|
+
* matters: the merge has already corrected neutral tones, repaired 儿化 and
|
|
173
|
+
* derived 繁體 forms for the phrase corpus, so what is counted here is what the
|
|
174
|
+
* dictionary actually holds rather than what one source said about it.
|
|
175
|
+
*
|
|
176
|
+
* Words are counted once each rather than weighted by frequency. A default is
|
|
177
|
+
* only there to keep the exception list short — every word it gets wrong is
|
|
178
|
+
* stored — so what matters is how many words agree, not how often they are
|
|
179
|
+
* said.
|
|
180
|
+
*/
|
|
181
|
+
export function buildScriptTables(entries) {
|
|
182
|
+
const toTraditionalCounts = new Map();
|
|
183
|
+
const toSimplifiedCounts = new Map();
|
|
184
|
+
for (const entry of entries) {
|
|
185
|
+
for (const { hans, hant, key } of pairingsOf(entry)) {
|
|
186
|
+
tally(toTraditionalCounts, hans, hant, key, 1);
|
|
187
|
+
tally(toSimplifiedCounts, hant, hans, key, 1);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
const toTraditional = tableOf(toTraditionalCounts);
|
|
191
|
+
const toSimplified = tableOf(toSimplifiedCounts);
|
|
192
|
+
// Only the words the character tables get wrong. Everything else is already
|
|
193
|
+
// right and would be bytes spent restating it.
|
|
194
|
+
//
|
|
195
|
+
// Single characters are deliberately excluded. A one-character entry is not
|
|
196
|
+
// independent evidence about that character — it is one of the observations
|
|
197
|
+
// the character table was built from — so an "exception" for it is simply the
|
|
198
|
+
// aggregate being overruled by one of its own inputs. 和 has a rare variant
|
|
199
|
+
// 咊 that Unihan knows and nobody writes; keeping the exception would convert
|
|
200
|
+
// every 和 to it, against the thousands of words that say otherwise.
|
|
201
|
+
const traditionalWords = new Map();
|
|
202
|
+
const simplifiedWords = new Map();
|
|
203
|
+
for (const entry of entries) {
|
|
204
|
+
if (toCharacters(entry.hans).length < 2) {
|
|
205
|
+
continue;
|
|
206
|
+
}
|
|
207
|
+
const readings = alignedReadings(entry);
|
|
208
|
+
if (convertCharacters(toTraditional, entry.hans, readings) !== entry.hant) {
|
|
209
|
+
traditionalWords.set(entry.hans, entry.hant);
|
|
210
|
+
}
|
|
211
|
+
if (convertCharacters(toSimplified, entry.hant, readings) !== entry.hans) {
|
|
212
|
+
simplifiedWords.set(entry.hant, entry.hans);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return {
|
|
216
|
+
toTraditional,
|
|
217
|
+
toSimplified,
|
|
218
|
+
traditionalWords,
|
|
219
|
+
simplifiedWords,
|
|
220
|
+
...scriptOnlyCharacters(entries),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The characters each script writes and the other does not.
|
|
225
|
+
*
|
|
226
|
+
* What settles a text's script is which characters *occur* in each: 发 is
|
|
227
|
+
* 简体-only because no 繁體 word is written with it, and 髮 is 繁體-only for the
|
|
228
|
+
* mirror reason. A character both scripts use — the great majority — settles
|
|
229
|
+
* nothing and belongs in neither set.
|
|
230
|
+
*
|
|
231
|
+
* Only entries whose two forms **differ** are counted, and that restriction is
|
|
232
|
+
* what makes this work at all. `hans` is the dictionary's key rather than a
|
|
233
|
+
* claim about script, so every 繁體 character is also some entry's `hans` — 髮
|
|
234
|
+
* has a character entry of its own, with 髮 on both sides. Counting those would
|
|
235
|
+
* put every character in both sets and leave both empty.
|
|
236
|
+
*
|
|
237
|
+
* It also settles the genuinely two-sided characters correctly. 干 is a 简体
|
|
238
|
+
* form of 幹 and 乾 *and* a 繁體 character in its own right, so it appears on
|
|
239
|
+
* both sides of 干扰/干擾 and lands in neither set, which is the honest answer.
|
|
240
|
+
*
|
|
241
|
+
* Both sides are folded to their canonical glyph forms first. The phrase corpus
|
|
242
|
+
* is nominally 简体 and writes a few hundred headwords with 繁體 variants — 衞生,
|
|
243
|
+
* 鹫峯寺 — and taking those at face value put 衞 and 峯 in the 简体-only set. A
|
|
244
|
+
* text written 衞生 was then detected as 简体 and left alone when it was asked
|
|
245
|
+
* for 简体, which is the opposite of what it needed.
|
|
246
|
+
*/
|
|
247
|
+
function scriptOnlyCharacters(entries) {
|
|
248
|
+
const inHans = new Set();
|
|
249
|
+
const inHant = new Set();
|
|
250
|
+
for (const entry of entries) {
|
|
251
|
+
// A 繁體 form that differs from the 简体 one only by glyph normalisation is
|
|
252
|
+
// not evidence about script — 衞生 and 衛生 are two 繁體 spellings of one
|
|
253
|
+
// word, and the merge keys the second so the first can be found. Counting
|
|
254
|
+
// it would put that entry's 简体 characters on the 繁體 side, which is how
|
|
255
|
+
// 发 stopped being 简体-only.
|
|
256
|
+
const canonicalHans = toCanonicalGlyphs(entry.hans);
|
|
257
|
+
const forms = [entry.hant, ...(entry.hantVariants ?? [])].filter((form) => form !== entry.hans && form !== canonicalHans);
|
|
258
|
+
if (forms.length === 0) {
|
|
259
|
+
continue;
|
|
260
|
+
}
|
|
261
|
+
const hansCharacters = toCharacters(canonicalHans);
|
|
262
|
+
for (const character of hansCharacters) {
|
|
263
|
+
inHans.add(character);
|
|
264
|
+
}
|
|
265
|
+
const hantCharacters = forms.flatMap((form) => toCharacters(toCanonicalGlyphs(form)));
|
|
266
|
+
for (const character of hantCharacters) {
|
|
267
|
+
inHant.add(character);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return {
|
|
271
|
+
hansOnly: new Set([...inHans].filter((c) => !inHant.has(c))),
|
|
272
|
+
hantOnly: new Set([...inHant].filter((c) => !inHans.has(c))),
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
//# sourceMappingURL=script-tables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-tables.js","sourceRoot":"","sources":["../../src/dictionary/script-tables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAEL,aAAa,EACb,iBAAiB,GAElB,MAAM,yBAAyB,CAAC;AAcjC;;GAEG;AACH,MAAM,GAAG,GAAG,EAAE,CAAC;AAEf;;;;;;;GAOG;AACH,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B;;;;;;;;;GASG;AACH,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB;;;;;;;GAOG;AACH,SAAS,UAAU,CACjB,KAAsB;IAEtB,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC;IACZ,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC;IAClC,yEAAyE;IACzE,qEAAqE;IACrE,+DAA+D;IAC/D,MAAM,SAAS,GAAG,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,MAAM,CAAC;IACjD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,SAAS;QACf,qEAAqE;QACrE,IAAI,EAAE,IAAI,CAAC,EAAE,C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,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,CAAC,KAAK,CAAC,IAAI,EAAE,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,CAAC,MAAM,CAC9D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,IAAI,IAAI,KAAK,aAAa,CACxD,CAAC;QACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACvB,SAAS;QACX,CAAC;QACD,MAAM,cAAc,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;QACnD,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;YACvC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;QACD,MAAM,cAAc,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC5C,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC,CACtC,CAAC;QACF,KAAK,MAAM,SAAS,IAAI,cAAc,EAAE,CAAC;YACvC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACxB,CAAC;IACH,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5D,QAAQ,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;KAC7D,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ScriptTables } from "../script/conversion.js";
|
|
1
2
|
import type { DictionaryArtifact } from "./artifact.js";
|
|
2
3
|
import { Dictionary } from "./dictionary.js";
|
|
3
4
|
import type { Tier } from "./tiers.js";
|
|
@@ -42,4 +43,21 @@ export declare function loadArtifact(source: DictionarySource, tier: Tier): Prom
|
|
|
42
43
|
* Load a tier and wrap it in a {@link Dictionary}.
|
|
43
44
|
*/
|
|
44
45
|
export declare function loadDictionary(source: DictionarySource, tier: Tier): Promise<Dictionary>;
|
|
46
|
+
/**
|
|
47
|
+
* The file the script conversion tables live in.
|
|
48
|
+
*
|
|
49
|
+
* One file rather than one per table, and outside the tiers rather than
|
|
50
|
+
* repeated in each: script conversion does not get more accurate with a bigger
|
|
51
|
+
* dictionary the way reading does, so there is nothing to tier.
|
|
52
|
+
*/
|
|
53
|
+
export declare const SCRIPT_FILE = "script.map";
|
|
54
|
+
/**
|
|
55
|
+
* Load the script conversion tables.
|
|
56
|
+
*
|
|
57
|
+
* Separate from the dictionary on purpose. A caller converting hanzi to pinyin
|
|
58
|
+
* — which is most of them — never fetches this, and a caller converting between
|
|
59
|
+
* the scripts fetches about 100 KB compressed rather than carrying it inside
|
|
60
|
+
* every tier. See SCRIPTS-AND-LOCALES.md.
|
|
61
|
+
*/
|
|
62
|
+
export declare function loadScriptTables(source: DictionarySource): Promise<ScriptTables>;
|
|
45
63
|
//# sourceMappingURL=source.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.d.ts","sourceRoot":"","sources":["../../src/dictionary/source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEvC;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACjD,2CAA2C;IAC3C,QAAQ,CAAC,KAA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AG;IACrC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B,CAMA;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAqB7D;AAED;;;;;GAKG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,kBAAkB,CAAC,CAQ7B;AAED;;GAEG;AACH,wBAAsB,cAAc,CAClC,MAAM,EAAE,gBAAgB,EACxB,IAAI,EAAE,IAAI,GACT,OAAO,CAAC,UAAU,CAAC,CAErB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,eAAe,CAAC;AAExC;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,YAAY,CAAC,CAEvB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { readScriptTables } from "../script/conversion.js";
|
|
1
2
|
import { Dictionary } from "./dictionary.js";
|
|
2
3
|
/**
|
|
3
4
|
* The three files a tier is made of.
|
|
@@ -57,4 +58,23 @@ export async function loadArtifact(source, tier) {
|
|
|
57
58
|
export async function loadDictionary(source, tier) {
|
|
58
59
|
return Dictionary.from(await loadArtifact(source, tier));
|
|
59
60
|
}
|
|
61
|
+
/**
|
|
62
|
+
* The file the script conversion tables live in.
|
|
63
|
+
*
|
|
64
|
+
* One file rather than one per table, and outside the tiers rather than
|
|
65
|
+
* repeated in each: script conversion does not get more accurate with a bigger
|
|
66
|
+
* dictionary the way reading does, so there is nothing to tier.
|
|
67
|
+
*/
|
|
68
|
+
export const SCRIPT_FILE = "script.map";
|
|
69
|
+
/**
|
|
70
|
+
* Load the script conversion tables.
|
|
71
|
+
*
|
|
72
|
+
* Separate from the dictionary on purpose. A caller converting hanzi to pinyin
|
|
73
|
+
* — which is most of them — never fetches this, and a caller converting between
|
|
74
|
+
* the scripts fetches about 100 KB compressed rather than carrying it inside
|
|
75
|
+
* every tier. See SCRIPTS-AND-LOCALES.md.
|
|
76
|
+
*/
|
|
77
|
+
export async function loadScriptTables(source) {
|
|
78
|
+
return readScriptTables(await source.text(SCRIPT_FILE));
|
|
79
|
+
}
|
|
60
80
|
//# sourceMappingURL=source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/dictionary/source.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"source.js","sourceRoot":"","sources":["../../src/dictionary/source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAqB,MAAM,yBAAyB,CAAC;AAE9E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkB7C;;GAEG;AACH,MAAM,UAAU,SAAS,CAAC,IAAU;IAKlC,OAAO;QACL,IAAI,EAAE,GAAG,IAAI,OAAO;QACpB,OAAO,EAAE,GAAG,IAAI,UAAU;QAC1B,WAAW,EAAE,GAAG,IAAI,OAAO;KAC5B,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,OAAe;IACzC,MAAM,EAAE,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC;IAC9E,MAAM,GAAG,GAAG,KAAK,EAAE,IAAY,EAAqB,EAAE;QACpD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,YAAY,EAAE,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC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AU,gBAAgB,CACpC,MAAwB;IAExB,OAAO,gBAAgB,CAAC,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { type NumberStyle } from "../decode/convert.js";
|
|
2
|
+
import type { SandhiOptions } from "../decode/sandhi.js";
|
|
3
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
4
|
+
import type { Locale } from "../script/script.js";
|
|
5
|
+
/**
|
|
6
|
+
* Whether a slug carries its tones.
|
|
7
|
+
*
|
|
8
|
+
* `numbers` writes them as digits — 中文 is `zhong1wen2` — and `none` leaves
|
|
9
|
+
* them off. Tones are on by default because dropping them collides: there are
|
|
10
|
+
* roughly 400 toneless syllables against 1300 toned ones, so a toneless slug
|
|
11
|
+
* runs 树, 书 and 输 together as `shu`. They are not a guarantee, though —
|
|
12
|
+
* 权利 and 权力 are both `quan2li4`, and only {@link SlugOptions.hash} tells
|
|
13
|
+
* those apart.
|
|
14
|
+
*/
|
|
15
|
+
export type SlugTones = "numbers" | "none";
|
|
16
|
+
/**
|
|
17
|
+
* Whether the syllables inside one word are separated.
|
|
18
|
+
*
|
|
19
|
+
* `join` writes a word as a word — 中文 is `zhong1wen2` — which is what 正词法
|
|
20
|
+
* asks for and what a reader expects in a URL. `separate` cuts every syllable
|
|
21
|
+
* apart, `zhong1-wen2`, for a caller matching a slug syllable by syllable.
|
|
22
|
+
*/
|
|
23
|
+
export type SlugSyllables = "join" | "separate";
|
|
24
|
+
/**
|
|
25
|
+
* How ü is written where the alphabet has no room for it.
|
|
26
|
+
*
|
|
27
|
+
* `v` is the input-method convention and keeps 绿 `lv4` apart from 路 `lu4`;
|
|
28
|
+
* `u` is prettier and merges them.
|
|
29
|
+
*/
|
|
30
|
+
export type SlugUmlaut = "v" | "u";
|
|
31
|
+
/**
|
|
32
|
+
* How a slug is built.
|
|
33
|
+
*/
|
|
34
|
+
export interface SlugOptions {
|
|
35
|
+
/** Whether tones are written. Defaults to `numbers`. */
|
|
36
|
+
readonly tones?: SlugTones;
|
|
37
|
+
/**
|
|
38
|
+
* What goes between words. Defaults to `-`.
|
|
39
|
+
*
|
|
40
|
+
* Written as given rather than checked, because the separator is the one
|
|
41
|
+
* place a caller decides what kind of identifier this is: `-` for a URL, `_`
|
|
42
|
+
* for a name in code, and the empty string for a key to match against.
|
|
43
|
+
*/
|
|
44
|
+
readonly separator?: string;
|
|
45
|
+
/** Whether the syllables within a word are separated. Defaults to `join`. */
|
|
46
|
+
readonly syllables?: SlugSyllables;
|
|
47
|
+
/** How ü is written. Defaults to `v`. */
|
|
48
|
+
readonly umlaut?: SlugUmlaut;
|
|
49
|
+
/**
|
|
50
|
+
* What to do with the digits in a text. Defaults to `keep`.
|
|
51
|
+
*
|
|
52
|
+
* The opposite of what a conversion defaults to, and deliberately: a slug for
|
|
53
|
+
* iPhone 15 评测 should be `iphone-15-ping2ce4` rather than
|
|
54
|
+
* `iphone-shi2wu3-ping2ce4`, because the digits are how anyone would look for
|
|
55
|
+
* it. `read` says them, for a caller that wants the text spoken.
|
|
56
|
+
*/
|
|
57
|
+
readonly numbers?: NumberStyle;
|
|
58
|
+
/**
|
|
59
|
+
* A short hash of the source text on the end. Defaults to none.
|
|
60
|
+
*
|
|
61
|
+
* `true` for {@link DEFAULT_HASH_LENGTH} characters, or a length of your own,
|
|
62
|
+
* up to {@link LONGEST_HASH}. See {@link hashOf} for what is hashed and why
|
|
63
|
+
* it is the hanzi rather than the pinyin.
|
|
64
|
+
*
|
|
65
|
+
* Unconditional rather than only where two slugs collide: a function that
|
|
66
|
+
* cannot see the rest of your corpus cannot know that they did. It narrows
|
|
67
|
+
* collisions rather than closing them, and checking the slug you generated
|
|
68
|
+
* against the ones you have stored is still yours to do.
|
|
69
|
+
*/
|
|
70
|
+
readonly hash?: number | boolean;
|
|
71
|
+
/**
|
|
72
|
+
* The longest the slug may be, counting any hash. Defaults to no limit.
|
|
73
|
+
*
|
|
74
|
+
* Cut at a word boundary, so a limit lands between words rather than through
|
|
75
|
+
* the middle of one. A single word longer than the limit is cut where the
|
|
76
|
+
* limit falls, since there is nowhere else to cut it, and the hash is never
|
|
77
|
+
* what gets dropped.
|
|
78
|
+
*/
|
|
79
|
+
readonly maxLength?: number;
|
|
80
|
+
/**
|
|
81
|
+
* What to write where a text slugs to nothing. Defaults to the empty string.
|
|
82
|
+
*
|
|
83
|
+
* 《》! has no letters in it, and neither does an empty text.
|
|
84
|
+
*/
|
|
85
|
+
readonly fallback?: string;
|
|
86
|
+
/** Which reading standard to use. Defaults to `zh-CN`. */
|
|
87
|
+
readonly locale?: Locale;
|
|
88
|
+
/** Which tone sandhi to apply. Defaults to what a conversion applies. */
|
|
89
|
+
readonly sandhi?: SandhiOptions;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* How many characters {@link SlugOptions.hash} writes when simply asked for.
|
|
93
|
+
*
|
|
94
|
+
* Four base-36 characters is 1.7 million values, which is far more than it
|
|
95
|
+
* looks: two texts only collide when their slugs *and* their hashes match, so
|
|
96
|
+
* the suffix is only ever telling apart the handful of texts sharing one slug,
|
|
97
|
+
* not the whole corpus.
|
|
98
|
+
*/
|
|
99
|
+
export declare const DEFAULT_HASH_LENGTH = 4;
|
|
100
|
+
/**
|
|
101
|
+
* The longest hash there is anything to fill.
|
|
102
|
+
*
|
|
103
|
+
* {@link hashOf} is 32 bits wide, and 36⁷ is the last power of 36 under 2³²:
|
|
104
|
+
* asking for an eighth character would add a place that some values can never
|
|
105
|
+
* reach, which looks like more uniqueness while being none.
|
|
106
|
+
*/
|
|
107
|
+
export declare const LONGEST_HASH = 7;
|
|
108
|
+
/**
|
|
109
|
+
* A 32-bit hash of a text, written in the letters and digits a slug allows.
|
|
110
|
+
*
|
|
111
|
+
* **The source text is what is hashed, not the pinyin.** Two texts needing a
|
|
112
|
+
* hash to tell them apart are, by definition, ones the pinyin already ran
|
|
113
|
+
* together: 权利 and 权力 are both `quan2li4`, and hashing that would give them
|
|
114
|
+
* the same suffix and settle nothing. Hashing the hanzi also means the suffix
|
|
115
|
+
* does not move when a later release reads a word differently, so a slug's tail
|
|
116
|
+
* is the stable half of it.
|
|
117
|
+
*
|
|
118
|
+
* FNV-1a with murmur3's finalizer, which is neither cryptographic nor trying to
|
|
119
|
+
* be: nothing here resists an attacker, and all that is being asked of it is
|
|
120
|
+
* that two texts a reader would call different land on different suffixes.
|
|
121
|
+
* Written out rather than reached for because the package has no runtime
|
|
122
|
+
* dependencies and the core imports no Node built-ins, and `crypto.subtle` —
|
|
123
|
+
* the one hash a browser ships — is asynchronous, which this is not.
|
|
124
|
+
*
|
|
125
|
+
* Normalised first, so that text typed as a decomposed sequence hashes as the
|
|
126
|
+
* same text once composed. 简体 and 繁體 are deliberately *not* folded together:
|
|
127
|
+
* a caller who wrote 头发 and 頭髮 separately meant them separately.
|
|
128
|
+
*/
|
|
129
|
+
export declare function hashOf(text: string, length: number): string;
|
|
130
|
+
/**
|
|
131
|
+
* Convert hanzi to a URL-safe slug.
|
|
132
|
+
*
|
|
133
|
+
* 我想学中文。 is `wo3-xiang3-xue2-zhong1wen2`, and the reason to ask a
|
|
134
|
+
* dictionary for it rather than a string is everything a slugifier working
|
|
135
|
+
* after the fact cannot recover: 银行 is `yin2hang2` and not `yin2xing2`
|
|
136
|
+
* because the word was decoded rather than the characters looked up one at a
|
|
137
|
+
* time; the hyphens fall between words because 正词法 grouping put them there;
|
|
138
|
+
* and 西安 is `xi-an` rather than `xian` — a different word — because the
|
|
139
|
+
* syllable boundary was still known when the slug was cut.
|
|
140
|
+
*
|
|
141
|
+
* Everything that is not Han is folded into the same alphabet and kept, so
|
|
142
|
+
* iPhone 15 评测 is `iphone-15-ping2ce4`, and everything else — punctuation,
|
|
143
|
+
* emoji, marks of any script — becomes a boundary between words.
|
|
144
|
+
*
|
|
145
|
+
* The options generalise it past URLs: a separator of `_` writes a name in
|
|
146
|
+
* code, and one of the empty string with `tones: "none"` writes a key to match
|
|
147
|
+
* a search box against, where someone typing `zhongwen` should find 中文. See
|
|
148
|
+
* the slug page in `docs/` for those written out.
|
|
149
|
+
*
|
|
150
|
+
* **A slug is not unique and this cannot make it one.** Tones narrow the
|
|
151
|
+
* collisions, {@link SlugOptions.hash} narrows them much further, and neither
|
|
152
|
+
* is a guarantee; a slug that has to be unique still has to be checked against
|
|
153
|
+
* the ones already stored.
|
|
154
|
+
*/
|
|
155
|
+
export declare function slug(dictionary: Dictionary, text: string, options?: SlugOptions): string;
|
|
156
|
+
//# sourceMappingURL=slug.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../src/format/slug.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,WAAW,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAGlD;;;;;;;;;GASG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,UAAU,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,UAAU,GAAG,GAAG,GAAG,GAAG,CAAC;AAEnC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,wDAAwD;IACxD,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B,6EAA6E;IAC7E,QAAQ,CAAC,SAAS,CAAC,EAAE,aAAa,CAAC;IACnC,yCAAyC;IACzC,QAAQ,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;IAC7B;;;;;;;OAOG;IACH,QAAQ,C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} from "./dictionary/traditional.js";
|
|
|
25
25
|
export type { ScriptPairing } from "./dictionary/traditional.js";
|
|
26
26
|
export { Dictionary } from "./dictionary/dictionary.js";
|
|
27
27
|
export type { WordEntry } from "./dictionary/dictionary.js";
|
|
28
|
-
export { fetchSource, loadArtifact, loadDictionary, tierFiles, } from "./dictionary/source.js";
|
|
28
|
+
export { fetchSource, loadArtifact, loadDictionary, loadScriptTables, SCRIPT_FILE, tierFiles, } from "./dictionary/source.js";
|
|
29
29
|
export type { DictionarySource } from "./dictionary/source.js";
|
|
30
30
|
export { convert, convertGreedily, convertPieces, joinPieces, } from "./decode/convert.js";
|
|
31
31
|
export type { ConvertedPiece, ConvertOptions } from "./decode/convert.js";
|
|
@@ -35,7 +35,14 @@ export { decodeReadings, decodeRun, decodeRunScored, decodeSpacing, } from "./de
|
|
|
35
35
|
export { convertToHtml, toHtml } from "./format/html.js";
|
|
36
36
|
export { convertToWadeGiles, toTranscription, type TranscriptionOptions, type WriteWord, } from "./format/transcription.js";
|
|
37
37
|
export type { HtmlOptions } from "./format/html.js";
|
|
38
|
+
export { slug } from "./format/slug.js";
|
|
39
|
+
export type { SlugOptions, SlugSyllables, SlugTones, SlugUmlaut, } from "./format/slug.js";
|
|
38
40
|
export { decodeGreedily } from "./decode/greedy.js";
|
|
41
|
+
export { isUncertainChoice, SCRIPT_EVIDENCE, SCRIPT_TARGETS, toScript, toScriptPieces, } from "./decode/script.js";
|
|
42
|
+
export type { ScriptChoice, ScriptConversion, ScriptEvidence, ScriptOptions, ScriptTarget, } from "./decode/script.js";
|
|
43
|
+
export { conversionKey, convertCharacter, convertCharacters, formsOf, isAmbiguousCharacter, readConversionKey, readScriptTables, writeScriptTables, } from "./script/conversion.js";
|
|
44
|
+
export type { CharacterConversion, ScriptTables } from "./script/conversion.js";
|
|
45
|
+
export { buildScriptTables } from "./dictionary/script-tables.js";
|
|
39
46
|
export { allEdges, buildLattice, cutPoints, READING_CHARGE, } from "./decode/lattice.js";
|
|
40
47
|
export type { Lattice, LatticeEdge } from "./decode/lattice.js";
|
|
41
48
|
export { isSettled, projectReadings, settledUnits, unitsOf, } from "./decode/locking.js";
|
|
@@ -84,6 +91,8 @@ export type { PunctuationStyle } from "./orthography/punctuation.js";
|
|
|
84
91
|
export { isSeparableStart, SEPARABLE_VOWELS } from "./syllable/separation.js";
|
|
85
92
|
export { detectScript, DEFAULT_LOCALE, isLocale, isScript, LOCALES, SCRIPTS, } from "./script/script.js";
|
|
86
93
|
export type { Locale, Script } from "./script/script.js";
|
|
94
|
+
export { DEFAULT_REGION, isReadingSensitive, REGIONS, toCanonicalGlyph, toCanonicalGlyphs, toRegionalGlyph, toRegionalGlyphs, } from "./script/glyphs.js";
|
|
95
|
+
export type { Region } from "./script/glyphs.js";
|
|
87
96
|
export { ATTESTED_SYLLABLES, DICTIONARY_SYLLABLES, isAttestedTone, RARE_SYLLABLES, SYLLABLE_TONES, } from "./syllable/inventory.js";
|
|
88
97
|
export { FINALS, INITIALS, isFinal, isInitial, isPalatalInitial, } from "./syllable/phonology.js";
|
|
89
98
|
export type { Final, Initial } from "./syllable/phonology.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,aAAa,EACb,aAAa,EACb,aAAa,EACb,oBAAoB,EACpB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACtE,YAAY,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAE5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wB,CAAC;AAErE,OAAO,EACL,aAAa,EACb,cAAc,EACd,aAAa,GACd,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAC/E,YAAY,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -16,13 +16,17 @@ export { OVERRIDE_READINGS, READING_OVERRIDES, readOverrideReading, } from "./di
|
|
|
16
16
|
export { readAlignedReading, readDictionaryReading, } from "./dictionary/reading.js";
|
|
17
17
|
export { pairScripts, TraditionalTable } from "./dictionary/traditional.js";
|
|
18
18
|
export { Dictionary } from "./dictionary/dictionary.js";
|
|
19
|
-
export { fetchSource, loadArtifact, loadDictionary, tierFiles, } from "./dictionary/source.js";
|
|
19
|
+
export { fetchSource, loadArtifact, loadDictionary, loadScriptTables, SCRIPT_FILE, tierFiles, } from "./dictionary/source.js";
|
|
20
20
|
export { convert, convertGreedily, convertPieces, joinPieces, } from "./decode/convert.js";
|
|
21
21
|
export { isUncertain, scoreReadings } from "./decode/confidence.js";
|
|
22
22
|
export { decodeReadings, decodeRun, decodeRunScored, decodeSpacing, } from "./decode/decode.js";
|
|
23
23
|
export { convertToHtml, toHtml } from "./format/html.js";
|
|
24
24
|
export { convertToWadeGiles, toTranscription, } from "./format/transcription.js";
|
|
25
|
+
export { slug } from "./format/slug.js";
|
|
25
26
|
export { decodeGreedily } from "./decode/greedy.js";
|
|
27
|
+
export { isUncertainChoice, SCRIPT_EVIDENCE, SCRIPT_TARGETS, toScript, toScriptPieces, } from "./decode/script.js";
|
|
28
|
+
export { conversionKey, convertCharacter, convertCharacters, formsOf, isAmbiguousCharacter, readConversionKey, readScriptTables, writeScriptTables, } from "./script/conversion.js";
|
|
29
|
+
export { buildScriptTables } from "./dictionary/script-tables.js";
|
|
26
30
|
export { allEdges, buildLattice, cutPoints, READING_CHARGE, } from "./decode/lattice.js";
|
|
27
31
|
export { isSettled, projectReadings, settledUnits, unitsOf, } from "./decode/locking.js";
|
|
28
32
|
export { applyEdgeRules, tagOf, wordEndingAt, wordStartingAt, } from "./decode/rules.js";
|
|
@@ -50,6 +54,7 @@ export { rewriteParts } from "./orthography/parts.js";
|
|
|
50
54
|
export { toLatinPunctuation, toLatinPunctuationParts, } from "./orthography/punctuation.js";
|
|
51
55
|
export { isSeparableStart, SEPARABLE_VOWELS } from "./syllable/separation.js";
|
|
52
56
|
export { detectScript, DEFAULT_LOCALE, isLocale, isScript, LOCALES, SCRIPTS, } from "./script/script.js";
|
|
57
|
+
export { DEFAULT_REGION, isReadingSensitive, REGIONS, toCanonicalGlyph, toCanonicalGlyphs, toRegionalGlyph, toRegionalGlyphs, } from "./script/glyphs.js";
|
|
53
58
|
export { ATTESTED_SYLLABLES, DICTIONARY_SYLLABLES, isAttestedTone, RARE_SYLLABLES, SYLLABLE_TONES, } from "./syllable/inventory.js";
|
|
54
59
|
export { FINALS, INITIALS, isFinal, isInitial, isPalatalInitial, } from "./syllable/phonology.js";
|
|
55
60
|
export { readWord, splitSyllables } from "./syllable/split.js";
|