@kensio/pinyinjs 1.7.6 → 1.7.7
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/data/full.entries +46 -46
- package/data/manifest.json +8 -8
- package/data/script.map +102 -0
- package/data/standard.entries +8 -8
- package/dist/decode/chang-complement.d.ts +19 -0
- package/dist/decode/chang-complement.d.ts.map +1 -0
- package/dist/decode/chang-complement.js +113 -0
- package/dist/decode/chang-complement.js.map +1 -0
- package/dist/decode/chang-context.d.ts +9 -7
- package/dist/decode/chang-context.d.ts.map +1 -1
- package/dist/decode/chang-context.js +36 -3
- package/dist/decode/chang-context.js.map +1 -1
- package/dist/decode/chang-rule.d.ts +25 -15
- package/dist/decode/chang-rule.d.ts.map +1 -1
- package/dist/decode/chang-rule.js +38 -19
- package/dist/decode/chang-rule.js.map +1 -1
- package/dist/decode/convert-pipeline.d.ts.map +1 -1
- package/dist/decode/convert-pipeline.js +3 -3
- package/dist/decode/convert-pipeline.js.map +1 -1
- package/dist/decode/de-rule.d.ts +20 -0
- package/dist/decode/de-rule.d.ts.map +1 -1
- package/dist/decode/de-rule.js +87 -1
- package/dist/decode/de-rule.js.map +1 -1
- package/dist/decode/decode.d.ts +12 -25
- package/dist/decode/decode.d.ts.map +1 -1
- package/dist/decode/decode.js +10 -47
- package/dist/decode/decode.js.map +1 -1
- package/dist/decode/decoders.d.ts +9 -4
- package/dist/decode/decoders.d.ts.map +1 -1
- package/dist/decode/decoders.js +7 -7
- package/dist/decode/decoders.js.map +1 -1
- package/dist/decode/edge-context.d.ts +19 -0
- package/dist/decode/edge-context.d.ts.map +1 -1
- package/dist/decode/edge-context.js +41 -0
- package/dist/decode/edge-context.js.map +1 -1
- package/dist/decode/lattice-decode.d.ts +28 -0
- package/dist/decode/lattice-decode.d.ts.map +1 -0
- package/dist/decode/lattice-decode.js +48 -0
- package/dist/decode/lattice-decode.js.map +1 -0
- package/dist/decode/lattice-slice.d.ts +22 -6
- package/dist/decode/lattice-slice.d.ts.map +1 -1
- package/dist/decode/lattice-slice.js +24 -18
- package/dist/decode/lattice-slice.js.map +1 -1
- package/dist/decode/numbers.d.ts +0 -8
- package/dist/decode/numbers.d.ts.map +1 -1
- package/dist/decode/numbers.js +0 -10
- package/dist/decode/numbers.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +1 -1
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +3 -2
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/rules.d.ts +1 -1
- package/dist/decode/rules.d.ts.map +1 -1
- package/dist/decode/rules.js +1 -1
- package/dist/decode/rules.js.map +1 -1
- package/dist/decode/run-context.d.ts +33 -0
- package/dist/decode/run-context.d.ts.map +1 -0
- package/dist/decode/run-context.js +47 -0
- package/dist/decode/run-context.js.map +1 -0
- package/dist/decode/run-lattice.d.ts +13 -10
- package/dist/decode/run-lattice.d.ts.map +1 -1
- package/dist/decode/run-lattice.js +15 -12
- package/dist/decode/run-lattice.js.map +1 -1
- package/dist/decode/script-region.d.ts +15 -0
- package/dist/decode/script-region.d.ts.map +1 -0
- package/dist/decode/script-region.js +61 -0
- package/dist/decode/script-region.js.map +1 -0
- package/dist/decode/script-types.d.ts +11 -2
- package/dist/decode/script-types.d.ts.map +1 -1
- package/dist/decode/script-types.js +2 -1
- package/dist/decode/script-types.js.map +1 -1
- package/dist/decode/script-words.d.ts +7 -5
- package/dist/decode/script-words.d.ts.map +1 -1
- package/dist/decode/script-words.js +18 -25
- package/dist/decode/script-words.js.map +1 -1
- package/dist/decode/script.d.ts.map +1 -1
- package/dist/decode/script.js +2 -1
- package/dist/decode/script.js.map +1 -1
- package/dist/dictionary/measure-tone.d.ts +36 -0
- package/dist/dictionary/measure-tone.d.ts.map +1 -0
- package/dist/dictionary/measure-tone.js +139 -0
- package/dist/dictionary/measure-tone.js.map +1 -0
- package/dist/dictionary/merge-types.d.ts +8 -3
- package/dist/dictionary/merge-types.d.ts.map +1 -1
- package/dist/dictionary/merge-types.js.map +1 -1
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +7 -1
- package/dist/dictionary/merge.js.map +1 -1
- package/dist/dictionary/overrides.d.ts +5 -0
- package/dist/dictionary/overrides.d.ts.map +1 -1
- package/dist/dictionary/overrides.js +5 -5
- package/dist/dictionary/overrides.js.map +1 -1
- package/dist/dictionary/script-tables.js +91 -13
- package/dist/dictionary/script-tables.js.map +1 -1
- package/dist/dictionary/word-readings.d.ts.map +1 -1
- package/dist/dictionary/word-readings.js +3 -0
- package/dist/dictionary/word-readings.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/script/glyphs.d.ts +9 -8
- package/dist/script/glyphs.d.ts.map +1 -1
- package/dist/script/glyphs.js +21 -48
- package/dist/script/glyphs.js.map +1 -1
- package/dist/script/reading-splits.d.ts +41 -0
- package/dist/script/reading-splits.d.ts.map +1 -0
- package/dist/script/reading-splits.js +98 -0
- package/dist/script/reading-splits.js.map +1 -0
- package/package.json +1 -1
package/dist/decode/rules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/decode/rules.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,cAAc,
|
|
1
|
+
{"version":3,"file":"rules.js","sourceRoot":"","sources":["../../src/decode/rules.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,MAAM,EACN,YAAY,EACZ,KAAK,EACL,YAAY,EACZ,aAAa,EACb,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAsC3B;;;;;;;GAOG;AACH,SAAS,aAAa,CAAC,OAAgB;IACrC,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC;IACzC,MAAM,OAAO,GAAG,KAAK,CAAC,IA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AAK,EAAE,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CACjC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAC7C;KACF,CAAC;IACF,OAAO,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a Han run is handed about the numbers around it.
|
|
3
|
+
*
|
|
4
|
+
* A run is decoded on its own, so the digits either side of it are invisible to
|
|
5
|
+
* it unless something puts them there. This is what puts them there, as the
|
|
6
|
+
* 汉字 they would have been written with.
|
|
7
|
+
*/
|
|
8
|
+
import type { NumeralSegment } from "../numerals/text.js";
|
|
9
|
+
import type { DecodeContext } from "./lattice-slice.js";
|
|
10
|
+
import type { TextRun } from "./runs.js";
|
|
11
|
+
/**
|
|
12
|
+
* The 汉字 a number in front of a Han run stands for, for that run's decode.
|
|
13
|
+
*
|
|
14
|
+
* Only the last segment of the run before, because only that one touches the
|
|
15
|
+
* Han: the D of 3D银行 comes between them, and a decode of 银行 that saw 三
|
|
16
|
+
* beside it would be reading a text nobody wrote.
|
|
17
|
+
*/
|
|
18
|
+
export declare function numeralBefore(segments: readonly NumeralSegment[]): string;
|
|
19
|
+
/**
|
|
20
|
+
* The same, for the number after a Han run: only the first segment of it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function numeralAfter(segments: readonly NumeralSegment[]): string;
|
|
23
|
+
/**
|
|
24
|
+
* The 汉字 either side of a Han run, once the digits around it have been read.
|
|
25
|
+
*
|
|
26
|
+
* 那条河长300公里 is four runs, and the 长 ends the first of them, so a rule
|
|
27
|
+
* asking what the 长 is measured in used to see nothing at all: the numeral is
|
|
28
|
+
* one run away and the 公里 two. This hands the decode what the sentence would
|
|
29
|
+
* have said spelled out, which is the number in front, and the number behind
|
|
30
|
+
* with the Han that carries on from it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function contextAround(runs: readonly TextRun[], read: readonly (readonly NumeralSegment[])[], at: number): DecodeContext;
|
|
33
|
+
//# sourceMappingURL=run-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-context.d.ts","sourceRoot":"","sources":["../../src/decode/run-context.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAazC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAEzE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,GAAG,MAAM,CAExE;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,OAAO,EAAE,EACxB,IAAI,EAAE,SAAS,CAAC,SAAS,cAAc,EAAE,CAAC,EAAE,EAC5C,EAAE,EAAE,MAAM,GACT,aAAa,CAUf"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { toCharacters } from "../script/characters.js";
|
|
2
|
+
/**
|
|
3
|
+
* How far past a number a run's decode is allowed to see, in characters.
|
|
4
|
+
*
|
|
5
|
+
* The same four {@link import("./edge-context.js").wordStartingAt} looks ahead
|
|
6
|
+
* by, and for the same reason: four characters is as far as a rule can reach,
|
|
7
|
+
* so carrying more would be lattice nobody reads. A prefix can only take words
|
|
8
|
+
* away and never invent one, so cutting the run here costs the decode nothing
|
|
9
|
+
* it would otherwise have had.
|
|
10
|
+
*/
|
|
11
|
+
const READS_AHEAD = 4;
|
|
12
|
+
/**
|
|
13
|
+
* The 汉字 a number in front of a Han run stands for, for that run's decode.
|
|
14
|
+
*
|
|
15
|
+
* Only the last segment of the run before, because only that one touches the
|
|
16
|
+
* Han: the D of 3D银行 comes between them, and a decode of 银行 that saw 三
|
|
17
|
+
* beside it would be reading a text nobody wrote.
|
|
18
|
+
*/
|
|
19
|
+
export function numeralBefore(segments) {
|
|
20
|
+
return segments.at(-1)?.hanzi ?? "";
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The same, for the number after a Han run: only the first segment of it.
|
|
24
|
+
*/
|
|
25
|
+
export function numeralAfter(segments) {
|
|
26
|
+
return segments[0]?.hanzi ?? "";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The 汉字 either side of a Han run, once the digits around it have been read.
|
|
30
|
+
*
|
|
31
|
+
* 那条河长300公里 is four runs, and the 长 ends the first of them, so a rule
|
|
32
|
+
* asking what the 长 is measured in used to see nothing at all: the numeral is
|
|
33
|
+
* one run away and the 公里 two. This hands the decode what the sentence would
|
|
34
|
+
* have said spelled out, which is the number in front, and the number behind
|
|
35
|
+
* with the Han that carries on from it.
|
|
36
|
+
*/
|
|
37
|
+
export function contextAround(runs, read, at) {
|
|
38
|
+
const said = numeralAfter(read[at + 1] ?? []);
|
|
39
|
+
const following = runs[at + 2];
|
|
40
|
+
return {
|
|
41
|
+
before: numeralBefore(read[at - 1] ?? []),
|
|
42
|
+
after: said === "" || following?.isHan !== true
|
|
43
|
+
? said
|
|
44
|
+
: said + toCharacters(following.text).slice(0, READS_AHEAD).join(""),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=run-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-context.js","sourceRoot":"","sources":["../../src/decode/run-context.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAIvD;;;;;;;;GAQG;AACH,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB;;;;;;GAMG;AACH,MAAM,UAAU,aAAa,CAAC,QAAmC;IAC/D,OAAO,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,QAAmC;IAC9D,OAAO,QAAQ,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;AAClC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,aAAa,CAC3B,IAAwB,EACxB,IAA4C,EAC5C,EAAU;IAEV,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC;IAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAC/B,OAAO;QACL,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;QACzC,KAAK,EACH,IAAI,KAAK,EAAE,IAAI,SAAS,EAAE,KAAK,KAAK,IAAI;YACtC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,GAAG,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC;KACzE,CAAC;AACJ,CAAC"}
|
|
@@ -29,13 +29,14 @@ export declare function wordFrom(dictionary: Dictionary, lattice: Lattice, group
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function ruledLattice(dictionary: Dictionary, run: string, rules: readonly EdgeRule[], hints: ResolvedHints | undefined): Lattice;
|
|
31
31
|
/**
|
|
32
|
-
* Cut a decode of the whole lattice down to the run
|
|
32
|
+
* Cut a decode of the whole lattice down to the run inside it.
|
|
33
33
|
*
|
|
34
|
-
* Everything
|
|
35
|
-
*
|
|
36
|
-
* work.
|
|
34
|
+
* Everything outside `at` and `to` was context rather than run — 汉字 a caller
|
|
35
|
+
* put either side so that the decode could see them — and is dropped once it
|
|
36
|
+
* has done its work. A unit is kept only where it lies wholly inside the run,
|
|
37
|
+
* which is what `isJoinedAt` guarantees for the ones that cannot be cut.
|
|
37
38
|
*/
|
|
38
|
-
export declare function runGroups<Unit extends ReadingUnit>({ lattice, at }: RunLattice, units: readonly Unit[]): readonly (readonly Unit[])[];
|
|
39
|
+
export declare function runGroups<Unit extends ReadingUnit>({ lattice, at, to }: RunLattice, units: readonly Unit[]): readonly (readonly Unit[])[];
|
|
39
40
|
/**
|
|
40
41
|
* Decode a Han run with the lattice: the recommended path.
|
|
41
42
|
*
|
|
@@ -43,10 +44,12 @@ export declare function runGroups<Unit extends ReadingUnit>({ lattice, at }: Run
|
|
|
43
44
|
* lock the positions that cannot vary, score the rest — where the greedy
|
|
44
45
|
* baseline commits to the longest match at each position and never revisits it.
|
|
45
46
|
*
|
|
46
|
-
* `before`
|
|
47
|
-
* not report: the 汉字 a number written in digits would have been
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
47
|
+
* `before` and `after` are 汉字 standing either side of the run that the decode
|
|
48
|
+
* should see and not report: the 汉字 a number written in digits would have been
|
|
49
|
+
* written with, and whatever carries on from it. A run is decoded on its own
|
|
50
|
+
* without them, and a run reached that way has no idea what surrounded it —
|
|
51
|
+
* 个人 alone is the word `gèrén`, while the 两 of 2个人 makes 两个 the word and
|
|
52
|
+
* leaves 人 to itself, and 那条河长 ends where 那条河长三百公里 goes on to say
|
|
53
|
+
* how long the river is.
|
|
51
54
|
*/
|
|
52
55
|
//# sourceMappingURL=run-lattice.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-lattice.d.ts","sourceRoot":"","sources":["../../src/decode/run-lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YA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AK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAkB,KAAK,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAE7C;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,IAAI,SAAS,WAAW,EACjD,KAAK,EAAE,SAAS,IAAI,EAAE,EACtB,UAAU,EAAE,SAAS,MAAM,EAAE,GAC5B,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAkB9B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,SAAS,WAAW,EAAE,GAC5B,WAAW,CAiBb;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,UAAU,EACtB,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,KAAK,EAAE,aAAa,GAAG,SAAS,GAC/B,OAAO,CAMT;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,IAAI,SAAS,WAAW,EAChD,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,UAAU,EAC/B,KAAK,EAAE,SAAS,IAAI,EAAE,GACrB,SAAS,CAAC,SAAS,IAAI,EAAE,CAAC,EAAE,CAK9B;AAED;;;;;;;;;;;;;;GAcG"}
|
|
@@ -7,7 +7,7 @@ export { runLattice } from "./lattice-slice.js";
|
|
|
7
7
|
* is where a lattice is cut down to a run and the words are read back out of
|
|
8
8
|
* it. `decode.ts` is what asks for one.
|
|
9
9
|
*/
|
|
10
|
-
import { decodeSpacing } from "./decode.js";
|
|
10
|
+
import { decodeSpacing } from "./lattice-decode.js";
|
|
11
11
|
import { applyEdgeRules } from "./rules.js";
|
|
12
12
|
/**
|
|
13
13
|
* Gather the reading units into the words the boundaries make of them.
|
|
@@ -66,14 +66,15 @@ export function ruledLattice(dictionary, run, rules, hints) {
|
|
|
66
66
|
return applyEdgeRules(buildLattice(dictionary, run, hints), dictionary, rules);
|
|
67
67
|
}
|
|
68
68
|
/**
|
|
69
|
-
* Cut a decode of the whole lattice down to the run
|
|
69
|
+
* Cut a decode of the whole lattice down to the run inside it.
|
|
70
70
|
*
|
|
71
|
-
* Everything
|
|
72
|
-
*
|
|
73
|
-
* work.
|
|
71
|
+
* Everything outside `at` and `to` was context rather than run — 汉字 a caller
|
|
72
|
+
* put either side so that the decode could see them — and is dropped once it
|
|
73
|
+
* has done its work. A unit is kept only where it lies wholly inside the run,
|
|
74
|
+
* which is what `isJoinedAt` guarantees for the ones that cannot be cut.
|
|
74
75
|
*/
|
|
75
|
-
export function runGroups({ lattice, at }, units) {
|
|
76
|
-
return groupUnits(units.filter((unit) => unit.from >= at), decodeSpacing(lattice).filter((from) => from >= at));
|
|
76
|
+
export function runGroups({ lattice, at, to }, units) {
|
|
77
|
+
return groupUnits(units.filter((unit) => unit.from >= at && unit.to <= to), decodeSpacing(lattice).filter((from) => from >= at && from < to));
|
|
77
78
|
}
|
|
78
79
|
/**
|
|
79
80
|
* Decode a Han run with the lattice: the recommended path.
|
|
@@ -82,10 +83,12 @@ export function runGroups({ lattice, at }, units) {
|
|
|
82
83
|
* lock the positions that cannot vary, score the rest — where the greedy
|
|
83
84
|
* baseline commits to the longest match at each position and never revisits it.
|
|
84
85
|
*
|
|
85
|
-
* `before`
|
|
86
|
-
* not report: the 汉字 a number written in digits would have been
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
86
|
+
* `before` and `after` are 汉字 standing either side of the run that the decode
|
|
87
|
+
* should see and not report: the 汉字 a number written in digits would have been
|
|
88
|
+
* written with, and whatever carries on from it. A run is decoded on its own
|
|
89
|
+
* without them, and a run reached that way has no idea what surrounded it —
|
|
90
|
+
* 个人 alone is the word `gèrén`, while the 两 of 2个人 makes 两个 the word and
|
|
91
|
+
* leaves 人 to itself, and 那条河长 ends where 那条河长三百公里 goes on to say
|
|
92
|
+
* how long the river is.
|
|
90
93
|
*/
|
|
91
94
|
//# sourceMappingURL=run-lattice.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-lattice.js","sourceRoot":"","sources":["../../src/decode/run-lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,cAAc,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"run-lattice.js","sourceRoot":"","sources":["../../src/decode/run-lattice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAgB,MAAM,cAAc,CAAC;AAI1D,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD;;;;;;GAMG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,cAAc,EAAiB,MAAM,YAAY,CAAC;AAG3D;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CACxB,KAAsB,EACtB,UAA6B;IAE7B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,MAAM,IAAI,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAChE,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAW,EAAE,CAAC;IAEtB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,CAA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AW,EACX,KAA0B,EAC1B,KAAgC;IAEhC,OAAO,cAAc,CACnB,YAAY,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,EACpC,UAAU,EACV,KAAK,CACN,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,EAAc,EAC/B,KAAsB;IAEtB,OAAO,UAAU,CACf,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,IAAI,EAAE,CAAC,EACxD,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE,CAAC,CACjE,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing a converted word in a region's own 繁體 orthography.
|
|
3
|
+
*
|
|
4
|
+
* The last pass over a word's choices. Taiwan and Hong Kong disagree about the
|
|
5
|
+
* standard form of 58 characters and about nothing else, so this rewrites forms
|
|
6
|
+
* and never a reading.
|
|
7
|
+
*/
|
|
8
|
+
import { type Region } from "../script/glyphs.js";
|
|
9
|
+
import type { Syllable } from "../syllable/syllable.js";
|
|
10
|
+
import type { ScriptChoice } from "./script-types.js";
|
|
11
|
+
/**
|
|
12
|
+
* Apply the regional 繁體 forms, which never change a reading.
|
|
13
|
+
*/
|
|
14
|
+
export declare function applyRegion(choices: readonly ScriptChoice[], reading: readonly Syllable[], region: Region, isAligned: boolean): readonly ScriptChoice[];
|
|
15
|
+
//# sourceMappingURL=script-region.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-region.d.ts","sourceRoot":"","sources":["../../src/decode/script-region.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAGL,KAAK,MAAM,EAGZ,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,mBAAmB,CAAC;AAEtE;;GAEG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,SAAS,YAAY,EAAE,EAChC,OAAO,EAAE,SAAS,QAAQ,EAAE,EAC5B,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,OAAO,GACjB,SAAS,YAAY,EAAE,CAsBzB"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writing a converted word in a region's own 繁體 orthography.
|
|
3
|
+
*
|
|
4
|
+
* The last pass over a word's choices. Taiwan and Hong Kong disagree about the
|
|
5
|
+
* standard form of 58 characters and about nothing else, so this rewrites forms
|
|
6
|
+
* and never a reading.
|
|
7
|
+
*/
|
|
8
|
+
import { DEFAULT_REGION, isReadingSensitive, regionalGlyphsOf, toRegionalGlyph, } from "../script/glyphs.js";
|
|
9
|
+
/**
|
|
10
|
+
* Apply the regional 繁體 forms, which never change a reading.
|
|
11
|
+
*/
|
|
12
|
+
export function applyRegion(choices, reading, region, isAligned) {
|
|
13
|
+
if (region === DEFAULT_REGION) {
|
|
14
|
+
return choices;
|
|
15
|
+
}
|
|
16
|
+
return choices.map((choice, at) => {
|
|
17
|
+
const syllable = isAligned ? reading[at] : undefined;
|
|
18
|
+
// A regional form that needs the reading and has none is a guess, whatever
|
|
19
|
+
// settled the script conversion before it: 著 is 着 or 著 in Hong Kong.
|
|
20
|
+
const isGuess = isReadingSensitive(choice.to) && syllable === undefined;
|
|
21
|
+
const to = toRegionalGlyph(choice.to, region, syllable);
|
|
22
|
+
const alternatives = regionalAlternatives(choice, region, to, isGuess);
|
|
23
|
+
return {
|
|
24
|
+
...choice,
|
|
25
|
+
to,
|
|
26
|
+
// A region can leave a character one form where the script left it two:
|
|
27
|
+
// Hong Kong writes 台 for both 台 and 臺, and 泄 for both 泄 and 洩. There
|
|
28
|
+
// was nothing to decide once the region is applied, whatever the script
|
|
29
|
+
// conversion thought it was deciding.
|
|
30
|
+
evidence: evidenceAfter(choice, alternatives, isGuess),
|
|
31
|
+
alternatives,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* What settled a choice once the region has had its say.
|
|
37
|
+
*/
|
|
38
|
+
function evidenceAfter(choice, alternatives, isGuess) {
|
|
39
|
+
if (alternatives.length === 0) {
|
|
40
|
+
return "locked";
|
|
41
|
+
}
|
|
42
|
+
return isGuess ? "default" : choice.evidence;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* The forms a choice was written against, in the region's own orthography.
|
|
46
|
+
*
|
|
47
|
+
* Two things happen here. The rivals the script tables named are rewritten,
|
|
48
|
+
* since a choice reporting 面 settled for Hong Kong beside a Taiwan 麵 would be
|
|
49
|
+
* writing two orthographies at once — 3,163 of the 39,430 alternatives over
|
|
50
|
+
* 88,866 lines were doing that, mostly 裡 for 裏 and 麵 for 麪. And a guess the
|
|
51
|
+
* region itself created gains the form the reading would have kept, which is
|
|
52
|
+
* the only thing 著 and 參 were ever choosing between.
|
|
53
|
+
*/
|
|
54
|
+
function regionalAlternatives(choice, region, to, isGuess) {
|
|
55
|
+
const forms = [
|
|
56
|
+
...choice.alternatives.map((form) => toRegionalGlyph(form, region)),
|
|
57
|
+
...(isGuess ? regionalGlyphsOf(choice.to, region) : []),
|
|
58
|
+
];
|
|
59
|
+
return [...new Set(forms)].filter((form) => form !== to);
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=script-region.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"script-region.js","sourceRoot":"","sources":["../../src/decode/script-region.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EACL,cAAc,EACd,kBAAkB,EAElB,gBAAgB,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AAc,EACd,EAAU,EACV,OAAgB;IAEhB,MAAM,KAAK,GAAG;QACZ,GAAG,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnE,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;KACxD,CAAC;IACF,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -35,7 +35,8 @@ export interface ScriptOptions {
|
|
|
35
35
|
*
|
|
36
36
|
* - `locked` — the character has one form and there was nothing to decide.
|
|
37
37
|
* True of the great majority: simplification changed a minority of
|
|
38
|
-
* characters, and most of those are one-to-one.
|
|
38
|
+
* characters, and most of those are one-to-one. The one evidence that comes
|
|
39
|
+
* with no {@link ScriptChoice.alternatives}, and the only one.
|
|
39
40
|
* - `word` — a word some source wrote in both scripts settled it. The strongest
|
|
40
41
|
* real evidence, because it was written rather than inferred.
|
|
41
42
|
* - `reading` — the character had rival forms and the syllable it was decoded
|
|
@@ -63,7 +64,15 @@ export interface ScriptChoice {
|
|
|
63
64
|
/** The character as it was converted. */
|
|
64
65
|
readonly to: string;
|
|
65
66
|
readonly evidence: ScriptEvidence;
|
|
66
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* The forms this character could also have taken.
|
|
69
|
+
*
|
|
70
|
+
* Empty exactly when the evidence is `locked`, so a caller reading one of
|
|
71
|
+
* them never has to check the other. The character's own form counts: 万 is
|
|
72
|
+
* 萬 counting and 万 in the surname 万俟, and a conversion that took 萬 was
|
|
73
|
+
* choosing between the two. So does the region's: Hong Kong writes 麪 where
|
|
74
|
+
* Taiwan writes 麵, and a Hong Kong conversion says 麪.
|
|
75
|
+
*/
|
|
67
76
|
readonly alternatives: readonly string[];
|
|
68
77
|
}
|
|
69
78
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-types.d.ts","sourceRoot":"","sources":["../../src/decode/script-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YACzB,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,CACJ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED
|
|
1
|
+
{"version":3,"file":"script-types.d.ts","sourceRoot":"","sources":["../../src/decode/script-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,YACzB,SAAS,EACT,SAAS,EACT,YAAY,EACZ,YAAY,CACJ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3D;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,QAAQ,CAAC,EAAE,CAAC,EAAE,YAAY,CAAC;IAC3B;;;;;;OAMG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,YAC1B,QAAQ,EACR,MAAM,EACN,SAAS,EACT,SAAS,CACD,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D;;;;;;;GAOG;AACH,MAAM,WAAW,YAAY;IAC3B,uCAAuC;IACvC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,yCAAyC;IACzC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC;IAClC;;;;;;;;OAQG;IACH,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C"}
|
|
@@ -17,7 +17,8 @@ export const SCRIPT_TARGETS = [
|
|
|
17
17
|
*
|
|
18
18
|
* - `locked` — the character has one form and there was nothing to decide.
|
|
19
19
|
* True of the great majority: simplification changed a minority of
|
|
20
|
-
* characters, and most of those are one-to-one.
|
|
20
|
+
* characters, and most of those are one-to-one. The one evidence that comes
|
|
21
|
+
* with no {@link ScriptChoice.alternatives}, and the only one.
|
|
21
22
|
* - `word` — a word some source wrote in both scripts settled it. The strongest
|
|
22
23
|
* real evidence, because it was written rather than inferred.
|
|
23
24
|
* - `reading` — the character had rival forms and the syllable it was decoded
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-types.js","sourceRoot":"","sources":["../../src/decode/script-types.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,SAAS;IACT,YAAY;IACZ,YAAY;CACJ,CAAC;AAuBX
|
|
1
|
+
{"version":3,"file":"script-types.js","sourceRoot":"","sources":["../../src/decode/script-types.ts"],"names":[],"mappings":"AAKA;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,SAAS;IACT,SAAS;IACT,YAAY;IACZ,YAAY;CACJ,CAAC;AAuBX;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,QAAQ;IACR,MAAM;IACN,SAAS;IACT,SAAS;CACD,CAAC"}
|
|
@@ -23,10 +23,12 @@ export declare function targetOf(target: ScriptTarget): {
|
|
|
23
23
|
export declare function convertWord(table: ReadonlyMap<string, CharacterConversion>, words: ReadonlyMap<string, string>, word: string, reading: readonly Syllable[]): readonly ScriptChoice[];
|
|
24
24
|
/**
|
|
25
25
|
* Rank what settled a character, strongest evidence first.
|
|
26
|
+
*
|
|
27
|
+
* `locked` is keyed on whether a rival form survived rather than on
|
|
28
|
+
* {@link import("../script/conversion.js").isAmbiguousCharacter}, and the two part company where a word overrides
|
|
29
|
+
* the character table. 钟 has one 繁體 form by the characters and 一见钟情 is
|
|
30
|
+
* 一見鍾情, so the choice named 鐘 as the road not taken while calling itself
|
|
31
|
+
* locked. A word settled that one, which is what `word` is for.
|
|
26
32
|
*/
|
|
27
|
-
export declare function evidenceFor(isAttested: boolean, isAtReading: boolean,
|
|
28
|
-
/**
|
|
29
|
-
* Apply the regional 繁體 forms, which never change a reading.
|
|
30
|
-
*/
|
|
31
|
-
export declare function applyRegion(choices: readonly ScriptChoice[], reading: readonly Syllable[], region: Region, isAligned: boolean): readonly ScriptChoice[];
|
|
33
|
+
export declare function evidenceFor(isAttested: boolean, isAtReading: boolean, hasRival: boolean): ScriptEvidence;
|
|
32
34
|
//# sourceMappingURL=script-words.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-words.d.ts","sourceRoot":"","sources":["../../src/decode/script-words.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"script-words.d.ts","sourceRoot":"","sources":["../../src/decode/script-words.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,cAAc,EACd,YAAY,EACb,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,KAAK,mBAAmB,EAIzB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAkB,KAAK,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,YAAY,GAAG;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB,CAQA;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,mBAAmB,CAAC,EAC/C,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAClC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,QAAQ,EAAE,GAC3B,SAAS,YAAY,EAAE,CAuCzB;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CACzB,UAAU,EAAE,OAAO,EACnB,WAAW,EAAE,OAAO,EACpB,QAAQ,EAAE,OAAO,GAChB,cAAc,CAQhB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { toCharacters } from "../script/characters.js";
|
|
2
|
-
import { conversionKey, convertCharacter, formsOf,
|
|
3
|
-
import { DEFAULT_REGION
|
|
2
|
+
import { conversionKey, convertCharacter, formsOf, } from "../script/conversion.js";
|
|
3
|
+
import { DEFAULT_REGION } from "../script/glyphs.js";
|
|
4
4
|
/**
|
|
5
5
|
* The script and region a target names.
|
|
6
6
|
*/
|
|
@@ -35,19 +35,31 @@ export function convertWord(table, words, word, reading) {
|
|
|
35
35
|
? /* c8 ignore next -- the lengths were just checked */
|
|
36
36
|
(attestedCharacters[at] ?? character)
|
|
37
37
|
: convertCharacter(table, character, syllable);
|
|
38
|
+
// Every form the table names but the one taken. The character's own form
|
|
39
|
+
// belongs among them: 万 is 萬 counting and 万 in the surname 万俟, 准 is
|
|
40
|
+
// 準 and 准 in 准將, 著 is 着 and 著 at `zhù`. Excluding it left 42 简→繁
|
|
41
|
+
// characters and 3,160 繁→简 ones reporting a guess with nothing to have
|
|
42
|
+
// guessed between.
|
|
43
|
+
const alternatives = formsOf(conversion).filter((form) => form !== to);
|
|
38
44
|
return {
|
|
39
45
|
from: character,
|
|
40
46
|
to,
|
|
41
|
-
evidence: evidenceFor(isAttested, atReading !== undefined,
|
|
42
|
-
alternatives
|
|
47
|
+
evidence: evidenceFor(isAttested, atReading !== undefined, alternatives.length > 0),
|
|
48
|
+
alternatives,
|
|
43
49
|
};
|
|
44
50
|
});
|
|
45
51
|
}
|
|
46
52
|
/**
|
|
47
53
|
* Rank what settled a character, strongest evidence first.
|
|
54
|
+
*
|
|
55
|
+
* `locked` is keyed on whether a rival form survived rather than on
|
|
56
|
+
* {@link import("../script/conversion.js").isAmbiguousCharacter}, and the two part company where a word overrides
|
|
57
|
+
* the character table. 钟 has one 繁體 form by the characters and 一见钟情 is
|
|
58
|
+
* 一見鍾情, so the choice named 鐘 as the road not taken while calling itself
|
|
59
|
+
* locked. A word settled that one, which is what `word` is for.
|
|
48
60
|
*/
|
|
49
|
-
export function evidenceFor(isAttested, isAtReading,
|
|
50
|
-
if (!
|
|
61
|
+
export function evidenceFor(isAttested, isAtReading, hasRival) {
|
|
62
|
+
if (!hasRival) {
|
|
51
63
|
return "locked";
|
|
52
64
|
}
|
|
53
65
|
if (isAttested) {
|
|
@@ -55,23 +67,4 @@ export function evidenceFor(isAttested, isAtReading, isAmbiguous) {
|
|
|
55
67
|
}
|
|
56
68
|
return isAtReading ? "reading" : "default";
|
|
57
69
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Apply the regional 繁體 forms, which never change a reading.
|
|
60
|
-
*/
|
|
61
|
-
export function applyRegion(choices, reading, region, isAligned) {
|
|
62
|
-
if (region === DEFAULT_REGION) {
|
|
63
|
-
return choices;
|
|
64
|
-
}
|
|
65
|
-
return choices.map((choice, at) => {
|
|
66
|
-
const syllable = isAligned ? reading[at] : undefined;
|
|
67
|
-
// A regional form that needs the reading and has none is a guess, whatever
|
|
68
|
-
// settled the script conversion before it: 著 is 着 or 著 in Hong Kong.
|
|
69
|
-
const isGuess = isReadingSensitive(choice.to) && syllable === undefined;
|
|
70
|
-
return {
|
|
71
|
-
...choice,
|
|
72
|
-
to: toRegionalGlyph(choice.to, region, syllable),
|
|
73
|
-
evidence: isGuess ? "default" : choice.evidence,
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
70
|
//# sourceMappingURL=script-words.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script-words.js","sourceRoot":"","sources":["../../src/decode/script-words.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAEL,aAAa,EACb,gBAAgB,EAChB,OAAO,
|
|
1
|
+
{"version":3,"file":"script-words.js","sourceRoot":"","sources":["../../src/decode/script-words.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAEL,aAAa,EACb,gBAAgB,EAChB,OAAO,GACR,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAe,MAAM,qBAAqB,CAAC;AAIlE;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAoB;IAI3C,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC;IACpD,CAAC;IACD,OAAO;QACL,MA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AoE;QACpE,iEAAiE;QACjE,uEAAuE;QACvE,mBAAmB;QACnB,MAAM,YAAY,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;QACvE,OAAO;YACL,IAAI,EAAE,SAAS;YACf,EAAE;YACF,QAAQ,EAAE,WAAW,CACnB,UAAU,EACV,SAAS,KAAK,SAAS,EACvB,YAAY,CAAC,MAAM,GAAG,CAAC,CACxB;YACD,YAAY;SACb,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CACzB,UAAmB,EACnB,WAAoB,EACpB,QAAiB;IAEjB,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,OAAO,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC;AAC7C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../src/decode/script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"script.d.ts","sourceRoot":"","sources":["../../src/decode/script.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAS5D,OAAO,KAAK,EACV,YAAY,EACZ,gBAAgB,EAChB,aAAa,EACd,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,eAAe,EACf,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,cAAc,EACd,KAAK,YAAY,GAClB,MAAM,mBAAmB,CAAC;AAC3B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,aAAkB,GAC1B,gBAAgB,CA0ClB;AAeD;;GAEG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,YAAY,EACpB,IAAI,EAAE,MAAM,EACZ,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAE/D"}
|
package/dist/decode/script.js
CHANGED
|
@@ -4,7 +4,8 @@ import { detectScript } from "../script/script.js";
|
|
|
4
4
|
import { decodeRun } from "./decode.js";
|
|
5
5
|
import { READING_RULES } from "./reading-rules.js";
|
|
6
6
|
import { splitRuns } from "./runs.js";
|
|
7
|
-
import { applyRegion
|
|
7
|
+
import { applyRegion } from "./script-region.js";
|
|
8
|
+
import { convertWord, targetOf } from "./script-words.js";
|
|
8
9
|
export { SCRIPT_EVIDENCE, SCRIPT_TARGETS, } from "./script-types.js";
|
|
9
10
|
/**
|
|
10
11
|
* Convert a text between the scripts, reporting what it was unsure about.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"script.js","sourceRoot":"","sources":["../../src/decode/script.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAA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ACtC,CAAC;AAED;;;GAGG;AACH,SAAS,QAAQ,CAAC,IAAY;IAC5B,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QAC5C,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,SAAS;QACb,QAAQ,EAAE,QAAiB;QAC3B,YAAY,EAAE,EAAE;KACjB,CAAC,CAAC,CAAC;AACN,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CACtB,UAAsB,EACtB,MAAoB,EACpB,IAAY,EACZ,OAAO,GAAkB,EAAE;IAE3B,OAAO,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC,IAAI,CAAC;AAChE,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAoB;IACpD,OAAO,MAAM,CAAC,QAAQ,KAAK,SAAS,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type Tone } from "../tone/tone.js";
|
|
2
|
+
import type { DictionaryEntry } from "./entry.js";
|
|
3
|
+
/**
|
|
4
|
+
* The determiners that take 个 into a word of their own, where it is 轻声.
|
|
5
|
+
*
|
|
6
|
+
* Six characters and not a part of speech, because the tag cannot draw the
|
|
7
|
+
* line. jieba tags 这个, 那个 and 每个 `r` and tags 各个, 某个 and 整个 `r` as
|
|
8
|
+
* well, and those three are `gègè`, `mǒugè` and `zhěnggè` in both sources with
|
|
9
|
+
* nothing disagreeing. So this is a list of judgements, in the way
|
|
10
|
+
* {@link import("./neutral-senses.js").NEUTRAL_SENSE_WORDS} is, and the words
|
|
11
|
+
* it decides are the ones where a source writes the 轻声 on the determiner and
|
|
12
|
+
* the pair together.
|
|
13
|
+
*/
|
|
14
|
+
export declare const NEUTRAL_MEASURE_DETERMINERS: ReadonlySet<string>;
|
|
15
|
+
/**
|
|
16
|
+
* The tone the 个 at a position takes, or undefined where nothing settles it.
|
|
17
|
+
*/
|
|
18
|
+
export declare function countingToneAt(characters: readonly string[], at: number): Tone | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* What the settling pass changed.
|
|
21
|
+
*/
|
|
22
|
+
export interface MeasureToneSettlement {
|
|
23
|
+
readonly entries: readonly DictionaryEntry[];
|
|
24
|
+
/** Entries whose 个 was retoned. */
|
|
25
|
+
readonly settled: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Give every 个 the tone its position calls for.
|
|
29
|
+
*
|
|
30
|
+
* Runs over the finished entries, before the constituent repair, so that a
|
|
31
|
+
* phrase held to the words inside it is held to a settled reading. Only the
|
|
32
|
+
* 普通话 reading is touched. A zh-TW delta is a claim about how 國語 differs
|
|
33
|
+
* from what stands beside it, and none of the 279 entries holding a 个 has one.
|
|
34
|
+
*/
|
|
35
|
+
export declare function settleMeasureTones(entries: readonly DictionaryEntry[]): MeasureToneSettlement;
|
|
36
|
+
//# sourceMappingURL=measure-tone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"measure-tone.d.ts","sourceRoot":"","sources":["../../src/dictionary/measure-tone.ts"],"names":[],"mappings":"AA6CA,OAAO,EAAgB,KAAK,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAYlD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,2BAA2B,EAAE,WAAW,CAAC,MAAM,CAQ1D,CAAC;AAgBH;;GAEG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,SAAS,MAAM,EAAE,EAC7B,EAAE,EAAE,MAAM,GACT,IAAI,GAAG,SAAS,CAQlB;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,SAAS,eAAe,EAAE,CAAC;IAC7C,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,eAAe,EAAE,GAClC,qBAAqB,CAsCvB"}
|