@kensio/pinyinjs 1.8.6 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
@@ -67108,6 +67108,7 @@ B
67108
67108
  網關
67109
67109
  網頁
67110
67110
  網點
67111
+ 綳
67111
67112
  綴
67112
67113
  綵
67113
67114
  綷
@@ -96968,7 +96969,6 @@ B
96968
96969
  麩
96969
96970
  麫
96970
96971
  麮
96971
- 麯
96972
96972
  麰
96973
96973
  麳
96974
96974
  麴
@@ -1 +1 @@
1
- {"version":3,"file":"character-defaults.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAGL,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,QAAQ,GAAG,SAAS,CAEtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC,CAAC;IAC5D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,EACzD,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,GACxD,iBAAiB,CAiDnB"}
1
+ {"version":3,"file":"character-defaults.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAGL,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAErD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,GACd,QAAQ,GAAG,SAAS,CAEtB;AAED;;;GAGG;AACH,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CAAC;IACvC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,QAAQ,EAAE,CAAC,CAAC;IAC5D,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,EACzD,YAAY,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,WAAW,EAAE,CAAC,GACxD,iBAAiB,CAsDnB"}
@@ -8,6 +8,7 @@
8
8
  */
9
9
  import { countCorpusMass, rankByCorpusMass } from "./corpus-mass.js";
10
10
  import { demoteReducedNeutrals, isNeutralAlone, resolveFrequencyTones, } from "./frequency-tones.js";
11
+ import { leadWithFreeReading } from "./free-readings.js";
11
12
  import { readAlignedReading, readDictionaryReading } from "./reading.js";
12
13
  import { pairScripts, TraditionalTable, } from "./traditional.js";
