@kensio/pinyinjs 1.6.0 → 1.7.1
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 +211 -5
- package/data/core.entries +393 -392
- package/data/core.freq +0 -0
- package/data/core.keys +1 -0
- package/data/full.entries +10220 -10220
- package/data/manifest.json +12 -12
- package/data/script.map +7 -7
- package/data/standard.entries +957 -956
- package/data/standard.freq +0 -0
- package/data/standard.keys +1 -0
- package/dist/cli/arguments.d.ts +38 -0
- package/dist/cli/arguments.d.ts.map +1 -1
- package/dist/cli/arguments.js +46 -0
- package/dist/cli/arguments.js.map +1 -1
- package/dist/cli/commands.d.ts.map +1 -1
- package/dist/cli/commands.js +207 -1
- package/dist/cli/commands.js.map +1 -1
- package/dist/cli/help.d.ts.map +1 -1
- package/dist/cli/help.js +5 -0
- package/dist/cli/help.js.map +1 -1
- package/dist/decode/convert.d.ts +16 -0
- package/dist/decode/convert.d.ts.map +1 -1
- package/dist/decode/convert.js +3 -28
- package/dist/decode/convert.js.map +1 -1
- package/dist/decode/runs.d.ts +11 -0
- package/dist/decode/runs.d.ts.map +1 -1
- package/dist/decode/runs.js +19 -0
- package/dist/decode/runs.js.map +1 -1
- package/dist/decode/segment.d.ts +66 -0
- package/dist/decode/segment.d.ts.map +1 -0
- package/dist/decode/segment.js +79 -0
- package/dist/decode/segment.js.map +1 -0
- package/dist/dictionary/artifact.d.ts +10 -0
- package/dist/dictionary/artifact.d.ts.map +1 -1
- package/dist/dictionary/artifact.js +17 -0
- package/dist/dictionary/artifact.js.map +1 -1
- package/dist/dictionary/assertions.d.ts.map +1 -1
- package/dist/dictionary/assertions.js +38 -0
- package/dist/dictionary/assertions.js.map +1 -1
- package/dist/dictionary/corpus-mass.d.ts +68 -0
- package/dist/dictionary/corpus-mass.d.ts.map +1 -0
- package/dist/dictionary/corpus-mass.js +163 -0
- package/dist/dictionary/corpus-mass.js.map +1 -0
- package/dist/dictionary/dictionary.d.ts +56 -0
- package/dist/dictionary/dictionary.d.ts.map +1 -1
- package/dist/dictionary/dictionary.js +116 -1
- package/dist/dictionary/dictionary.js.map +1 -1
- package/dist/dictionary/erhua.d.ts +4 -0
- package/dist/dictionary/erhua.d.ts.map +1 -1
- package/dist/dictionary/erhua.js +6 -0
- package/dist/dictionary/erhua.js.map +1 -1
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +16 -8
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/tiers.d.ts +2 -1
- package/dist/dictionary/tiers.d.ts.map +1 -1
- package/dist/dictionary/tiers.js +77 -11
- package/dist/dictionary/tiers.js.map +1 -1
- package/dist/grade/check.d.ts +156 -0
- package/dist/grade/check.d.ts.map +1 -0
- package/dist/grade/check.js +356 -0
- package/dist/grade/check.js.map +1 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/search/candidates.d.ts +84 -0
- package/dist/search/candidates.d.ts.map +1 -0
- package/dist/search/candidates.js +290 -0
- package/dist/search/candidates.js.map +1 -0
- package/dist/search/match.d.ts +72 -0
- package/dist/search/match.d.ts.map +1 -0
- package/dist/search/match.js +419 -0
- package/dist/search/match.js.map +1 -0
- package/dist/search/query.d.ts +49 -0
- package/dist/search/query.d.ts.map +1 -0
- package/dist/search/query.js +115 -0
- package/dist/search/query.js.map +1 -0
- package/dist/search/reverse-index.d.ts +141 -0
- package/dist/search/reverse-index.d.ts.map +1 -0
- package/dist/search/reverse-index.js +356 -0
- package/dist/search/reverse-index.js.map +1 -0
- package/dist/sources/unihan.d.ts +9 -0
- package/dist/sources/unihan.d.ts.map +1 -1
- package/dist/sources/unihan.js +12 -1
- package/dist/sources/unihan.js.map +1 -1
- package/package.json +2 -3
- package/CHANGELOG.md +0 -634
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { Dictionary } from "../dictionary/dictionary.js";
|
|
2
|
+
/**
|
|
3
|
+
* Fold a stored reading into the key a typist's spelling reaches it by.
|
|
4
|
+
*
|
|
5
|
+
* `yin2 hang2` becomes `yinhang` and `lü4 se4` becomes `luse`. Three things go:
|
|
6
|
+
* the spaces, because nobody types them; the tone digits, because a typist
|
|
7
|
+
* mostly does not write tones and a toned query is answered by filtering a
|
|
8
|
+
* toneless list rather than by a second index; and the umlaut, because `lu` and
|
|
9
|
+
* `lv` both have to reach 绿 and the only spelling both of them fold to is `lu`.
|
|
10
|
+
*
|
|
11
|
+
* The 儿化 r **stays**, so 玩儿 is keyed `wanr` and not `wan`. It is a letter a
|
|
12
|
+
* typist writes, and the query side reaches the key from both directions by
|
|
13
|
+
* searching `wan` and `wanr` alike — see `candidates`.
|
|
14
|
+
*
|
|
15
|
+
* Nothing here parses a syllable, which is what keeps a pass over every key in
|
|
16
|
+
* the dictionary affordable.
|
|
17
|
+
*/
|
|
18
|
+
export declare function readingKey(reading: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* A reverse index in the form it can be handed between threads.
|
|
21
|
+
*
|
|
22
|
+
* Three pieces, the same shape the forward index has: the reading keys as one
|
|
23
|
+
* sorted newline-joined blob, the dictionary positions grouped under them, and
|
|
24
|
+
* where each group begins. The two arrays are transferable and the blob is a
|
|
25
|
+
* string, so a worker can build this and post it back with no copy of the
|
|
26
|
+
* postings — which is the point, since the full tier's build is over half a
|
|
27
|
+
* second and does not belong on the main thread.
|
|
28
|
+
*/
|
|
29
|
+
export interface ReverseIndexData {
|
|
30
|
+
/** Sorted reading keys, newline-joined: a {@link KeyIndex} blob. */
|
|
31
|
+
readonly keys: string;
|
|
32
|
+
/** Dictionary positions, grouped by reading key, likeliest first. */
|
|
33
|
+
readonly postings: Uint32Array;
|
|
34
|
+
/** Where each key's postings begin, with one past the end on the tail. */
|
|
35
|
+
readonly starts: Uint32Array;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A reverse index being built, a slice at a time.
|
|
39
|
+
*
|
|
40
|
+
* The full tier costs about 510 ms to derive, which is thirty-odd frames, so the
|
|
41
|
+
* build is a state machine a caller can drive from `requestIdleCallback` rather
|
|
42
|
+
* than a function that takes the thread. `core` is 4 ms and `standard` is 62 ms,
|
|
43
|
+
* and both can simply be built with {@link ReverseIndex.of}.
|
|
44
|
+
*
|
|
45
|
+
* ```ts
|
|
46
|
+
* const build = ReverseIndex.building(dictionary);
|
|
47
|
+
* const tick = (): void => {
|
|
48
|
+
* const index = build.step();
|
|
49
|
+
* if (index === undefined) {
|
|
50
|
+
* requestIdleCallback(tick);
|
|
51
|
+
* }
|
|
52
|
+
* };
|
|
53
|
+
* requestIdleCallback(tick);
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
export interface ReverseIndexBuild {
|
|
57
|
+
/**
|
|
58
|
+
* How much of the build is done, from 0 to 1.
|
|
59
|
+
*/
|
|
60
|
+
readonly progress: number;
|
|
61
|
+
/**
|
|
62
|
+
* Do some more of the work, returning the index once there is none left.
|
|
63
|
+
*
|
|
64
|
+
* `positions` bounds a step to that many dictionary positions, or that many
|
|
65
|
+
* reading groups while the last pass is ranking them. It is a bound rather
|
|
66
|
+
* than a promise: the pass that sorts the reading keys cannot be divided, and
|
|
67
|
+
* is one step of its own.
|
|
68
|
+
*/
|
|
69
|
+
readonly step: (positions?: number) => ReverseIndex | undefined;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Which readings each word in the dictionary can be reached by.
|
|
73
|
+
*
|
|
74
|
+
* Every index in the package runs hanzi → reading; this is the other direction,
|
|
75
|
+
* and it is **derived on load rather than downloaded**. The measurement is in
|
|
76
|
+
* issue #71 and the summary is that shipping it would add 1,995 KB to the full
|
|
77
|
+
* tier — an 84% increase — to save under 60% of a build the client can do from
|
|
78
|
+
* bytes it already holds. Nothing new is fetched and no artifact exists.
|
|
79
|
+
*
|
|
80
|
+
* Held the way the forward index is held, and for the same reason: the reading
|
|
81
|
+
* keys are one sorted blob searched by binary search, and the postings are a
|
|
82
|
+
* `Uint32Array` of dictionary positions. That is 2.03 MB on the full tier where
|
|
83
|
+
* a `Map<string, number[]>` of the same content is 47.83 MB.
|
|
84
|
+
*
|
|
85
|
+
* A posting is a position rather than a word, which is what makes ranking free:
|
|
86
|
+
* a position indexes the frequency table directly, so the groups are sorted
|
|
87
|
+
* likeliest-first during the build and a query pays nothing for its order.
|
|
88
|
+
*/
|
|
89
|
+
export declare class ReverseIndex {
|
|
90
|
+
#private;
|
|
91
|
+
/**
|
|
92
|
+
* Derive the whole index in one go.
|
|
93
|
+
*
|
|
94
|
+
* About 4 ms on `core`, 62 ms on `standard` and 510 ms on `full`, measured on
|
|
95
|
+
* a machine roughly 2.5× a mid-range laptop. Use {@link ReverseIndex.building}
|
|
96
|
+
* for anything that has a frame to hold on to.
|
|
97
|
+
*/
|
|
98
|
+
static of(dictionary: Dictionary): ReverseIndex;
|
|
99
|
+
/**
|
|
100
|
+
* Start a build that can be driven a slice at a time.
|
|
101
|
+
*/
|
|
102
|
+
static building(dictionary: Dictionary): ReverseIndexBuild;
|
|
103
|
+
/**
|
|
104
|
+
* Wrap what a worker built and posted back.
|
|
105
|
+
*
|
|
106
|
+
* The dictionary is passed again rather than travelling with the data,
|
|
107
|
+
* because the positions are only meaningful against the artifact they were
|
|
108
|
+
* derived from — a dictionary of a different tier would resolve them to the
|
|
109
|
+
* wrong words.
|
|
110
|
+
*/
|
|
111
|
+
static from(dictionary: Dictionary, data: ReverseIndexData): ReverseIndex;
|
|
112
|
+
/**
|
|
113
|
+
* Wrap already-grouped postings. Use {@link ReverseIndex.of} or
|
|
114
|
+
* {@link ReverseIndex.from}.
|
|
115
|
+
*/
|
|
116
|
+
private constructor();
|
|
117
|
+
/**
|
|
118
|
+
* The dictionary the index was derived from, and resolves its postings
|
|
119
|
+
* against.
|
|
120
|
+
*/
|
|
121
|
+
get dictionary(): Dictionary;
|
|
122
|
+
/**
|
|
123
|
+
* How many distinct readings the index holds, which is its key count.
|
|
124
|
+
*/
|
|
125
|
+
get size(): number;
|
|
126
|
+
/**
|
|
127
|
+
* The dictionary positions read as a key, likeliest first.
|
|
128
|
+
*
|
|
129
|
+
* The key is the folded spelling {@link readingKey} produces — toneless, no
|
|
130
|
+
* spaces, ü written u — not a query. `candidates` is what turns what somebody
|
|
131
|
+
* types into one of these.
|
|
132
|
+
*
|
|
133
|
+
* A view onto the postings rather than a copy, so asking is free.
|
|
134
|
+
*/
|
|
135
|
+
positionsFor(key: string): Uint32Array;
|
|
136
|
+
/**
|
|
137
|
+
* The pieces, ready to be posted to another thread or held elsewhere.
|
|
138
|
+
*/
|
|
139
|
+
serialise(): ReverseIndexData;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=reverse-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse-index.d.ts","sourceRoot":"","sources":["../../src/search/reverse-index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AA6B9D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAYlD;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,gBAAgB;IAC/B,oEAAoE;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,0EAA0E;IAC1E,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;CAC9B;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B;;;;;;;OAOG;IACH,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,MAAM,KAAK,YAAY,GAAG,SAAS,CAAC;CACjE;AA+BD;;;;;;;;;;;;;;;;;GAiBG;AACH,qBAAa,YAAY;;IACvB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAO9C;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,GAAG,iBAAiB,CAEzD;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,gBAAgB,GAAG,YAAY,CAOxE;IAOD;;;OAGG;IACH,OAAO,eAUN;IAED;;;OAGG;IACH,IAAI,UAAU,IAAI,UAAU,CAE3B;IAED;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;;;;;;;OAQG;IACH,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CASrC;IAED;;OAEG;IACH,SAAS,IAAI,gBAAgB,CAM5B;CACF"}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { FREQUENCY_BUCKETS } from "../dictionary/frequency-table.js";
|
|
2
|
+
import { KeyIndex } from "../dictionary/key-index.js";
|
|
3
|
+
/**
|
|
4
|
+
* The separator between reading keys, matching what {@link KeyIndex} expects.
|
|
5
|
+
*/
|
|
6
|
+
const LINE = "\n";
|
|
7
|
+
const SPACE = 32;
|
|
8
|
+
const ZERO = 48;
|
|
9
|
+
const FIVE = 53;
|
|
10
|
+
const UMLAUT_U = "ü";
|
|
11
|
+
const PLAIN_U = "u";
|
|
12
|
+
/**
|
|
13
|
+
* How many positions one {@link ReverseIndexBuild.step} covers by default.
|
|
14
|
+
*
|
|
15
|
+
* Sized so that a step is a frame rather than several: the full tier's build is
|
|
16
|
+
* about 510 ms of work over 723,147 keys, so 20,000 keys is roughly 14 ms of it.
|
|
17
|
+
* A caller with a frame budget of its own should pass its own number rather than
|
|
18
|
+
* trust this one.
|
|
19
|
+
*/
|
|
20
|
+
const STEP = 20_000;
|
|
21
|
+
/**
|
|
22
|
+
* Fold a stored reading into the key a typist's spelling reaches it by.
|
|
23
|
+
*
|
|
24
|
+
* `yin2 hang2` becomes `yinhang` and `lü4 se4` becomes `luse`. Three things go:
|
|
25
|
+
* the spaces, because nobody types them; the tone digits, because a typist
|
|
26
|
+
* mostly does not write tones and a toned query is answered by filtering a
|
|
27
|
+
* toneless list rather than by a second index; and the umlaut, because `lu` and
|
|
28
|
+
* `lv` both have to reach 绿 and the only spelling both of them fold to is `lu`.
|
|
29
|
+
*
|
|
30
|
+
* The 儿化 r **stays**, so 玩儿 is keyed `wanr` and not `wan`. It is a letter a
|
|
31
|
+
* typist writes, and the query side reaches the key from both directions by
|
|
32
|
+
* searching `wan` and `wanr` alike — see `candidates`.
|
|
33
|
+
*
|
|
34
|
+
* Nothing here parses a syllable, which is what keeps a pass over every key in
|
|
35
|
+
* the dictionary affordable.
|
|
36
|
+
*/
|
|
37
|
+
export function readingKey(reading) {
|
|
38
|
+
let key = "";
|
|
39
|
+
for (let at = 0; at < reading.length; at++) {
|
|
40
|
+
/* c8 ignore next -- `at` is inside the string, so the fallback cannot fire */
|
|
41
|
+
const code = reading.codePointAt(at) ?? 0;
|
|
42
|
+
if (code === SPACE || (code >= ZERO && code <= FIVE)) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const character = reading.charAt(at);
|
|
46
|
+
key += character === UMLAUT_U ? PLAIN_U : character;
|
|
47
|
+
}
|
|
48
|
+
return key;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* What share of the build each pass is worth, for {@link ReverseIndexBuild.progress}.
|
|
52
|
+
*/
|
|
53
|
+
const SHARE = { counting: 0.45, filling: 0.45, ranking: 0.1 };
|
|
54
|
+
/**
|
|
55
|
+
* The empty posting list, shared rather than allocated per miss.
|
|
56
|
+
*/
|
|
57
|
+
const NONE = new Uint32Array(0);
|
|
58
|
+
/**
|
|
59
|
+
* Read a `Uint32Array` at an index that is in range by construction.
|
|
60
|
+
*
|
|
61
|
+
* `noUncheckedIndexedAccess` types every read as possibly undefined, and every
|
|
62
|
+
* one below is bounded by the layout of the array it indexes — a group start, a
|
|
63
|
+
* cursor inside a group, a bucket between 0 and 15. Gathered here rather than
|
|
64
|
+
* written as a fallback at each of them, since a fallback that cannot happen
|
|
65
|
+
* reads as a case somebody considered.
|
|
66
|
+
*/
|
|
67
|
+
/* c8 ignore next 3 -- the fallback is unreachable; see above */
|
|
68
|
+
function readAt(values, at) {
|
|
69
|
+
return values[at] ?? 0;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Which readings each word in the dictionary can be reached by.
|
|
73
|
+
*
|
|
74
|
+
* Every index in the package runs hanzi → reading; this is the other direction,
|
|
75
|
+
* and it is **derived on load rather than downloaded**. The measurement is in
|
|
76
|
+
* issue #71 and the summary is that shipping it would add 1,995 KB to the full
|
|
77
|
+
* tier — an 84% increase — to save under 60% of a build the client can do from
|
|
78
|
+
* bytes it already holds. Nothing new is fetched and no artifact exists.
|
|
79
|
+
*
|
|
80
|
+
* Held the way the forward index is held, and for the same reason: the reading
|
|
81
|
+
* keys are one sorted blob searched by binary search, and the postings are a
|
|
82
|
+
* `Uint32Array` of dictionary positions. That is 2.03 MB on the full tier where
|
|
83
|
+
* a `Map<string, number[]>` of the same content is 47.83 MB.
|
|
84
|
+
*
|
|
85
|
+
* A posting is a position rather than a word, which is what makes ranking free:
|
|
86
|
+
* a position indexes the frequency table directly, so the groups are sorted
|
|
87
|
+
* likeliest-first during the build and a query pays nothing for its order.
|
|
88
|
+
*/
|
|
89
|
+
export class ReverseIndex {
|
|
90
|
+
/**
|
|
91
|
+
* Derive the whole index in one go.
|
|
92
|
+
*
|
|
93
|
+
* About 4 ms on `core`, 62 ms on `standard` and 510 ms on `full`, measured on
|
|
94
|
+
* a machine roughly 2.5× a mid-range laptop. Use {@link ReverseIndex.building}
|
|
95
|
+
* for anything that has a frame to hold on to.
|
|
96
|
+
*/
|
|
97
|
+
static of(dictionary) {
|
|
98
|
+
const build = this.building(dictionary);
|
|
99
|
+
let index = build.step(Number.POSITIVE_INFINITY);
|
|
100
|
+
while (index === undefined) {
|
|
101
|
+
index = build.step(Number.POSITIVE_INFINITY);
|
|
102
|
+
}
|
|
103
|
+
return index;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Start a build that can be driven a slice at a time.
|
|
107
|
+
*/
|
|
108
|
+
static building(dictionary) {
|
|
109
|
+
return startBuild(dictionary);
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Wrap what a worker built and posted back.
|
|
113
|
+
*
|
|
114
|
+
* The dictionary is passed again rather than travelling with the data,
|
|
115
|
+
* because the positions are only meaningful against the artifact they were
|
|
116
|
+
* derived from — a dictionary of a different tier would resolve them to the
|
|
117
|
+
* wrong words.
|
|
118
|
+
*/
|
|
119
|
+
static from(dictionary, data) {
|
|
120
|
+
return new ReverseIndex(dictionary, KeyIndex.from(data.keys), data.postings, data.starts);
|
|
121
|
+
}
|
|
122
|
+
#dictionary;
|
|
123
|
+
#keys;
|
|
124
|
+
#postings;
|
|
125
|
+
#starts;
|
|
126
|
+
/**
|
|
127
|
+
* Wrap already-grouped postings. Use {@link ReverseIndex.of} or
|
|
128
|
+
* {@link ReverseIndex.from}.
|
|
129
|
+
*/
|
|
130
|
+
constructor(dictionary, keys, postings, starts) {
|
|
131
|
+
this.#dictionary = dictionary;
|
|
132
|
+
this.#keys = keys;
|
|
133
|
+
this.#postings = postings;
|
|
134
|
+
this.#starts = starts;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* The dictionary the index was derived from, and resolves its postings
|
|
138
|
+
* against.
|
|
139
|
+
*/
|
|
140
|
+
get dictionary() {
|
|
141
|
+
return this.#dictionary;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* How many distinct readings the index holds, which is its key count.
|
|
145
|
+
*/
|
|
146
|
+
get size() {
|
|
147
|
+
return this.#keys.size;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* The dictionary positions read as a key, likeliest first.
|
|
151
|
+
*
|
|
152
|
+
* The key is the folded spelling {@link readingKey} produces — toneless, no
|
|
153
|
+
* spaces, ü written u — not a query. `candidates` is what turns what somebody
|
|
154
|
+
* types into one of these.
|
|
155
|
+
*
|
|
156
|
+
* A view onto the postings rather than a copy, so asking is free.
|
|
157
|
+
*/
|
|
158
|
+
positionsFor(key) {
|
|
159
|
+
const found = this.#keys.lookup(key);
|
|
160
|
+
if (!found.isKey) {
|
|
161
|
+
return NONE;
|
|
162
|
+
}
|
|
163
|
+
return this.#postings.subarray(readAt(this.#starts, found.index), readAt(this.#starts, found.index + 1));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* The pieces, ready to be posted to another thread or held elsewhere.
|
|
167
|
+
*/
|
|
168
|
+
serialise() {
|
|
169
|
+
return {
|
|
170
|
+
keys: this.#keys.serialise(),
|
|
171
|
+
postings: this.#postings,
|
|
172
|
+
starts: this.#starts,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* The streaming build, which never holds every reading at once.
|
|
178
|
+
*
|
|
179
|
+
* Three passes over the dictionary — count the groups, fill them, rank them —
|
|
180
|
+
* with each key's reading recomputed in the fill pass rather than kept from the
|
|
181
|
+
* count pass. That trade is the whole reason this is safe on a phone: keeping
|
|
182
|
+
* all 723,147 readings costs 39 MB retained and peaks at 65 MB, where
|
|
183
|
+
* recomputing them peaks at 25 MB for a 2 MB result.
|
|
184
|
+
*
|
|
185
|
+
* A closure rather than a class because the state is a cursor and four buffers
|
|
186
|
+
* that only the passes below ever touch, and because two of them are dropped
|
|
187
|
+
* part way through: what is live during counting is not what is live during
|
|
188
|
+
* ranking.
|
|
189
|
+
*/
|
|
190
|
+
function startBuild(dictionary) {
|
|
191
|
+
const readings = dictionary.readingsInOrder();
|
|
192
|
+
let counts = new Map();
|
|
193
|
+
let pass = "counting";
|
|
194
|
+
let at = 0;
|
|
195
|
+
let keys = [];
|
|
196
|
+
let slots = new Map();
|
|
197
|
+
let starts = new Uint32Array(1);
|
|
198
|
+
let cursors = new Uint32Array(0);
|
|
199
|
+
let postings = NONE;
|
|
200
|
+
let widest = 0;
|
|
201
|
+
/** The reading key at a position, or the empty string where there is none. */
|
|
202
|
+
const keyAt = (position) => readingKey(readings.readingAt(position));
|
|
203
|
+
/** Where a position sorts, commonest first: the bucket, counted downwards. */
|
|
204
|
+
const rankOf = (position) => FREQUENCY_BUCKETS - 1 - dictionary.frequencyAt(position);
|
|
205
|
+
/** Count how many words each reading has, so the postings can be one array. */
|
|
206
|
+
const count = (positions) => {
|
|
207
|
+
const end = Math.min(readings.size, at + positions);
|
|
208
|
+
for (; at < end; at++) {
|
|
209
|
+
const key = keyAt(at);
|
|
210
|
+
if (key !== "") {
|
|
211
|
+
counts.set(key, (counts.get(key) ?? 0) + 1);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (at >= readings.size) {
|
|
215
|
+
pass = "ordering";
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Sort the reading keys and lay out where each group's postings go.
|
|
220
|
+
*
|
|
221
|
+
* One step of its own, because a sort cannot be resumed part way through.
|
|
222
|
+
*/
|
|
223
|
+
const order = () => {
|
|
224
|
+
// Sorted as pairs rather than by key and looked up again, and by code unit
|
|
225
|
+
// rather than by locale, which is the order `KeyIndex` searches in.
|
|
226
|
+
const ordered = [...counts].toSorted(([left], [right]) => left < right ? -1 : Number(left > right));
|
|
227
|
+
keys = ordered.map(([key]) => key);
|
|
228
|
+
starts = new Uint32Array(keys.length + 1);
|
|
229
|
+
let running = 0;
|
|
230
|
+
for (const [group, [key, held]] of ordered.entries()) {
|
|
231
|
+
slots.set(key, group);
|
|
232
|
+
starts[group] = running;
|
|
233
|
+
running += held;
|
|
234
|
+
widest = Math.max(widest, held);
|
|
235
|
+
}
|
|
236
|
+
starts[keys.length] = running;
|
|
237
|
+
counts = new Map();
|
|
238
|
+
cursors = starts.slice(0, keys.length);
|
|
239
|
+
postings = new Uint32Array(running);
|
|
240
|
+
at = 0;
|
|
241
|
+
pass = "filling";
|
|
242
|
+
};
|
|
243
|
+
/** Place each position in its reading's group, recomputing the reading. */
|
|
244
|
+
const fill = (positions) => {
|
|
245
|
+
const end = Math.min(readings.size, at + positions);
|
|
246
|
+
for (; at < end; at++) {
|
|
247
|
+
const key = keyAt(at);
|
|
248
|
+
const group = key === "" ? undefined : slots.get(key);
|
|
249
|
+
if (group === undefined) {
|
|
250
|
+
continue;
|
|
251
|
+
}
|
|
252
|
+
const cursor = readAt(cursors, group);
|
|
253
|
+
postings[cursor] = at;
|
|
254
|
+
cursors[group] = cursor + 1;
|
|
255
|
+
}
|
|
256
|
+
if (at >= readings.size) {
|
|
257
|
+
slots = new Map();
|
|
258
|
+
cursors = new Uint32Array(0);
|
|
259
|
+
at = 0;
|
|
260
|
+
pass = "ranking";
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
/**
|
|
264
|
+
* Sort each group likeliest-first, which is a counting sort on the bucket.
|
|
265
|
+
*
|
|
266
|
+
* Buckets run 0 to 15, so there is nothing to compare: tally the group, turn
|
|
267
|
+
* the tally into offsets, and deal the postings out. Stable, so two words in
|
|
268
|
+
* the same bucket keep the dictionary's own order and the result does not
|
|
269
|
+
* depend on how the fill pass happened to lay the postings down.
|
|
270
|
+
*/
|
|
271
|
+
const rank = (groups) => {
|
|
272
|
+
const scratch = new Uint32Array(widest);
|
|
273
|
+
const tally = new Uint32Array(FREQUENCY_BUCKETS);
|
|
274
|
+
const end = Math.min(keys.length, at + groups);
|
|
275
|
+
for (; at < end; at++) {
|
|
276
|
+
const from = readAt(starts, at);
|
|
277
|
+
const to = readAt(starts, at + 1);
|
|
278
|
+
tally.fill(0);
|
|
279
|
+
for (let cursor = from; cursor < to; cursor++) {
|
|
280
|
+
const position = readAt(postings, cursor);
|
|
281
|
+
scratch[cursor - from] = position;
|
|
282
|
+
const bucket = rankOf(position);
|
|
283
|
+
tally[bucket] = readAt(tally, bucket) + 1;
|
|
284
|
+
}
|
|
285
|
+
let running = from;
|
|
286
|
+
for (let bucket = 0; bucket < FREQUENCY_BUCKETS; bucket++) {
|
|
287
|
+
const held = readAt(tally, bucket);
|
|
288
|
+
tally[bucket] = running;
|
|
289
|
+
running += held;
|
|
290
|
+
}
|
|
291
|
+
for (let cursor = 0; cursor < to - from; cursor++) {
|
|
292
|
+
const position = readAt(scratch, cursor);
|
|
293
|
+
const bucket = rankOf(position);
|
|
294
|
+
postings[readAt(tally, bucket)] = position;
|
|
295
|
+
tally[bucket] = readAt(tally, bucket) + 1;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (at < keys.length) {
|
|
299
|
+
return undefined;
|
|
300
|
+
}
|
|
301
|
+
pass = "done";
|
|
302
|
+
return ReverseIndex.from(dictionary, {
|
|
303
|
+
keys: keys.join(LINE),
|
|
304
|
+
postings,
|
|
305
|
+
starts,
|
|
306
|
+
});
|
|
307
|
+
};
|
|
308
|
+
return {
|
|
309
|
+
get progress() {
|
|
310
|
+
const size = Math.max(1, readings.size);
|
|
311
|
+
switch (pass) {
|
|
312
|
+
case "counting": {
|
|
313
|
+
return (SHARE.counting * at) / size;
|
|
314
|
+
}
|
|
315
|
+
case "ordering": {
|
|
316
|
+
return SHARE.counting;
|
|
317
|
+
}
|
|
318
|
+
case "filling": {
|
|
319
|
+
return SHARE.counting + (SHARE.filling * at) / size;
|
|
320
|
+
}
|
|
321
|
+
case "ranking": {
|
|
322
|
+
return (SHARE.counting +
|
|
323
|
+
SHARE.filling +
|
|
324
|
+
(SHARE.ranking * at) / Math.max(1, keys.length));
|
|
325
|
+
}
|
|
326
|
+
case "done": {
|
|
327
|
+
return 1;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
},
|
|
331
|
+
step(positions = STEP) {
|
|
332
|
+
switch (pass) {
|
|
333
|
+
case "counting": {
|
|
334
|
+
count(positions);
|
|
335
|
+
return undefined;
|
|
336
|
+
}
|
|
337
|
+
case "ordering": {
|
|
338
|
+
order();
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
case "filling": {
|
|
342
|
+
fill(positions);
|
|
343
|
+
return undefined;
|
|
344
|
+
}
|
|
345
|
+
case "ranking": {
|
|
346
|
+
return rank(positions);
|
|
347
|
+
}
|
|
348
|
+
/* c8 ignore next 3 -- a finished build is not stepped again */
|
|
349
|
+
case "done": {
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=reverse-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reverse-index.js","sourceRoot":"","sources":["../../src/search/reverse-index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD;;GAEG;AACH,MAAM,IAAI,GAAG,IAAI,CAAC;AAElB,MAAM,KAAK,GAAG,EAAE,CAAC;AAEjB,MAAM,IAAI,GAAG,EAAE,CAAC;AAEhB,MAAM,IAAI,GAAG,EAAE,CAAC;AAEhB,MAAM,QAAQ,GAAG,GAAG,CAAC;AAErB,MAAM,OAAO,GAAG,GAAG,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC;QAC3C,8EAA8E;QAC9E,MAAM,IAAI,GAAG,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QAC1C,IAAI,IAAI,KAAK,KAAK,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,CA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gBACX,CAAC;YACH,CAAC;QACH,CAAC;QACD,IAAI,CAAC,SAAS,GAAW,IAAI;YAC3B,QAAQ,IAAI,EAAE,CAAC;gBACb,KAAK,UAAU,EAAE,CAAC;oBAChB,KAAK,CAAC,SAAS,CAAC,CAAC;oBACjB,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,KAAK,UAAU,EAAE,CAAC;oBAChB,KAAK,EAAE,CAAC;oBACR,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,KAAK,SAAS,EAAE,CAAC;oBACf,IAAI,CAAC,SAAS,CAAC,CAAC;oBAChB,OAAO,SAAS,CAAC;gBACnB,CAAC;gBACD,KAAK,SAAS,EAAE,CAAC;oBACf,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC;gBACzB,CAAC;gBACD,+DAA+D;gBAC/D,KAAK,MAAM,EAAE,CAAC;oBACZ,OAAO,SAAS,CAAC;gBACnB,CAAC;YACH,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/sources/unihan.d.ts
CHANGED
|
@@ -58,6 +58,15 @@ export type ReadingField = (typeof READING_FIELDS)[number];
|
|
|
58
58
|
* most careful to read.
|
|
59
59
|
*/
|
|
60
60
|
export declare const FREQUENCY_FIELD = "kHanyuPinlu";
|
|
61
|
+
/**
|
|
62
|
+
* Whether `kHanyuPinlu` ranks this character's readings against each other.
|
|
63
|
+
*
|
|
64
|
+
* True only where it lists more than one, which is the difference between a
|
|
65
|
+
* ranking and a bare observation — see {@link fieldOrder}. It decides both what
|
|
66
|
+
* ranks the readings here and whether anything downstream is entitled to
|
|
67
|
+
* re-rank them, so it is one predicate rather than two.
|
|
68
|
+
*/
|
|
69
|
+
export declare function isFrequencyRanked(fields: ReadonlyMap<ReadingField, readonly string[]>): boolean;
|
|
61
70
|
/**
|
|
62
71
|
* Read the readings out of a Unihan data file such as `Unihan_Readings.txt`.
|
|
63
72
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unihan.d.ts","sourceRoot":"","sources":["../../src/sources/unihan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC9D;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAaD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,YACzB,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,CACF,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,gBAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"unihan.d.ts","sourceRoot":"","sources":["../../src/sources/unihan.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC;;;;;;;;OAQG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC9D;;;;;;OAMG;IACH,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAaD;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,YACzB,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,CACF,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,gBAAuC,CAAC;AA+BpE;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,WAAW,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC,GACnD,OAAO,CAET;AAyDD;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CA+C7E;AAUD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;IAC5D,mDAAmD;IACnD,QAAQ,CAAC,WAAW,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC;CAC9D;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CA2BhE"}
|
package/dist/sources/unihan.js
CHANGED
|
@@ -61,6 +61,17 @@ function readFieldValue(field, value) {
|
|
|
61
61
|
.flatMap((reading) => reading.split(","))
|
|
62
62
|
.filter((reading) => reading !== "");
|
|
63
63
|
}
|
|
64
|
+
/**
|
|
65
|
+
* Whether `kHanyuPinlu` ranks this character's readings against each other.
|
|
66
|
+
*
|
|
67
|
+
* True only where it lists more than one, which is the difference between a
|
|
68
|
+
* ranking and a bare observation — see {@link fieldOrder}. It decides both what
|
|
69
|
+
* ranks the readings here and whether anything downstream is entitled to
|
|
70
|
+
* re-rank them, so it is one predicate rather than two.
|
|
71
|
+
*/
|
|
72
|
+
export function isFrequencyRanked(fields) {
|
|
73
|
+
return (fields.get(FREQUENCY_FIELD) ?? []).length > 1;
|
|
74
|
+
}
|
|
64
75
|
/**
|
|
65
76
|
* Which fields to trust, in order, for one character.
|
|
66
77
|
*
|
|
@@ -84,7 +95,7 @@ function readFieldValue(field, value) {
|
|
|
84
95
|
* nothing that a word entry does not already settle.
|
|
85
96
|
*/
|
|
86
97
|
function fieldOrder(fields) {
|
|
87
|
-
if ((fields
|
|
98
|
+
if (isFrequencyRanked(fields)) {
|
|
88
99
|
return READING_FIELDS;
|
|
89
100
|
}
|
|
90
101
|
return [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unihan.js","sourceRoot":"","sources":["../../src/sources/unihan.ts"],"names":[],"mappings":"AAgCA;;GAEG;AACH,MAAM,UAAU,GAAG,+BAA+B,CAAC;AAEnD;;;GAGG;AACH,MAAM,kBAAkB,GAAG,kBAAkB,CAAC;AAE9C;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,aAAa;IACb,WAAW;IACX,WAAW;IACX,UAAU;CACF,CAAC;AAOX;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,aAAoC,CAAC;AAEpE;;;;;;GAMG;AACH,SAAS,cAAc,CAAC,KAAmB,EAAE,KAAa;IACxD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,EAAE,CAAC,CAAC;IAEnE,IAAI,KAAK,KAAK,aAAa,EAAE,CAAC;QAC5B,OAAO,MAAM;aACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aAC9C,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,IAAI,CAAC;aACjC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;aACtE,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CA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,KAAK,oBAAoB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC;QAChE,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,QAAQ,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;AACrC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kensio/pinyinjs",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Chinese hanzi to pinyin conversion",
|
|
5
5
|
"repository": "https://github.com/KensioSoftware/pinyinjs",
|
|
6
6
|
"homepage": "https://pinyinjs.dev",
|
|
@@ -26,7 +26,6 @@
|
|
|
26
26
|
"dist",
|
|
27
27
|
"data",
|
|
28
28
|
"README.md",
|
|
29
|
-
"CHANGELOG.md",
|
|
30
29
|
"LICENSE",
|
|
31
30
|
"NOTICE"
|
|
32
31
|
],
|
|
@@ -67,7 +66,7 @@
|
|
|
67
66
|
"@types/node": "^26.0.0",
|
|
68
67
|
"@typescript/native": "npm:typescript@^7.0.2",
|
|
69
68
|
"@vitest/coverage-v8": "^4.1.10",
|
|
70
|
-
"conventional-changelog-conventionalcommits": "
|
|
69
|
+
"conventional-changelog-conventionalcommits": "9.3.1",
|
|
71
70
|
"fta-cli": "^3.0.0",
|
|
72
71
|
"jiti": "^2.7.0",
|
|
73
72
|
"oxfmt": "^0.62.0",
|