@furifont/dictionary 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { Dictionary } from "@furifont/core";
2
2
  //#region src/index.d.ts
3
- /** Loads the compiled dictionary: JMdict and JMnedict place names, aligned by JmdictFurigana, with KANJIDIC2's on'yomi and JLPT levels. */
3
+ /** Loads the compiled dictionary: JMdict and JMnedict place names, aligned by JmdictFurigana, with KANJIDIC2's on'yomi, JLPT levels and uses in Tatoeba's sentences. */
4
4
  export declare function loadDictionary(): Promise<Dictionary>;
5
5
  //#endregion
package/dist/index.mjs CHANGED
@@ -1,18 +1,20 @@
1
1
  import * as v from "valibot";
2
- //#region src/defaults.ts
2
+ //#region src/overrides.ts
3
3
  /**
4
- * Default readings the compiled data ranks wrong, in inline notation. JMdict's
4
+ * Readings that override the compiled data where it ranks them wrong, in inline notation. JMdict's
5
5
  * frequency tags belong to a written form, so across entries they cannot tell
6
6
  * two readings apart; and a form that drops its okurigana usually meets it in
7
7
  * running text, where the font cannot see it. Users' pins override these.
8
8
  */
9
- const DEFAULT_READINGS = [
9
+ const OVERRIDE_READINGS = [
10
10
  "出[で]来[き]",
11
11
  "何[なん]人[にん]",
12
12
  "何[なん]時[じ]",
13
13
  "三[さん]十[じゅう]日[にち]",
14
14
  "外[そと]付[づ]",
15
- "支[し]払[はら]"
15
+ "支[し]払[はら]",
16
+ "字[じ]",
17
+ "明[みん]朝[ちょう]"
16
18
  ];
17
19
  /**
18
20
  * Kanji left bare when alone in a run, though one reading dominates the
@@ -50,6 +52,11 @@ const JlptSchema = v.array(v.tuple([
50
52
  5
51
53
  ])
52
54
  ]));
55
+ const TatoebaSchema = v.array(v.tuple([
56
+ v.string(),
57
+ v.string(),
58
+ v.pipe(v.number(), v.integer(), v.minValue(1))
59
+ ]));
53
60
  /**
54
61
  * A data file as a JSON module, which Node loads and bundlers split into a
55
62
  * lazy chunk. The path is a template so that TypeScript leaves the 11 MB file
@@ -59,18 +66,20 @@ async function readData(name, schema) {
59
66
  const { default: data } = await import(`../data/${name}.json`, { with: { type: "json" } });
60
67
  return v.parse(schema, data);
61
68
  }
62
- /** Loads the compiled dictionary: JMdict and JMnedict place names, aligned by JmdictFurigana, with KANJIDIC2's on'yomi and JLPT levels. */
69
+ /** Loads the compiled dictionary: JMdict and JMnedict place names, aligned by JmdictFurigana, with KANJIDIC2's on'yomi, JLPT levels and uses in Tatoeba's sentences. */
63
70
  async function loadDictionary() {
64
- const [data, places, jlpt] = await Promise.all([
71
+ const [data, places, jlpt, tatoeba] = await Promise.all([
65
72
  readData("dictionary", DataSchema),
66
73
  readData("places", PlacesSchema),
67
- readData("jlpt", JlptSchema)
74
+ readData("jlpt", JlptSchema),
75
+ readData("tatoeba", TatoebaSchema)
68
76
  ]);
69
77
  const levels = new Map(jlpt.map(([form, furigana, level]) => [`${form}|${furigana}`, level]));
78
+ const uses = new Map(tatoeba.map(([form, furigana, n]) => [`${form}|${furigana}`, n]));
70
79
  return {
71
80
  sources: data.sources,
72
81
  onyomi: data.onyomi,
73
- defaults: DEFAULT_READINGS,
82
+ defaults: OVERRIDE_READINGS,
74
83
  bare: BARE_FORMS,
75
84
  places: places.map(([form, furigana]) => ({
76
85
  form,
@@ -78,6 +87,8 @@ async function loadDictionary() {
78
87
  })),
79
88
  entries: data.entries.map(([form, furigana, nf, priority, order, conjugates]) => {
80
89
  const level = levels.get(`${form}|${furigana}`);
90
+ const n = uses.get(`${form}|${furigana}`);
91
+ uses.delete(`${form}|${furigana}`);
81
92
  return {
82
93
  form,
83
94
  furigana,
@@ -85,7 +96,8 @@ async function loadDictionary() {
85
96
  priority,
86
97
  order,
87
98
  ...conjugates && { conjugatesReading: true },
88
- ...level && { jlpt: level }
99
+ ...level && { jlpt: level },
100
+ ...n && { tatoeba: n }
89
101
  };
90
102
  })
91
103
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@furifont/dictionary",
3
3
  "type": "module",
4
- "version": "0.1.2",
4
+ "version": "0.2.0",
5
5
  "description": "JMdict words aligned with per-kanji readings, compiled for Furifont",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "CC-BY-SA-4.0",
@@ -25,11 +25,15 @@
25
25
  "dist"
26
26
  ],
27
27
  "dependencies": {
28
- "@furifont/core": "0.1.2",
28
+ "@furifont/core": "0.2.0",
29
29
  "valibot": "^1.5.0"
30
30
  },
31
+ "devDependencies": {
32
+ "@furifont/compiler": "0.2.0"
33
+ },
31
34
  "scripts": {
32
35
  "build": "tsdown",
33
- "update": "node scripts/update.ts"
36
+ "update": "node scripts/update.ts",
37
+ "audit": "node scripts/audit.ts"
34
38
  }
35
39
  }