13
14
  /**
@@ -39,6 +40,8 @@ export function buildCharacterDefaults(sources, cedictByWord, cedictByHant) {
39
40
  // Unihan ranks the readings and the corpus re-ranks the ones it has seen: a
40
41
  // character's default is whichever of its readings the dictionary's own words
41
42
  // spend the most of jieba's corpus on, and Unihan's order decides the rest.
43
+ // A character listed in FREE_READINGS then leads with the reading it takes
44
+ // standing alone, which neither ranking can see.
42
45
  const mass = countCorpusMass({ phrase, cedict, jieba }, traditional);
43
46
  const defaults = new Map();
44
47
  let reducedNeutrals = 0;
@@ -59,7 +62,7 @@ export function buildCharacterDefaults(sources, cedictByWord, cedictByHant) {
59
62
  .map((reading) => characterSyllable(character, reading))
60
63
  .filter((syllable) => syllable !== undefined);
61
64
  if (parsed.length > 0) {
62
- defaults.set(character, rankByCorpusMass(character, parsed, readings.fields, mass));
65
+ defaults.set(character, leadWithFreeReading(character, rankByCorpusMass(character, parsed, readings.fields, mass)));
63
66
  }
64
67
  }
65
68
  return { traditional, defaults, reducedNeutrals };
@@ -1 +1 @@
1
- {"version":3,"file":"character-defaults.js","sourceRoot":"","sources":["../../src/dictionary/character-defaults.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EACL,qBAAqB,EACrB,cAAc,EACd,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACzE,OAAO,EACL,WAAW,EAEX,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAG1B;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAC/B,SAAiB,EACjB,OAAe;IAEf,OAAO,qBAAqB,CAAC,SAAS,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAC1D,CAAC;AAYD;;GAEG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAqB,EACrB,YAAyD,EACzD,YAAyD;IAEzD,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC1E,6DAA6D;IAC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V,CAAC,CAAC,qBAAqB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAC9C,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;YACrD,eAAe,EAAE,CAAC;QACpB,CAAC;QACD,MAAM,MAAM,GAAG,MAAM;aAClB,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;aACvD,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC;QAChD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,QAAQ,CAAC,GAAG,CACV,SAAS,EACT,mBAAmB,CACjB,SAAS,EACT,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAC3D,CACF,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,CAAC;AACpD,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"character-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-readings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,kBAAkB,EAAE,SAAS,cAAc,EAsBvD,CAAC"}
1
+ {"version":3,"file":"character-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/character-readings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,eAAO,MAAM,kBAAkB,EAAE,SAAS,cAAc,EA+BvD,CAAC"}
@@ -21,5 +21,14 @@ export const CHARACTER_READINGS = [
21
21
  reads("子", "zǐ", "and a suffix sense is not a claim about the character"),
22
22
  reads("夫", "fū", "nor is 大夫's and 丈夫's reduction"),
23
23
  reads("吗", "ma", "but a 语气词 CC-CEDICT reads 轻声 alone keeps it"),
24
+ // FREE_READINGS: the free verb or classifier leads, and the compounds that
25
+ // ranked the other reading first keep it.
26
+ reads("剥", "bāo", "the free verb, not 剥削's bō"),
27
+ reads("剥削", "bō xuē", "and the compounds keep the literary reading"),
28
+ reads("切", "qiē", "kHanyuPinlu's qiè is nearly all 一切"),
29
+ reads("一切", "yī qiè", "which keeps it"),
30
+ reads("幢", "zhuàng", "the classifier, not 经幢's banner"),
31
+ reads("脏", "zāng", "dirty, not the organ"),
32
+ reads("心脏", "xīn zàng", "which 心脏 keeps"),
24
33
  ];
25
34
  //# sourceMappingURL=character-readings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"character-readings.js","sourceRoot":"","sources":["../../src/dictionary/character-readings.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,MAAM,CAAC,MAAM,kBAAkB,GAA8B;IAC3D,oEAAoE;IACpE,wEAAwE;IACxE,0EAA0E;IAC1E,yEAAyE;IACzE,gEAAgE;IAChE,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,uCAAuC,CAAC;IAChE,KAAK,CAAC,IAAI,EAAE,SAAS,EAAE,6CAA6C,CAAC;IACrE,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,gDAAgD,CAAC;IACvE,0EAA0E;IAC1E,wEAAwE;IACxE,0EAA0E;IAC1E,4EAA4E;IAC5E,uDAAuD;IACvD,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,yCAAyC,CAAC;IAC3D,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,+CAA+C,CAAC;IAClE,KAAK,CAAC,GAAG,EAAE,IAAI,EAAE,4CAA4C,CAAC;IAC9D,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,mDAAmD,CAAC;IAC1E,KAAK,CAAC,G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AK,EAAE,4BAA4B,CAAC;IAC/C,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,6CAA6C,CAAC;IACpE,KAAK,CAAC,GAAG,EAAE,KAAK,EAAE,oCAAoC,CAAC;IACvD,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,gBAAgB,CAAC;IACvC,KAAK,CAAC,GAAG,EAAE,QAAQ,EAAE,iCAAiC,CAAC;IACvD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,sBAAsB,CAAC;IAC1C,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,gBAAgB,CAAC;CAC1C,CAAC"}
@@ -0,0 +1,70 @@
1
+ import { type Syllable } from "../syllable/syllable.js";
2
+ /**
3
+ * A character whose reading as a word of its own is not the one it leads with.
4
+ */
5
+ export interface FreeReading {
6
+ /** The character, in either script. */
7
+ readonly character: string;
8
+ /** The reading it takes standing alone, as tone-marked pinyin. */
9
+ readonly reading: string;
10
+ /** The words that carry the other reading, which is why the sources rank it
11
+ * first. */
12
+ readonly displaces: string;
13
+ }
14
+ /**
15
+ * Characters that read one way inside words and another standing alone.
16
+ *
17
+ * A character's default is ranked by `kHanyuPinlu` where it lists several
18
+ * readings and by the corpus mass of the dictionary's words where it does not,
19
+ * and both count the character *inside words*. That is the right evidence for
20
+ * most polyphones and the wrong evidence for these, which have a literary
21
+ * reading in their compounds and an everyday one as a free verb or classifier.
22
+ * 剥削, 剥夺 and 剥落 give 剥 `bō`, and a reader peeling an orange says `bāo`.
23
+ * `kHanyuPinlu` counts 切 `qiè` 998 times against `qiē` 70, nearly all of it
24
+ * 一切, and 切土豆 is `qiē`.
25
+ *
26
+ * The compounds are dictionary words and keep their own readings. The default
27
+ * is what a character segmented on its own is read with, which is where these
28
+ * stand as free words, and what an unknown compound is derived from.
29
+ *
30
+ * **What is listed here.** A character whose 现代汉语词典 entry gives the listed
31
+ * reading to its free use and the other to its compounds or a literary sense,
32
+ * found by reading example sentences rather than by a measure. CPP labels
33
+ * news text, where these characters mostly sit inside words, so it is the check
34
+ * that nothing broke rather than the evidence for the list. What is *not*
35
+ * listed is a character whose free uses split, such as 卡 (a card, `kǎ`, and
36
+ * stuck, `qiǎ`) or 背 (the back and to recite, `bèi`, and to carry, `bēi`): a
37
+ * default cannot choose between two free words, and a context rule can. Nor
38
+ * is a character that names and transliterations use on its own: 勒 is `lēi`
39
+ * in 勒得难受 and `lè` in every 希特勒 and 达勒姆 the dictionary lacks, and 盛 is
40
+ * `chéng` in 盛汤 and the surname `Shèng` in 刘盛. Listing either cost CPP 25
41
+ * and 7 cases.
42
+ *
43
+ * **The reading must be one the sources already give the character.** It is
44
+ * moved to the front of the ranking rather than written over it, so a source
45
+ * refresh that dropped it would fail the build rather than leave a reading
46
+ * nothing attests. That is why 剝 and 掙 are missing beside 剥 and 挣: Unihan
47
+ * gives them `bō` and `zhēng` alone.
48
+ */
49
+ export declare const FREE_READINGS: readonly FreeReading[];
50
+ /**
51
+ * Read a free reading into a syllable, throwing if it is not one.
52
+ *
53
+ * Throwing for the reason {@link import("./overrides.js").readOverrideReading}
54
+ * does: an entry that failed to parse would leave the ranking it was written
55
+ * to correct, and nothing would notice.
56
+ */
57
+ export declare function freeSyllable(free: FreeReading): Syllable;
58
+ /**
59
+ * The table, keyed by character and parsed into syllables.
60
+ */
61
+ export declare const FREE_SYLLABLES: ReadonlyMap<string, Syllable>;
62
+ /**
63
+ * Lead a character's ranked readings with its free reading, where it has one.
64
+ *
65
+ * The rest keep the order the ranking gave them. A listed reading the ranking
66
+ * does not hold throws, which is the build failing on a source that stopped
67
+ * attesting it.
68
+ */
69
+ export declare function leadWithFreeReading(character: string, ranked: readonly Syllable[]): readonly Syllable[];
70
+ //# sourceMappingURL=free-readings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"free-readings.d.ts","sourceRoot":"","sources":["../../src/dictionary/free-readings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,uCAAuC;IACvC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;gBACY;IACZ,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EA0B/C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,WAAW,GAAG,QAAQ,CAQxD;AAED;;GAEG;AACH,eAAO,MAAM,cAAc,EAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAExD,CAAC;AAaF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,SAAS,QAAQ,EAAE,GAC1B,SAAS,QAAQ,EAAE,CAYrB"}
@@ -0,0 +1,108 @@
1
+ import { readSyllable } from "../syllable/syllable.js";
2
+ /**
3
+ * Characters that read one way inside words and another standing alone.
4
+ *
5
+ * A character's default is ranked by `kHanyuPinlu` where it lists several
6
+ * readings and by the corpus mass of the dictionary's words where it does not,
7
+ * and both count the character *inside words*. That is the right evidence for
8
+ * most polyphones and the wrong evidence for these, which have a literary
9
+ * reading in their compounds and an everyday one as a free verb or classifier.
10
+ * 剥削, 剥夺 and 剥落 give 剥 `bō`, and a reader peeling an orange says `bāo`.
11
+ * `kHanyuPinlu` counts 切 `qiè` 998 times against `qiē` 70, nearly all of it
12
+ * 一切, and 切土豆 is `qiē`.
13
+ *
14
+ * The compounds are dictionary words and keep their own readings. The default
15
+ * is what a character segmented on its own is read with, which is where these
16
+ * stand as free words, and what an unknown compound is derived from.
17
+ *
18
+ * **What is listed here.** A character whose 现代汉语词典 entry gives the listed
19
+ * reading to its free use and the other to its compounds or a literary sense,
20
+ * found by reading example sentences rather than by a measure. CPP labels
21
+ * news text, where these characters mostly sit inside words, so it is the check
22
+ * that nothing broke rather than the evidence for the list. What is *not*
23
+ * listed is a character whose free uses split, such as 卡 (a card, `kǎ`, and
24
+ * stuck, `qiǎ`) or 背 (the back and to recite, `bèi`, and to carry, `bēi`): a
25
+ * default cannot choose between two free words, and a context rule can. Nor
26
+ * is a character that names and transliterations use on its own: 勒 is `lēi`
27
+ * in 勒得难受 and `lè` in every 希特勒 and 达勒姆 the dictionary lacks, and 盛 is
28
+ * `chéng` in 盛汤 and the surname `Shèng` in 刘盛. Listing either cost CPP 25
29
+ * and 7 cases.
30
+ *
31
+ * **The reading must be one the sources already give the character.** It is
32
+ * moved to the front of the ranking rather than written over it, so a source
33
+ * refresh that dropped it would fail the build rather than leave a reading
34
+ * nothing attests. That is why 剝 and 掙 are missing beside 剥 and 挣: Unihan
35
+ * gives them `bō` and `zhēng` alone.
36
+ */
37
+ export const FREE_READINGS = [
38
+ { character: "幢", reading: "zhuàng", displaces: "幢幢 and 经幢, a banner" },
39
+ { character: "抡", reading: "lūn", displaces: "抡材 and 抡元, to select" },
40
+ { character: "掄", reading: "lūn", displaces: "掄材 and 掄元, to select" },
41
+ { character: "剥", reading: "bāo", displaces: "剥削, 剥夺 and 剥落" },
42
+ { character: "削", reading: "xiāo", displaces: "削弱, 削减 and 剥削" },
43
+ { character: "铺", reading: "pū", displaces: "店铺 and 床铺, the noun" },
44
+ { character: "鋪", reading: "pū", displaces: "店鋪 and 床鋪, the noun" },
45
+ { character: "咳", reading: "ké", displaces: "the interjection hāi" },
46
+ { character: "哄", reading: "hǒng", displaces: "哄堂 and 哄抢, an uproar" },
47
+ { character: "刨", reading: "páo", displaces: "刨床 and 刨子, a plane" },
48
+ { character: "攒", reading: "zǎn", displaces: "攒聚 and 攒眉, to gather" },
49
+ { character: "攢", reading: "zǎn", displaces: "攢聚 and 攢眉, to gather" },
50
+ { character: "绷", reading: "bēng", displaces: "绷着脸, a stiff face" },
51
+ { character: "繃", reading: "bēng", displaces: "繃著臉, a stiff face" },
52
+ { character: "翘", reading: "qiào", displaces: "翘首 and 翘楚" },
53
+ { character: "翹", reading: "qiào", displaces: "翹首 and 翹楚" },
54
+ { character: "划", reading: "huá", displaces: "计划, 划分 and 规划" },
55
+ { character: "劃", reading: "huá", displaces: "計劃, 劃分 and 規劃" },
56
+ { character: "曲", reading: "qǔ", displaces: "曲线, 弯曲 and 曲折" },
57
+ { character: "切", reading: "qiē", displaces: "一切, 亲切 and 切实" },
58
+ { character: "嚼", reading: "jiáo", displaces: "咀嚼, the literary word" },
59
+ { character: "倔", reading: "juè", displaces: "倔强 and 倔犟" },
60
+ { character: "脏", reading: "zāng", displaces: "心脏 and 内脏, an organ" },
61
+ { character: "挣", reading: "zhèng", displaces: "挣扎, to struggle" },
62
+ { character: "漂", reading: "piāo", displaces: "漂亮 and 漂白" },
63
+ ];
64
+ /**
65
+ * Read a free reading into a syllable, throwing if it is not one.
66
+ *
67
+ * Throwing for the reason {@link import("./overrides.js").readOverrideReading}
68
+ * does: an entry that failed to parse would leave the ranking it was written
69
+ * to correct, and nothing would notice.
70
+ */
71
+ export function freeSyllable(free) {
72
+ const syllable = readSyllable(free.reading);
73
+ if (syllable?.tone === undefined) {
74
+ throw new Error(`free reading for ${free.character} is not a reading: ${free.reading}`);
75
+ }
76
+ return syllable;
77
+ }
78
+ /**
79
+ * The table, keyed by character and parsed into syllables.
80
+ */
81
+ export const FREE_SYLLABLES = new Map(FREE_READINGS.map((free) => [free.character, freeSyllable(free)]));
82
+ /**
83
+ * Whether two syllables are the same reading, 儿化 aside.
84
+ */
85
+ function sameReading(left, right) {
86
+ return (left.initial === right.initial &&
87
+ left.final === right.final &&
88
+ left.tone === right.tone);
89
+ }
90
+ /**
91
+ * Lead a character's ranked readings with its free reading, where it has one.
92
+ *
93
+ * The rest keep the order the ranking gave them. A listed reading the ranking
94
+ * does not hold throws, which is the build failing on a source that stopped
95
+ * attesting it.
96
+ */
97
+ export function leadWithFreeReading(character, ranked) {
98
+ const free = FREE_SYLLABLES.get(character);
99
+ if (free === undefined) {
100
+ return ranked;
101
+ }
102
+ const lead = ranked.find((syllable) => sameReading(syllable, free));
103
+ if (lead === undefined) {
104
+ throw new Error(`free reading for ${character} is not one the sources give it`);
105
+ }
106
+ return [lead, ...ranked.filter((syllable) => syllable !== lead)];
107
+ }
108
+ //# sourceMappingURL=free-readings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"free-readings.js","sourceRoot":"","sources":["../../src/dictionary/free-readings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAiB,MAAM,yBAAyB,CAAC;AAetE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,qBAAqB,EAAE;IACvE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACrE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACrE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE;IAC9D,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE;IAC/D,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE;IACnE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,qBAAqB,EAAE;IACnE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,sBAAsB,EAAE;IACpE,EAAE,SAAS,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,S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AAC,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC,CAAC;IACpE,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CACb,oBAAoB,SAAS,iCAAiC,CAC/D,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC;AACnE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kensio/pinyinjs",
3
- "version": "1.8.6",
3
+ "version": "1.9.0",
4
4
  "description": "Chinese hanzi to pinyin conversion",
5
5
  "repository": "https://github.com/KensioSoftware/pinyinjs",
6
6
  "homepage": "https://pinyinjs.dev",