indickit 0.12.0 → 0.13.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.
@@ -6,9 +6,11 @@
6
6
  * @module
7
7
  */
8
8
  import rulesJson from "../phonetic/rules.json";
9
- type Rules = Omit<typeof rulesJson, "initials" | "titles" | "initial_branches" | "brahmic" | "extra"> & {
9
+ type Rules = Omit<typeof rulesJson, "initials" | "abbreviations" | "second_readings" | "titles" | "initial_branches" | "brahmic" | "extra"> & {
10
10
  extra: Record<string, string>;
11
11
  initials?: Record<string, string[]>;
12
+ abbreviations?: Record<string, string[]>;
13
+ second_readings?: string[][];
12
14
  initial_branches?: {
13
15
  from: number;
14
16
  to: number;
@@ -7,6 +7,9 @@
7
7
  * running text (the default); "names" for fields known to hold person
8
8
  * names, where a lookup of known names comes first; and "places" for place
9
9
  * names (its own tables in nine languages, the "words" tables in the others).
10
+ * In Hindi, `load("hi", "names", { route: true })` spells only the names the
11
+ * names tables were trained on with them, and every other word with the
12
+ * "words" tables.
10
13
  *
11
14
  * The tables are learned from data and loaded per language, on demand:
12
15
  *
@@ -43,7 +46,13 @@ export interface Romanizer {
43
46
  /**
44
47
  * Loads a language's tables for one mode: its own file, its script group's
45
48
  * pooled file (shared by the group, fetched once) and, for the names mode,
46
- * the letter n-gram every names page shares. It reads them beside this
49
+ * the letter n-gram every names page shares. With `route: true`, Hindi's
50
+ * names mode also loads its list of known names and its words tables
51
+ * (rules 2026-10-13): a name the names tables were trained on keeps its
52
+ * names list, and any other word gets the words list. On names in news held
53
+ * out (PIB, August 2023) Hindi's first spelling goes from 55.0% to 62.2%;
54
+ * the page grows from 0.56 MB to 2.5 MB (26 KB on a page that has Hindi's
55
+ * words tables). In a language or mode with no route, `route` changes nothing. It reads them beside this
47
56
  * module, else from jsDelivr at this package's version (the npm package
48
57
  * carries no tables); `base` or `fetch` replaces both. Rejects when the
49
58
  * language has no tables for the mode.
@@ -51,11 +60,17 @@ export interface Romanizer {
51
60
  export declare function load(lang: string, mode?: Mode, opts?: {
52
61
  fetch?: Fetcher;
53
62
  base?: URL | string;
63
+ route?: boolean;
54
64
  }): Promise<Romanizer>;
55
65
  /**
56
66
  * Builds a Romanizer from a language's files (for tests and offline use): its own, its
57
- * group's pooled one and, for a mode with a letter n-gram (names), that file too.
67
+ * group's pooled one and, for a mode with a letter n-gram (names), that file too. `route`
68
+ * turns the route on where the mode has one (Hindi names): the known list's file and the
69
+ * Romanizer of the other mode (Hindi words), as `load(..., { route: true })` passes them.
58
70
  */
59
- export declare function fromBytes(lang: string, mode: Mode, own: Uint8Array, pool: Uint8Array, lm?: Uint8Array): Romanizer;
71
+ export declare function fromBytes(lang: string, mode: Mode, own: Uint8Array, pool: Uint8Array, lm?: Uint8Array, route?: {
72
+ known: Uint8Array;
73
+ other: Romanizer;
74
+ }): Romanizer;
60
75
  /** @internal The model's own list for a unified word (no lookup), for the conformance test. */
61
76
  export declare function _decode(r: Romanizer, word: string, n: number): string[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indickit",
3
- "version": "0.12.0",
3
+ "version": "0.13.0",
4
4
  "description": "Small, exact utilities for text in Indian languages: a phonetic key that matches a name across 21 Indian scripts and English, a normalizer that gives text that looks the same one encoding, a segmenter for the letters a reader sees, and a stemmer for search.",
5
5
  "license": "MIT",
6
6
  "packageManager": "bun@1.3.14",