indickit 0.10.0 → 0.11.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/README.md +127 -65
- package/dist/deromanize.js +1 -1
- package/dist/normalize.js +1 -1
- package/dist/phonetic-search.js +1 -1
- package/dist/phonetic.js +1 -1
- package/dist/romanize.js +1 -1
- package/dist/search-key.js +1 -0
- package/dist/segment.js +1 -1
- package/dist/stem-compounds.js +1 -0
- package/dist/stem.js +1 -1
- package/dist/types/js/deromanize.d.ts +12 -0
- package/dist/types/js/phonetic-engine.d.ts +17 -1
- package/dist/types/js/phonetic-search.d.ts +2 -2
- package/dist/types/js/phonetic.d.ts +6 -4
- package/dist/types/js/romanize.d.ts +9 -5
- package/dist/types/js/search-key.d.ts +14 -0
- package/dist/types/js/stem-compounds.d.ts +16 -0
- package/dist/types/js/stem.d.ts +12 -3
- package/package.json +10 -2
|
@@ -16,8 +16,10 @@ export { MAX_NAME_KEYS };
|
|
|
16
16
|
export declare const RULES_VERSION: string;
|
|
17
17
|
/** The sorted keys of one word; empty when it holds no letter the rules read. */
|
|
18
18
|
export declare function keys(word: string): string[];
|
|
19
|
-
/** A name split
|
|
20
|
-
*
|
|
19
|
+
/** A name split on spaces and punctuation, with anything in brackets removed.
|
|
20
|
+
* nameKeys, joinedKeys and match split this way, then drop the leading
|
|
21
|
+
* titles (Shri, Smt., श्रीमती, திரு) of each comma-separated part ("Bajwa,
|
|
22
|
+
* Sardar Partap Singh"); a name of titles only keeps its last word. */
|
|
21
23
|
export declare function words(name: string): string[];
|
|
22
24
|
/** The keys of a whole name, one per combination of its words' keys, words
|
|
23
25
|
* separated by a space. Two names match when these share an element, so
|
|
@@ -30,6 +32,6 @@ export declare const JOINED_MIN_CLASSES: number;
|
|
|
30
32
|
* least JOINED_MIN_CLASSES classes. A search looks them up only when
|
|
31
33
|
* nameKeys find nobody; match does not use them. */
|
|
32
34
|
export declare function joinedKeys(name: string): string[];
|
|
33
|
-
/** Whether two names have the same number of
|
|
34
|
-
* in order, shares a key. */
|
|
35
|
+
/** Whether two names, their leading titles dropped, have the same number of
|
|
36
|
+
* words and every pair of words, in order, shares a key. */
|
|
35
37
|
export declare function match(a: string, b: string): boolean;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
* लक्ष्मी → lakshmi, മലൈക → malaika, پرویز → parvez.
|
|
4
4
|
*
|
|
5
5
|
* A ranked list: one word has several accepted spellings (Choudhury,
|
|
6
|
-
* Chowdhury), and the first is the most likely.
|
|
7
|
-
* running text (the default)
|
|
8
|
-
* names, where a lookup of known names comes first
|
|
6
|
+
* Chowdhury), and the first is the most likely. Three modes: "words" for
|
|
7
|
+
* running text (the default); "names" for fields known to hold person
|
|
8
|
+
* names, where a lookup of known names comes first; and "places" for place
|
|
9
|
+
* names (its own tables in nine languages, the "words" tables in the others).
|
|
9
10
|
*
|
|
10
11
|
* The tables are learned from data and loaded per language, on demand:
|
|
11
12
|
*
|
|
@@ -17,8 +18,11 @@
|
|
|
17
18
|
*
|
|
18
19
|
* @module
|
|
19
20
|
*/
|
|
20
|
-
/**
|
|
21
|
-
|
|
21
|
+
/**
|
|
22
|
+
* The tables: "words" for running text, "names" for person names, "places" for
|
|
23
|
+
* place names (own tables for bn hi ml mr or sat ta te ur; the "words" tables elsewhere).
|
|
24
|
+
*/
|
|
25
|
+
export type Mode = "words" | "names" | "places";
|
|
22
26
|
/** Changes whenever any output changes: store it beside romanized text. */
|
|
23
27
|
export declare const RULES_VERSION: string;
|
|
24
28
|
/** The language codes that have tables, for one mode. */
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one key to index and to query by:
|
|
3
|
+
* searchKey("किताबों", "hi") === searchKey("किताब", "hi"), and
|
|
4
|
+
* searchKey("हिन्दी", "hi") === searchKey("हिंदी", "hi").
|
|
5
|
+
*
|
|
6
|
+
* It normalizes, stems, then folds. The order was measured on search: fold
|
|
7
|
+
* after stem finds 2.4 points more of the right passages in Hindi and
|
|
8
|
+
* changes nothing in Bengali, Telugu or Assamese; fold before stem costs
|
|
9
|
+
* Assamese 3.7 points. A key is for matching only: never store it as text.
|
|
10
|
+
*
|
|
11
|
+
* @module
|
|
12
|
+
*/
|
|
13
|
+
/** The search key of `word` in language `lang` (a tag such as "hi", "hi-IN" or "hin"). */
|
|
14
|
+
export declare function searchKey(word: string, lang: string): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Malayalam compounds for search: the first member that starts a word.
|
|
3
|
+
* Use it in place of the stem for Malayalam:
|
|
4
|
+
*
|
|
5
|
+
* const key = compoundKey(w) ?? stem(w, "ml");
|
|
6
|
+
*
|
|
7
|
+
* It finds compounds and some oblique forms (കേരളസർക്കാർ and കേരളത്തിലെ
|
|
8
|
+
* share കേരള). On held-out news it found 5.5 points more of the right
|
|
9
|
+
* sentences than `stem` alone, and was 2.9 points less precise. A separate
|
|
10
|
+
* file, so that `stem` stays small for every other language. Normalize text
|
|
11
|
+
* first.
|
|
12
|
+
*
|
|
13
|
+
* @module
|
|
14
|
+
*/
|
|
15
|
+
/** The longest first member that starts `word` and leaves at least two code points, or null. */
|
|
16
|
+
export declare function compoundKey(word: string): string | null;
|
package/dist/types/js/stem.d.ts
CHANGED
|
@@ -19,8 +19,17 @@ export declare const RULES_VERSION: string;
|
|
|
19
19
|
/** The language codes that have a table. */
|
|
20
20
|
export declare const LANGUAGES: readonly string[];
|
|
21
21
|
/**
|
|
22
|
-
* The search key of `word` in language `lang` (
|
|
23
|
-
*
|
|
22
|
+
* The search key of `word` in language `lang` (any of the 22
|
|
23
|
+
* languages of the Eighth Schedule). Only the tag's language counts: "ta-IN", "TA" and "tam" are
|
|
24
24
|
* "ta". For any other `lang`, `word` unchanged.
|
|
25
25
|
*/
|
|
26
|
-
export declare function stem(word: string, lang: string): string;
|
|
26
|
+
export declare function stem(word: string, lang: string, options?: StemOptions): string;
|
|
27
|
+
/** Options for {@link stem}. */
|
|
28
|
+
export type StemOptions = {
|
|
29
|
+
/**
|
|
30
|
+
* The fewest code points a stem keeps (default 2, at most 9). A field of
|
|
31
|
+
* names wants 4: it halves the names that lose their end (करीना → कर) and
|
|
32
|
+
* costs 0.5–2 points of search recall.
|
|
33
|
+
*/
|
|
34
|
+
minStem?: number;
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "indickit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.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",
|
|
@@ -26,6 +26,14 @@
|
|
|
26
26
|
"types": "./dist/types/js/stem.d.ts",
|
|
27
27
|
"default": "./dist/stem.js"
|
|
28
28
|
},
|
|
29
|
+
"./search-key": {
|
|
30
|
+
"types": "./dist/types/js/search-key.d.ts",
|
|
31
|
+
"default": "./dist/search-key.js"
|
|
32
|
+
},
|
|
33
|
+
"./stem-compounds": {
|
|
34
|
+
"types": "./dist/types/js/stem-compounds.d.ts",
|
|
35
|
+
"default": "./dist/stem-compounds.js"
|
|
36
|
+
},
|
|
29
37
|
"./romanize": {
|
|
30
38
|
"types": "./dist/types/js/romanize.d.ts",
|
|
31
39
|
"default": "./dist/romanize.js"
|
|
@@ -48,7 +56,7 @@
|
|
|
48
56
|
],
|
|
49
57
|
"sideEffects": false,
|
|
50
58
|
"scripts": {
|
|
51
|
-
"build": "bun build js/phonetic.ts --outfile dist/phonetic.js --target browser --format esm --minify && bun build js/normalize.ts --outfile dist/normalize.js --target browser --format esm --minify && bun build js/segment.ts --outfile dist/segment.js --target browser --format esm --minify && bun build js/stem.ts --outfile dist/stem.js --target browser --format esm --minify && bun build js/romanize.ts --outfile dist/romanize.js --target browser --format esm --minify && bun build js/phonetic-search.ts --outfile dist/phonetic-search.js --target browser --format esm --minify && bun build js/deromanize.ts --outfile dist/deromanize.js --target browser --format esm --minify && bun build js/wellformed.ts --outfile dist/wellformed.js --target browser --format esm --minify && tsc -p tsconfig.json",
|
|
59
|
+
"build": "bun build js/phonetic.ts --outfile dist/phonetic.js --target browser --format esm --minify && bun build js/normalize.ts --outfile dist/normalize.js --target browser --format esm --minify && bun build js/segment.ts --outfile dist/segment.js --target browser --format esm --minify && bun build js/stem.ts --outfile dist/stem.js --target browser --format esm --minify && bun build js/stem-compounds.ts --outfile dist/stem-compounds.js --target browser --format esm --minify && bun build js/search-key.ts --outfile dist/search-key.js --target browser --format esm --minify && bun build js/romanize.ts --outfile dist/romanize.js --target browser --format esm --minify && bun build js/phonetic-search.ts --outfile dist/phonetic-search.js --target browser --format esm --minify && bun build js/deromanize.ts --outfile dist/deromanize.js --target browser --format esm --minify && bun build js/wellformed.ts --outfile dist/wellformed.js --target browser --format esm --minify && tsc -p tsconfig.json",
|
|
52
60
|
"test": "bun test",
|
|
53
61
|
"check-dist": "node js/check-dist.mjs"
|
|
54
62
|
},
|