@kensio/pinyinjs 1.7.5 → 1.7.6
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 +128 -123
- package/data/full.entries +2595 -2595
- package/data/manifest.json +5 -5
- package/data/script.map +66 -3
- package/dist/decode/chang-context.d.ts +27 -0
- package/dist/decode/chang-context.d.ts.map +1 -0
- package/dist/decode/chang-context.js +66 -0
- package/dist/decode/chang-context.js.map +1 -0
- package/dist/decode/chang-rule.d.ts +37 -0
- package/dist/decode/chang-rule.d.ts.map +1 -0
- package/dist/decode/chang-rule.js +169 -0
- package/dist/decode/chang-rule.js.map +1 -0
- package/dist/decode/confidence.d.ts +11 -3
- package/dist/decode/confidence.d.ts.map +1 -1
- package/dist/decode/confidence.js +11 -3
- package/dist/decode/confidence.js.map +1 -1
- package/dist/decode/convert-pipeline.d.ts.map +1 -1
- package/dist/decode/convert-pipeline.js +2 -1
- package/dist/decode/convert-pipeline.js.map +1 -1
- package/dist/decode/de-rule.d.ts +54 -0
- package/dist/decode/de-rule.d.ts.map +1 -0
- package/dist/decode/de-rule.js +113 -0
- package/dist/decode/de-rule.js.map +1 -0
- package/dist/decode/hint-lattice.d.ts.map +1 -1
- package/dist/decode/hint-lattice.js +17 -3
- package/dist/decode/hint-lattice.js.map +1 -1
- package/dist/decode/jiao-rule.d.ts +9 -3
- package/dist/decode/jiao-rule.d.ts.map +1 -1
- package/dist/decode/jiao-rule.js +44 -5
- package/dist/decode/jiao-rule.js.map +1 -1
- package/dist/decode/lattice-types.d.ts +27 -8
- package/dist/decode/lattice-types.d.ts.map +1 -1
- package/dist/decode/lattice-types.js +27 -8
- package/dist/decode/lattice-types.js.map +1 -1
- package/dist/decode/polyphone-rules.d.ts +7 -27
- package/dist/decode/polyphone-rules.d.ts.map +1 -1
- package/dist/decode/polyphone-rules.js +7 -155
- package/dist/decode/polyphone-rules.js.map +1 -1
- package/dist/decode/reading-rules.d.ts +1 -29
- package/dist/decode/reading-rules.d.ts.map +1 -1
- package/dist/decode/reading-rules.js +4 -69
- package/dist/decode/reading-rules.js.map +1 -1
- package/dist/decode/run-words.d.ts +17 -0
- package/dist/decode/run-words.d.ts.map +1 -0
- package/dist/decode/run-words.js +29 -0
- package/dist/decode/run-words.js.map +1 -0
- package/dist/decode/sandhi-input.d.ts +30 -0
- package/dist/decode/sandhi-input.d.ts.map +1 -0
- package/dist/decode/sandhi-input.js +35 -0
- package/dist/decode/sandhi-input.js.map +1 -0
- package/dist/decode/sandhi-tones.d.ts +33 -5
- package/dist/decode/sandhi-tones.d.ts.map +1 -1
- package/dist/decode/sandhi-tones.js +59 -8
- package/dist/decode/sandhi-tones.js.map +1 -1
- package/dist/decode/sandhi.d.ts +9 -6
- package/dist/decode/sandhi.d.ts.map +1 -1
- package/dist/decode/sandhi.js +10 -7
- package/dist/decode/sandhi.js.map +1 -1
- package/dist/decode/write-run.d.ts +0 -7
- package/dist/decode/write-run.d.ts.map +1 -1
- package/dist/decode/write-run.js +4 -39
- package/dist/decode/write-run.js.map +1 -1
- package/dist/dictionary/cedict-senses.d.ts +7 -0
- package/dist/dictionary/cedict-senses.d.ts.map +1 -1
- package/dist/dictionary/cedict-senses.js +12 -0
- package/dist/dictionary/cedict-senses.js.map +1 -1
- package/dist/dictionary/constituent-repair.d.ts +36 -0
- package/dist/dictionary/constituent-repair.d.ts.map +1 -0
- package/dist/dictionary/constituent-repair.js +117 -0
- package/dist/dictionary/constituent-repair.js.map +1 -0
- package/dist/dictionary/merge-types.d.ts +8 -2
- package/dist/dictionary/merge-types.d.ts.map +1 -1
- package/dist/dictionary/merge-types.js.map +1 -1
- package/dist/dictionary/merge-walk.d.ts +27 -0
- package/dist/dictionary/merge-walk.d.ts.map +1 -0
- package/dist/dictionary/merge-walk.js +49 -0
- package/dist/dictionary/merge-walk.js.map +1 -0
- package/dist/dictionary/merge.d.ts +3 -3
- package/dist/dictionary/merge.d.ts.map +1 -1
- package/dist/dictionary/merge.js +18 -28
- package/dist/dictionary/merge.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/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chang-rule.js","sourceRoot":"","sources":["../../src/decode/chang-rule.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACjE,OAAO,EAAmC,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3E;;GAEG;AACH,SAAS,OAAO,CAAC,QAA8B;IAC7C,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,IAAI;QAC1B,QAAQ,CAAC,KAAK,KAAK,KAAK;QACxB,QAAQ,CAAC,IAAI,KAAK,CAAC,CACpB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC;IACrB,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,GAAG;IACH,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,IAAI;CACL,CAAC,CAAC;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,U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AAG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC;IACvE,CAAC;CACF,CAAC"}
|
|
@@ -52,9 +52,17 @@ export interface ScoredUnit extends ReadingUnit, ReadingConfidence {
|
|
|
52
52
|
* only be had by rejecting a word the dictionary attests.
|
|
53
53
|
*
|
|
54
54
|
* **Measured** against the CPP dataset's 20,139 hand-labelled polyphones: a
|
|
55
|
-
* reading this reports uncertain is wrong
|
|
56
|
-
* one backed by a word and 1.5% for a locked one. It lands on
|
|
57
|
-
* syllables of everyday text and
|
|
55
|
+
* reading this reports uncertain is wrong 19.9% of the time, against 4.4% for
|
|
56
|
+
* one backed by a word and 1.5% for a locked one. It lands on 17.6% of the
|
|
57
|
+
* syllables of everyday text and 12.6% of encyclopedic text — see ROADMAP.md.
|
|
58
|
+
*
|
|
59
|
+
* What it is not is a graded score, and the threshold is not the lever it
|
|
60
|
+
* looks like. A character's second reading costs one `ALTERNATE_PENALTY`
|
|
61
|
+
* more than its first whatever the real odds are, so nearly every uncertain
|
|
62
|
+
* reading is uncertain by exactly that margin: moving the threshold anywhere
|
|
63
|
+
* between 1.5 and 6 moves the share of everyday text flagged from 16.5% to
|
|
64
|
+
* 17.6%. The flag says a word did not cover the character. It does not say the
|
|
65
|
+
* decode was close.
|
|
58
66
|
*/
|
|
59
67
|
export declare function isUncertain(confidence: ReadingConfidence): boolean;
|
|
60
68
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confidence.d.ts","sourceRoot":"","sources":["../../src/decode/confidence.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAa,KAAK,OAAO,EAAkB,MAAM,cAAc,CAAC;AACvE,OAAO,E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,EAAE,SAAS,kBAAkB,EAAE,CAAC;CACtD;AAED;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,WAAW,EAAE,iBAAiB;CAAG;AAErE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAElE;AACD;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAC3B,OAAO,EAAE,OAAO,EAChB,UAAU,EAAE,iBAAiB,GAC5B,SAAS,UAAU,EAAE,CAuBvB"}
|
|
@@ -12,9 +12,17 @@ import { scoreStretch } from "./alternatives.js";
|
|
|
12
12
|
* only be had by rejecting a word the dictionary attests.
|
|
13
13
|
*
|
|
14
14
|
* **Measured** against the CPP dataset's 20,139 hand-labelled polyphones: a
|
|
15
|
-
* reading this reports uncertain is wrong
|
|
16
|
-
* one backed by a word and 1.5% for a locked one. It lands on
|
|
17
|
-
* syllables of everyday text and
|
|
15
|
+
* reading this reports uncertain is wrong 19.9% of the time, against 4.4% for
|
|
16
|
+
* one backed by a word and 1.5% for a locked one. It lands on 17.6% of the
|
|
17
|
+
* syllables of everyday text and 12.6% of encyclopedic text — see ROADMAP.md.
|
|
18
|
+
*
|
|
19
|
+
* What it is not is a graded score, and the threshold is not the lever it
|
|
20
|
+
* looks like. A character's second reading costs one `ALTERNATE_PENALTY`
|
|
21
|
+
* more than its first whatever the real odds are, so nearly every uncertain
|
|
22
|
+
* reading is uncertain by exactly that margin: moving the threshold anywhere
|
|
23
|
+
* between 1.5 and 6 moves the share of everyday text flagged from 16.5% to
|
|
24
|
+
* 17.6%. The flag says a word did not cover the character. It does not say the
|
|
25
|
+
* decode was close.
|
|
18
26
|
*/
|
|
19
27
|
export function isUncertain(confidence) {
|
|
20
28
|
return (confidence.alternatives[0]?.cost ?? Infinity) < READING_CHARGE;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confidence.js","sourceRoot":"","sources":["../../src/decode/confidence.ts"],"names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,GAAG,IAAI;gBACP,QAAQ,EAAE,IAAI;gBACd,YAAY,EAAE,EAAE;aACjB,CAAC,CAAC,CACJ,CAAC;YACF,SAAS;QACX,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-pipeline.d.ts","sourceRoot":"","sources":["../../src/decode/convert-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,aAAa,CAAC;AAE3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"convert-pipeline.d.ts","sourceRoot":"","sources":["../../src/decode/convert-pipeline.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAU9D,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAW,MAAM,aAAa,CAAC;AAE3E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAI5C;;GAEG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,cAAc,GACtB,SAAS,cAAc,EAAE,CAiF3B"}
|
|
@@ -5,7 +5,8 @@ import { toCharacters } from "../script/characters.js";
|
|
|
5
5
|
import { hintsWithin, resolveHints } from "./hints.js";
|
|
6
6
|
import { splitRuns, surroundingCharacters } from "./runs.js";
|
|
7
7
|
import { numeralBefore, surrounding, writeNumbers } from "./numbers.js";
|
|
8
|
-
import {
|
|
8
|
+
import { wordsOf } from "./run-words.js";
|
|
9
|
+
import { writeRun, rewrite } from "./write-run.js";
|
|
9
10
|
/**
|
|
10
11
|
* Run the pipeline over a text with a given decoder.
|
|
11
12
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert-pipeline.js","sourceRoot":"","sources":["../../src/decode/convert-pipeline.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"convert-pipeline.js","sourceRoot":"","sources":["../../src/decode/convert-pipeline.ts"],"names":[],"mappings":"AAWA,OAAO,EACL,uBAAuB,EACvB,UAAU,GACX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAE7D,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAExE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAA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E,OAAO,EAAE,EAAE,CAAC,EAC9B,OAAO,EACP,EAAE,MAAM,EAAE,CACX,CACF,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,GAA8B,SAAS,CAAC;IAElD,0EAA0E;IAC1E,6EAA6E;IAC7E,qEAAqE;IACrE,IAAI,QAAQ,KAAK,MAAM,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QAC5C,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,uBAAuB,CAAC,CAAC;IACpD,CAAC;IACD,OAAO,WAAW,KAAK,OAAO;QAC5B,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,uBAAuB,CAAC;QAC1C,CAAC,CAAC,MAAM,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type EdgeRule } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* 得 read as `děi` where it is a modal rather than a particle.
|
|
4
|
+
*
|
|
5
|
+
* One character, three readings, and the dictionary can only carry a default:
|
|
6
|
+
* 得 is stored `de` — the structural particle, which is far the commonest — with
|
|
7
|
+
* `dé` and `děi` as alternates. Nothing in the cost model can prefer an
|
|
8
|
+
* alternate at a position no word covers, so 我得走了 came out `wǒ de zǒule`
|
|
9
|
+
* and every other modal 得 with it. This is the case ROADMAP.md was waiting for
|
|
10
|
+
* before building stage 4: neither harness could see it, since the gold corpus
|
|
11
|
+
* had only 觉得 and CPP's 40 得 cases are labelled `dé` or `de` and never `děi`.
|
|
12
|
+
*
|
|
13
|
+
* The context is what separates the three, and only one side of it carries
|
|
14
|
+
* information. The particle 得 always follows the verb or adjective it attaches
|
|
15
|
+
* to (说得好, 跑得快, 累得要命), so a 得 with a *pronoun, adverb or time word*
|
|
16
|
+
* in front of it is not that particle. Requiring a verb phrase after it as well
|
|
17
|
+
* keeps 得了感冒 and 得了奖 — `dé`, and a real reading of the same character —
|
|
18
|
+
* out of it.
|
|
19
|
+
*
|
|
20
|
+
* Conditioning on what precedes rather than on what follows was measured, not
|
|
21
|
+
* assumed: "the word before is not a verb" fires 309 times over 88,866 lines of
|
|
22
|
+
* Tatoeba and zh.wikipedia and is wrong about four times in five, because
|
|
23
|
+
* jieba tags 下 as `f`, 学 as `n` and 飞 as nothing at all, and 雨下得很大 is a
|
|
24
|
+
* particle whatever the tag says. Naming the small closed set of things that
|
|
25
|
+
* can precede a modal is the same rule from the other side, and over the same
|
|
26
|
+
* text it fires 126 times and is right 122: the four misses are literary 得
|
|
27
|
+
* read `dé` after an adverb — 未必得喜悦, 暂得于己, 仅得约, 未得迁还家乡 —
|
|
28
|
+
* which nothing short of semantics separates from 必须得承认.
|
|
29
|
+
*/
|
|
30
|
+
export declare const MODAL_DE: EdgeRule;
|
|
31
|
+
/**
|
|
32
|
+
* A word beginning with 的 does not start where the particle 的 does.
|
|
33
|
+
*
|
|
34
|
+
* The structural particle attaches to the modifier in front of it and the head
|
|
35
|
+
* follows, so a dictionary key spanning that 的 and the head's first character
|
|
36
|
+
* is describing some other sentence: 没有人知道他的真名字 came out
|
|
37
|
+
* `tā dí zhēn míngzi` on the strength of 的真, 图书馆的卡 on 的卡, and 你說的對
|
|
38
|
+
* came out as one word, `deduì`.
|
|
39
|
+
*
|
|
40
|
+
* Only a key **no source has tagged** is forbidden, which is the same line
|
|
41
|
+
* {@link TEACHING_JIAO} draws for a word ending in 教. 的确, 的士 and 的哥 are
|
|
42
|
+
* words jieba counted and tagged, and every one of them can genuinely begin
|
|
43
|
+
* where this fires: 我的确知道, 我要一辆的士, 那个的哥. That leaves 我的哥哥们
|
|
44
|
+
* reading `wǒ dī gēgē men`, since 的哥 is a taxi driver and jieba has counted
|
|
45
|
+
* them. What this does reach is the untagged tail — a reading somebody asserted
|
|
46
|
+
* rather than a word anybody counted — where the 的 is the particle every time.
|
|
47
|
+
*
|
|
48
|
+
* Measured over the 88,866 lines of Tatoeba and zh.wikipedia it forbids edges
|
|
49
|
+
* in 40 runs: 的筆 13, 的這 11, 的真 6, 的對 4, 的卡 4 and 的歷 once. Every one
|
|
50
|
+
* is a correction, and half of them are corrections to the spacing as much as
|
|
51
|
+
* to the reading — 你說的對 was one word `deduì` and is now two.
|
|
52
|
+
*/
|
|
53
|
+
export declare const PARTICLE_DE: EdgeRule;
|
|
54
|
+
//# sourceMappingURL=de-rule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"de-rule.d.ts","sourceRoot":"","sources":["../../src/decode/de-rule.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAgCpB;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,QAAQ,EAAE,QActB,CAAC;AAWF;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,EAAE,QAczB,CAAC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { tagOf, wordEndingAt, wordStartingAt, } from "./rules.js";
|
|
2
|
+
/**
|
|
3
|
+
* Whether a syllable is `děi`, the modal reading of 得.
|
|
4
|
+
*
|
|
5
|
+
* Compared structurally rather than by spelling it out, since a syllable is
|
|
6
|
+
* stored as its parts and writing one back is the formatting stage's job.
|
|
7
|
+
*/
|
|
8
|
+
function isDei(syllable) {
|
|
9
|
+
return (syllable?.initial === "d" && syllable.final === "ei" && syllable.tone === 3);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* What stands in front of a modal 得: a subject, an adverb, or a time word.
|
|
13
|
+
*
|
|
14
|
+
* 我得走, 你就得去, 我今天得走. The particle 得 cannot follow any of these,
|
|
15
|
+
* because it attaches to the predicate it modifies — which is exactly what
|
|
16
|
+
* makes this the discriminating side of the context.
|
|
17
|
+
*/
|
|
18
|
+
const SUBJECT_TAGS = new Set(["r", "d", "t"]);
|
|
19
|
+
/**
|
|
20
|
+
* What follows a modal 得: the verb phrase it governs.
|
|
21
|
+
*
|
|
22
|
+
* Prepositions and adverbs are in because 我得在八月, 我得先走 and 我得快点 are
|
|
23
|
+
* all modal, and what follows the 得 in each is the front of a verb phrase
|
|
24
|
+
* rather than a verb.
|
|
25
|
+
*/
|
|
26
|
+
const GOVERNED_TAGS = /^(?:v|p|d|a)/u;
|
|
27
|
+
/**
|
|
28
|
+
* 得 read as `děi` where it is a modal rather than a particle.
|
|
29
|
+
*
|
|
30
|
+
* One character, three readings, and the dictionary can only carry a default:
|
|
31
|
+
* 得 is stored `de` — the structural particle, which is far the commonest — with
|
|
32
|
+
* `dé` and `děi` as alternates. Nothing in the cost model can prefer an
|
|
33
|
+
* alternate at a position no word covers, so 我得走了 came out `wǒ de zǒule`
|
|
34
|
+
* and every other modal 得 with it. This is the case ROADMAP.md was waiting for
|
|
35
|
+
* before building stage 4: neither harness could see it, since the gold corpus
|
|
36
|
+
* had only 觉得 and CPP's 40 得 cases are labelled `dé` or `de` and never `děi`.
|
|
37
|
+
*
|
|
38
|
+
* The context is what separates the three, and only one side of it carries
|
|
39
|
+
* information. The particle 得 always follows the verb or adjective it attaches
|
|
40
|
+
* to (说得好, 跑得快, 累得要命), so a 得 with a *pronoun, adverb or time word*
|
|
41
|
+
* in front of it is not that particle. Requiring a verb phrase after it as well
|
|
42
|
+
* keeps 得了感冒 and 得了奖 — `dé`, and a real reading of the same character —
|
|
43
|
+
* out of it.
|
|
44
|
+
*
|
|
45
|
+
* Conditioning on what precedes rather than on what follows was measured, not
|
|
46
|
+
* assumed: "the word before is not a verb" fires 309 times over 88,866 lines of
|
|
47
|
+
* Tatoeba and zh.wikipedia and is wrong about four times in five, because
|
|
48
|
+
* jieba tags 下 as `f`, 学 as `n` and 飞 as nothing at all, and 雨下得很大 is a
|
|
49
|
+
* particle whatever the tag says. Naming the small closed set of things that
|
|
50
|
+
* can precede a modal is the same rule from the other side, and over the same
|
|
51
|
+
* text it fires 126 times and is right 122: the four misses are literary 得
|
|
52
|
+
* read `dé` after an adverb — 未必得喜悦, 暂得于己, 仅得约, 未得迁还家乡 —
|
|
53
|
+
* which nothing short of semantics separates from 必须得承认.
|
|
54
|
+
*/
|
|
55
|
+
export const MODAL_DE = {
|
|
56
|
+
name: "modal-de",
|
|
57
|
+
verdictFor: (context) => {
|
|
58
|
+
const { edge } = context;
|
|
59
|
+
if (edge.text !== "得" || !isDei(edge.reading[0])) {
|
|
60
|
+
return "keep";
|
|
61
|
+
}
|
|
62
|
+
const before = wordEndingAt(context, edge.from);
|
|
63
|
+
const after = wordStartingAt(context, edge.to);
|
|
64
|
+
return SUBJECT_TAGS.has(tagOf(context, before)) &&
|
|
65
|
+
GOVERNED_TAGS.test(tagOf(context, after))
|
|
66
|
+
? "force"
|
|
67
|
+
: "keep";
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* The tags a word carries when the 的 after it is the structural particle.
|
|
72
|
+
*
|
|
73
|
+
* A pronoun, a noun, an adjective, a verb or a distinguishing word: 他的,
|
|
74
|
+
* 图书馆的, 伟大的, 见过面的, 男的. What the particle marks is a modifier, and
|
|
75
|
+
* these are what a modifier is.
|
|
76
|
+
*/
|
|
77
|
+
const MODIFIED_TAGS = /^(?:r|n|a|v|b|z)/u;
|
|
78
|
+
/**
|
|
79
|
+
* A word beginning with 的 does not start where the particle 的 does.
|
|
80
|
+
*
|
|
81
|
+
* The structural particle attaches to the modifier in front of it and the head
|
|
82
|
+
* follows, so a dictionary key spanning that 的 and the head's first character
|
|
83
|
+
* is describing some other sentence: 没有人知道他的真名字 came out
|
|
84
|
+
* `tā dí zhēn míngzi` on the strength of 的真, 图书馆的卡 on 的卡, and 你說的對
|
|
85
|
+
* came out as one word, `deduì`.
|
|
86
|
+
*
|
|
87
|
+
* Only a key **no source has tagged** is forbidden, which is the same line
|
|
88
|
+
* {@link TEACHING_JIAO} draws for a word ending in 教. 的确, 的士 and 的哥 are
|
|
89
|
+
* words jieba counted and tagged, and every one of them can genuinely begin
|
|
90
|
+
* where this fires: 我的确知道, 我要一辆的士, 那个的哥. That leaves 我的哥哥们
|
|
91
|
+
* reading `wǒ dī gēgē men`, since 的哥 is a taxi driver and jieba has counted
|
|
92
|
+
* them. What this does reach is the untagged tail — a reading somebody asserted
|
|
93
|
+
* rather than a word anybody counted — where the 的 is the particle every time.
|
|
94
|
+
*
|
|
95
|
+
* Measured over the 88,866 lines of Tatoeba and zh.wikipedia it forbids edges
|
|
96
|
+
* in 40 runs: 的筆 13, 的這 11, 的真 6, 的對 4, 的卡 4 and 的歷 once. Every one
|
|
97
|
+
* is a correction, and half of them are corrections to the spacing as much as
|
|
98
|
+
* to the reading — 你說的對 was one word `deduì` and is now two.
|
|
99
|
+
*/
|
|
100
|
+
export const PARTICLE_DE = {
|
|
101
|
+
name: "particle-de",
|
|
102
|
+
verdictFor: (context) => {
|
|
103
|
+
const { edge } = context;
|
|
104
|
+
if (edge.to - edge.from < 2 ||
|
|
105
|
+
edge.partOfSpeech !== "" ||
|
|
106
|
+
!edge.text.startsWith("的")) {
|
|
107
|
+
return "keep";
|
|
108
|
+
}
|
|
109
|
+
const before = wordEndingAt(context, edge.from);
|
|
110
|
+
return MODIFIED_TAGS.test(tagOf(context, before)) ? "forbid" : "keep";
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
//# sourceMappingURL=de-rule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"de-rule.js","sourceRoot":"","sources":["../../src/decode/de-rule.ts"],"names":[],"mappings":"AASA,OAAO,EAGL,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;;;;GAKG;AACH,SAAS,KAAK,CAAC,QAA8B;IAC3C,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,GAAG,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,CAC5E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GA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ACD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC;IACxE,CAAC;CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hint-lattice.d.ts","sourceRoot":"","sources":["../../src/decode/hint-lattice.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"hint-lattice.d.ts","sourceRoot":"","sources":["../../src/decode/hint-lattice.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,OAAO,EAAoC,MAAM,cAAc,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAY,MAAM,YAAY,CAAC;AAiB1D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,GAAG,aAAa,CAK1E;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,aAAa,CAQf;AAeD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,aAAa,GAAG,OAAO,CAyF1E"}
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
import { READING_CHARGE
|
|
1
|
+
import { READING_CHARGE } from "./lattice.js";
|
|
2
|
+
/**
|
|
3
|
+
* What an edge a hint brought with it costs, in both decodes.
|
|
4
|
+
*
|
|
5
|
+
* Zero, because a caller naming a reading is the strongest evidence the decode
|
|
6
|
+
* has. The other branch of {@link applyHints} says so already by overwriting a
|
|
7
|
+
* dictionary entry's reading where a hint names the same stretch, and an edge
|
|
8
|
+
* with no entry behind it has to say the same thing through its cost.
|
|
9
|
+
*
|
|
10
|
+
* It was {@link import("./lattice-types.js").UNKNOWN_COST} until
|
|
11
|
+
* {@link READING_CHARGE} came down, which worked only while one edge beat two
|
|
12
|
+
* whatever they cost: 玩儿 hinted as `wánr` went back to `wán ér` the moment
|
|
13
|
+
* frequency could speak.
|
|
14
|
+
*/
|
|
15
|
+
const HINT_COST = 0;
|
|
2
16
|
/**
|
|
3
17
|
* The same hints with every position moved along by an offset.
|
|
4
18
|
*
|
|
@@ -123,8 +137,8 @@ export function applyHints(lattice, hints) {
|
|
|
123
137
|
to,
|
|
124
138
|
text: spanning.characters.join(""),
|
|
125
139
|
reading: spanning.reading,
|
|
126
|
-
cost:
|
|
127
|
-
readingCost:
|
|
140
|
+
cost: HINT_COST,
|
|
141
|
+
readingCost: HINT_COST + READING_CHARGE,
|
|
128
142
|
isProperNoun: false,
|
|
129
143
|
partOfSpeech: "",
|
|
130
144
|
// No dictionary entry backs this one — that is the whole reason it
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hint-lattice.js","sourceRoot":"","sources":["../../src/decode/hint-lattice.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"hint-lattice.js","sourceRoot":"","sources":["../../src/decode/hint-lattice.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkC,cAAc,EAAE,MAAM,cAAc,CAAC;AAG9E;;;;;;;;;;;;GAYG;AACH,MAAM,SAAS,GAAG,CAAC,CAAC;AAEpB;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,KAAoB,EAAE,EAAU;IACzD,OAAO;QACL,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,EAAE,EAAE,IAAI,GAAG,CAAC,CAAC,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,QAAQ,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE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F,IAAI,EAAE,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;oBAClC,OAAO,EAAE,QAAQ,CAAC,OAAO;oBACzB,IAAI,EAAE,SAAS;oBACf,WAAW,EAAE,SAAS,GAAG,cAAc;oBACvC,YAAY,EAAE,KAAK;oBACnB,YAAY,EAAE,EAAE;oBAChB,mEAAmE;oBACnE,oEAAoE;oBACpE,sEAAsE;oBACtE,6DAA6D;oBAC7D,OAAO,EAAE,KAAK;iBACf;aACF,CAAC;QACJ,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
|
|
@@ -25,6 +25,8 @@ export declare const TAUGHT_TAGS: Set<string>;
|
|
|
25
25
|
* a 教 with a pronoun, a noun or a name after it is governing it, and a 教 with
|
|
26
26
|
* 了, 过, 着 or 得 after it is a verb whatever follows that. A particle in front
|
|
27
27
|
* of it rules it out, since a verb does not follow one.
|
|
28
|
+
*
|
|
29
|
+
* {@link GOVERNING} is the case where nothing follows to look at.
|
|
28
30
|
*/
|
|
29
31
|
export declare function isTeachingAt(context: EdgeContext, at: number): boolean;
|
|
30
32
|
/**
|
|
@@ -46,13 +48,17 @@ export declare function isTeachingAt(context: EdgeContext, at: number): boolean;
|
|
|
46
48
|
* one that matters: 任教, 宗教, 主教, 佛教, 传教, 执教, 请教, 家教.
|
|
47
49
|
*
|
|
48
50
|
* Measured over 88,866 lines of Tatoeba and zh.wikipedia, 181 教 decode as a
|
|
49
|
-
* word of their own and every one of them read `jiào`. This moves
|
|
51
|
+
* word of their own and every one of them read `jiào`. This moves 162 to
|
|
50
52
|
* `jiāo` and is wrong on three: 统一教创始人, 方法教深思 and 做到了教政分离,
|
|
51
53
|
* where a nominal compound takes an object's shape, the last of them because
|
|
52
54
|
* 做到了 is a word and so the 了 in front is not a particle to look at. Of the
|
|
53
|
-
*
|
|
54
|
-
* 教室 reached through a bad split, and a 教 used as a bare noun — and
|
|
55
|
+
* 17 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
|
|
56
|
+
* 教室 reached through a bad split, and a 教 used as a bare noun — and 9 are
|
|
55
57
|
* misses, where jieba tags the object something this does not name.
|
|
58
|
+
*
|
|
59
|
+
* {@link GOVERNING} is four of that 162 and was added later: 能教教我,
|
|
60
|
+
* 要教一節課, 也會教像拉丁語, 這在學校是不教的. 有 is pointedly outside it,
|
|
61
|
+
* since 有教无类 is `yǒujiào wúlèi`.
|
|
56
62
|
*/
|
|
57
63
|
export declare const TEACHING_JIAO: EdgeRule;
|
|
58
64
|
//# sourceMappingURL=jiao-rule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jiao-rule.d.ts","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAI9D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAA8C,CAAC;
|
|
1
|
+
{"version":3,"file":"jiao-rule.d.ts","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,QAAQ,EAId,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,wBAAgB,MAAM,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,GAAG,OAAO,CAI9D;AAED;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,aAA8C,CAAC;AAkCvE;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAUtE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,eAAO,MAAM,aAAa,EAAE,QAiB3B,CAAC"}
|
package/dist/decode/jiao-rule.js
CHANGED
|
@@ -13,6 +13,37 @@ export function isJiao(syllable) {
|
|
|
13
13
|
* only 教 with a place tag after it over the corpus is 教青局, an office.
|
|
14
14
|
*/
|
|
15
15
|
export const TAUGHT_TAGS = new Set(["r", "n", "nz", "nr", "nt", "ng"]);
|
|
16
|
+
/**
|
|
17
|
+
* The words that can only be governing a verb, whatever comes after them.
|
|
18
|
+
*
|
|
19
|
+
* The far side of the context, for the 教 that teaches nothing named:
|
|
20
|
+
* 他怎么教,我都学不会, 你没能力教, 这在学校是不教的, 有时也会教. A modal or a
|
|
21
|
+
* negator has to be followed by a verb, so the 教 after one is the verb even
|
|
22
|
+
* where nothing at all follows it.
|
|
23
|
+
*
|
|
24
|
+
* Written out rather than taken from a tag, for the reason the 长 rule gives:
|
|
25
|
+
* jieba calls 会 `v` along with every other verb and 怎么 `r` along with every
|
|
26
|
+
* pronoun, so neither tag names this set.
|
|
27
|
+
*/
|
|
28
|
+
const GOVERNING = new Set([
|
|
29
|
+
"不",
|
|
30
|
+
"能",
|
|
31
|
+
"会",
|
|
32
|
+
"會",
|
|
33
|
+
"要",
|
|
34
|
+
"想",
|
|
35
|
+
"该",
|
|
36
|
+
"該",
|
|
37
|
+
"也",
|
|
38
|
+
"别",
|
|
39
|
+
"別",
|
|
40
|
+
"没",
|
|
41
|
+
"沒",
|
|
42
|
+
"怎么",
|
|
43
|
+
"怎麼",
|
|
44
|
+
"怎样",
|
|
45
|
+
"怎樣",
|
|
46
|
+
]);
|
|
16
47
|
/**
|
|
17
48
|
* Whether the 教 at a position is teaching something to somebody.
|
|
18
49
|
*
|
|
@@ -20,12 +51,16 @@ export const TAUGHT_TAGS = new Set(["r", "n", "nz", "nr", "nt", "ng"]);
|
|
|
20
51
|
* a 教 with a pronoun, a noun or a name after it is governing it, and a 教 with
|
|
21
52
|
* 了, 过, 着 or 得 after it is a verb whatever follows that. A particle in front
|
|
22
53
|
* of it rules it out, since a verb does not follow one.
|
|
54
|
+
*
|
|
55
|
+
* {@link GOVERNING} is the case where nothing follows to look at.
|
|
23
56
|
*/
|
|
24
57
|
export function isTeachingAt(context, at) {
|
|
25
|
-
|
|
58
|
+
const before = wordEndingAt(context, at);
|
|
59
|
+
if (tagOf(context, before).startsWith(PARTICLE_TAG)) {
|
|
26
60
|
return false;
|
|
27
61
|
}
|
|
28
|
-
return (
|
|
62
|
+
return (GOVERNING.has(before ?? "") ||
|
|
63
|
+
ASPECT.has(context.characters[at + 1] ?? "") ||
|
|
29
64
|
TAUGHT_TAGS.has(tagOf(context, wordStartingAt(context, at + 1))));
|
|
30
65
|
}
|
|
31
66
|
/**
|
|
@@ -47,13 +82,17 @@ export function isTeachingAt(context, at) {
|
|
|
47
82
|
* one that matters: 任教, 宗教, 主教, 佛教, 传教, 执教, 请教, 家教.
|
|
48
83
|
*
|
|
49
84
|
* Measured over 88,866 lines of Tatoeba and zh.wikipedia, 181 教 decode as a
|
|
50
|
-
* word of their own and every one of them read `jiào`. This moves
|
|
85
|
+
* word of their own and every one of them read `jiào`. This moves 162 to
|
|
51
86
|
* `jiāo` and is wrong on three: 统一教创始人, 方法教深思 and 做到了教政分离,
|
|
52
87
|
* where a nominal compound takes an object's shape, the last of them because
|
|
53
88
|
* 做到了 is a word and so the 了 in front is not a particle to look at. Of the
|
|
54
|
-
*
|
|
55
|
-
* 教室 reached through a bad split, and a 教 used as a bare noun — and
|
|
89
|
+
* 17 it leaves, 8 are right — 诸教中, 教外别传, 董教总, 风教, 教青局 twice, a
|
|
90
|
+
* 教室 reached through a bad split, and a 教 used as a bare noun — and 9 are
|
|
56
91
|
* misses, where jieba tags the object something this does not name.
|
|
92
|
+
*
|
|
93
|
+
* {@link GOVERNING} is four of that 162 and was added later: 能教教我,
|
|
94
|
+
* 要教一節課, 也會教像拉丁語, 這在學校是不教的. 有 is pointedly outside it,
|
|
95
|
+
* since 有教无类 is `yǒujiào wúlèi`.
|
|
57
96
|
*/
|
|
58
97
|
export const TEACHING_JIAO = {
|
|
59
98
|
name: "teaching-jiao",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jiao-rule.js","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,YAAY,EAGZ,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,QAA8B;IACnD,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,GAAG,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;AAEvE
|
|
1
|
+
{"version":3,"file":"jiao-rule.js","sourceRoot":"","sources":["../../src/decode/jiao-rule.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,MAAM,EACN,YAAY,EAGZ,KAAK,EACL,YAAY,EACZ,cAAc,GACf,MAAM,YAAY,CAAC;AAEpB;;GAEG;AACH,MAAM,UAAU,MAAM,CAAC,QAA8B;IACnD,OAAO,CACL,QAAQ,EAAE,OAAO,KAAK,GAAG,IAAI,QAAQ,CAAC,KAAK,KAAK,KAAK,IAAI,QAAQ,CAAC,IAAI,KAAK,CAAC,CAC7E,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,C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AO;gBACT,CAAC,CAAC,MAAM,CAAC;QACb,CAAC;QACD,OAAO,IAAI,CAAC,YAAY,KAAK,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;YACvB,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI;YAC3C,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;YAC5B,YAAY,CAAC,OAAO,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,CAAC;YAClC,CAAC,CAAC,QAAQ;YACV,CAAC,CAAC,MAAM,CAAC;IACb,CAAC;CACF,CAAC"}
|
|
@@ -63,15 +63,34 @@ export declare const ALTERNATE_PENALTY = 1;
|
|
|
63
63
|
* outright that those two characters together read `dì qì`. A stored reading is
|
|
64
64
|
* evidence about the characters; a character's default reading is only a prior.
|
|
65
65
|
*
|
|
66
|
-
* So the reading decode charges per *edge
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
66
|
+
* So the reading decode charges per *edge*, and the charge is what a word is
|
|
67
|
+
* worth against the frequencies around it. The whole frequency scale is 15
|
|
68
|
+
* buckets wide, so a charge of 15 already makes the rarest possible word beat
|
|
69
|
+
* the two commonest possible characters. This was 16 for most of the project's
|
|
70
|
+
* life, and with `WORD_CHARGE` on top of it the real price of a word boundary
|
|
71
|
+
* was 20.62 — five buckets past the point where frequency can say anything at
|
|
72
|
+
* all. Every 那是 in the language read `nà shi` on the strength of one
|
|
73
|
+
* colloquial CC-CEDICT entry no corpus has ever counted, and 都会, 过得, 得了
|
|
74
|
+
* and 的哥 went the same way.
|
|
75
|
+
*
|
|
76
|
+
* At 6 the price is 10.62 and the arithmetic decides something. A word loses
|
|
77
|
+
* its span to a two-character split when the two characters are more than
|
|
78
|
+
* 25.62 buckets better than it, which needs a word nothing attests standing
|
|
79
|
+
* against two characters near the top of the scale. An attested word survives
|
|
80
|
+
* whatever is beside it, so 地气 is still `dì qì`.
|
|
81
|
+
*
|
|
82
|
+
* Measured over the 88,866 lines of Tatoeba and zh.wikipedia the stage-4 rules
|
|
83
|
+
* were sized against, moving 16 to 6 changes 822 of 139,682 Han runs. The
|
|
84
|
+
* changes are 那是 (303), 都 read `dū` (141), 得 read `dé` after a verb (98),
|
|
85
|
+
* 为 read `wéi` where it means *for* (36), 一个 (27), and a tail of 了, 只, 中,
|
|
86
|
+
* 说 and 的. Against them stand 21 老是, 11 等地 and 10 倒是, where the word
|
|
87
|
+
* really was one word. On CPP's 20,139 hand-labelled polyphones it is 91.48%
|
|
88
|
+
* either way, and the gold corpus does not move.
|
|
89
|
+
*
|
|
90
|
+
* Word frequency survives as the tiebreak between paths covering the same span
|
|
91
|
+
* with the same number of words.
|
|
73
92
|
*/
|
|
74
|
-
export declare const READING_CHARGE =
|
|
93
|
+
export declare const READING_CHARGE = 6;
|
|
75
94
|
/**
|
|
76
95
|
* What an edge covering a character no dictionary entry knows costs.
|
|
77
96
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lattice-types.d.ts","sourceRoot":"","sources":["../../src/decode/lattice-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,OAAO,EAAE,SAAS,QAAQ,EAAE,CAAC;IACtC,2EAA2E;IAC3E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2EAA2E;IAC3E,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC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C7D,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,WAAW,EAAE,CAAC,EAAE,CAAC;CACrD;AAED;;;;;GAKG;AACH,eAAO,MAAM,YAAY,KAAK,CAAC;AAE/B;;;;;;;GAOG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;GAKG;AACH,eAAO,MAAM,YAAY,KAAK,CAAC"}
|
|
@@ -25,15 +25,34 @@ export const ALTERNATE_PENALTY = 1;
|
|
|
25
25
|
* outright that those two characters together read `dì qì`. A stored reading is
|
|
26
26
|
* evidence about the characters; a character's default reading is only a prior.
|
|
27
27
|
*
|
|
28
|
-
* So the reading decode charges per *edge
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
28
|
+
* So the reading decode charges per *edge*, and the charge is what a word is
|
|
29
|
+
* worth against the frequencies around it. The whole frequency scale is 15
|
|
30
|
+
* buckets wide, so a charge of 15 already makes the rarest possible word beat
|
|
31
|
+
* the two commonest possible characters. This was 16 for most of the project's
|
|
32
|
+
* life, and with `WORD_CHARGE` on top of it the real price of a word boundary
|
|
33
|
+
* was 20.62 — five buckets past the point where frequency can say anything at
|
|
34
|
+
* all. Every 那是 in the language read `nà shi` on the strength of one
|
|
35
|
+
* colloquial CC-CEDICT entry no corpus has ever counted, and 都会, 过得, 得了
|
|
36
|
+
* and 的哥 went the same way.
|
|
37
|
+
*
|
|
38
|
+
* At 6 the price is 10.62 and the arithmetic decides something. A word loses
|
|
39
|
+
* its span to a two-character split when the two characters are more than
|
|
40
|
+
* 25.62 buckets better than it, which needs a word nothing attests standing
|
|
41
|
+
* against two characters near the top of the scale. An attested word survives
|
|
42
|
+
* whatever is beside it, so 地气 is still `dì qì`.
|
|
43
|
+
*
|
|
44
|
+
* Measured over the 88,866 lines of Tatoeba and zh.wikipedia the stage-4 rules
|
|
45
|
+
* were sized against, moving 16 to 6 changes 822 of 139,682 Han runs. The
|
|
46
|
+
* changes are 那是 (303), 都 read `dū` (141), 得 read `dé` after a verb (98),
|
|
47
|
+
* 为 read `wéi` where it means *for* (36), 一个 (27), and a tail of 了, 只, 中,
|
|
48
|
+
* 说 and 的. Against them stand 21 老是, 11 等地 and 10 倒是, where the word
|
|
49
|
+
* really was one word. On CPP's 20,139 hand-labelled polyphones it is 91.48%
|
|
50
|
+
* either way, and the gold corpus does not move.
|
|
51
|
+
*
|
|
52
|
+
* Word frequency survives as the tiebreak between paths covering the same span
|
|
53
|
+
* with the same number of words.
|
|
35
54
|
*/
|
|
36
|
-
export const READING_CHARGE =
|
|
55
|
+
export const READING_CHARGE = 6;
|
|
37
56
|
/**
|
|
38
57
|
* What an edge covering a character no dictionary entry knows costs.
|
|
39
58
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lattice-types.js","sourceRoot":"","sources":["../../src/decode/lattice-types.ts"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC
|
|
1
|
+
{"version":3,"file":"lattice-types.js","sourceRoot":"","sources":["../../src/decode/lattice-types.ts"],"names":[],"mappings":"AAyCA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC;AAE/B;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAEnC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,CAAC"}
|
|
@@ -1,31 +1,11 @@
|
|
|
1
|
-
export { PLAYING_TAN } from "./tan-rule.js";
|
|
2
|
-
import { type EdgeRule } from "./rules.js";
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* The character is stored `zhǎng` with `cháng` as an alternate, and the data
|
|
7
|
-
* says so about the character in isolation: Unihan ranks the readings
|
|
8
|
-
* `zhǎng(1879) cháng(1179)` by corpus count and names `zhǎng` in `kMandarin`.
|
|
9
|
-
* That ranking is doing real work — 署长, 团长, 公安局长, 总会长, 审理长 and
|
|
10
|
-
* the rest reach a bare 长 at the end of a title and read it correctly — so the
|
|
11
|
-
* default is not the thing to change. What is left over is the 长 that is an
|
|
12
|
-
* adjective, and nothing in the cost model can prefer an alternate at a
|
|
13
|
-
* position no word covers: 这篇文章不太长 came out `bú tài zhǎng`.
|
|
14
|
-
*
|
|
15
|
-
* The context that separates them is one-sided, as it was for the modal 得. A
|
|
16
|
-
* 长 that is *growing* is a verb, and a degree adverb cannot modify one — there
|
|
17
|
-
* is no 很长 meaning it grew a lot — so 很, 太, 最, 多 and their kin in front of
|
|
18
|
-
* a bare 长 make it the adjective. The other side carries almost nothing: what
|
|
19
|
-
* follows an adjectival 长 is a noun (很长时间), a particle (最长的大桥), or the
|
|
20
|
-
* end of the sentence (他的腿很长), which is also what follows half the verbs.
|
|
2
|
+
* The rules that settle a polyphone from the words around it.
|
|
21
3
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* The other half of the rule is {@link GROWN_INTO}, which pushes the opposite
|
|
28
|
-
* way on the one shape the sources get wrong.
|
|
4
|
+
* 弹 is `tán` or `dàn`, and which one a text means is a question about the
|
|
5
|
+
* neighbours rather than about the character. 长 is the same question and has
|
|
6
|
+
* a file of its own. The other rules in `reading-rules.ts` are about particles
|
|
7
|
+
* and 儿化, which is a different kind of evidence.
|
|
29
8
|
*/
|
|
30
|
-
export
|
|
9
|
+
export { ADJECTIVAL_CHANG } from "./chang-rule.js";
|
|
10
|
+
export { PLAYING_TAN } from "./tan-rule.js";
|
|
31
11
|
//# sourceMappingURL=polyphone-rules.d.ts.map
|